:root {
  --primary: #059669;
  --primary-dark: #047857;
  --primary-light: #d1fae5;
  --accent: #10b981;
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --success: #10b981;
  --success-bg: #d1fae5;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 16px;
  padding-bottom: 30px;
}

.app-container {
  max-width: 650px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: linear-gradient(135deg, #065f46 0%, #059669 100%);
  color: white;
  padding: 1.25rem 1.25rem 1rem 1.25rem;
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.badge-protocol {
  display: inline-block;
  background: rgba(255, 255, 255, 0.2);
  color: #a7f3d0;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.header-title-box h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.header-subtitle {
  font-size: 0.8rem;
  color: #a7f3d0;
  margin-top: 4px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: background 0.2s;
}

.icon-btn:active {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(0.95);
}

/* Navigation Tabs */
.nav-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  padding: 0.75rem 1rem 0.25rem 1rem;
}

.tab-btn {
  background: #ffffff;
  border: 1px solid var(--border-color);
  padding: 0.75rem 0.5rem;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.tab-btn i {
  font-size: 1.25rem;
}

.tab-btn.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

/* Content Area */
.tab-content {
  display: none;
  padding: 0.75rem 1rem;
  flex-direction: column;
  gap: 1rem;
}

.tab-content.active {
  display: flex;
  animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.text-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

/* Form Controls */
textarea {
  width: 100%;
  min-height: 120px;
  padding: 0.85rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-color);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text-main);
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
  background: #fdfdfd;
}

textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

.card-actions {
  display: flex;
  gap: 8px;
}

/* Buttons */
.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.action-btn:active {
  transform: scale(0.98);
}

.primary-btn {
  background: var(--primary);
  color: white;
}

.primary-btn:hover {
  background: var(--primary-dark);
}

.secondary-btn {
  background: #f1f5f9;
  color: var(--text-main);
  font-size: 0.85rem;
  padding: 0.6rem 1rem;
}

/* Stat Cards */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.stat-card {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 0.5rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.stat-num {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary-dark);
}

.stat-lbl {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 2px;
}

/* Status Badges */
.badge-status {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
}

.badge-status.ok {
  background: var(--success-bg);
  color: #065f46;
}

.badge-status.warn {
  background: var(--danger-bg);
  color: #991b1b;
}

/* Sentence Report List */
.sentence-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
}

.sentence-item {
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  font-size: 0.95rem;
  border-left: 4px solid var(--border-color);
  background: #f8fafc;
}

.sentence-item.ok {
  border-left-color: var(--success);
  background: #f0fdf4;
}

.sentence-item.violation {
  border-left-color: var(--danger);
  background: #fef2f2;
}

.sentence-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  font-size: 0.75rem;
  font-weight: 700;
}

.word-count-badge {
  padding: 2px 6px;
  border-radius: 4px;
}

.word-count-badge.ok {
  background: #dcfce7;
  color: #166534;
}

.word-count-badge.bad {
  background: #fee2e2;
  color: #991b1b;
}

.violation-tag {
  color: var(--danger);
  font-size: 0.75rem;
  margin-top: 4px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 2.5rem;
  color: #cbd5e1;
  margin-bottom: 0.75rem;
}

/* Adapted output area */
.adapted-output-area {
  min-height: 120px;
  padding: 0.85rem;
  border-radius: var(--radius-md);
  background: #f8fafc;
  border: 1.5px dashed #cbd5e1;
  font-size: 1rem;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--text-main);
}

/* Spinner */
.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading .btn-spinner {
  display: block;
}

.loading span, .loading i {
  display: none;
}

/* Rules Section */
.rules-intro {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.rule-box {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 0.75rem;
  background: #f8fafc;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.rule-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}

.rule-icon.ok {
  background: var(--success-bg);
  color: var(--success);
}

.rule-icon.warn {
  background: var(--warning-bg);
  color: var(--warning);
}

.rule-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.85rem;
}

.rule-text strong {
  font-size: 0.95rem;
  color: var(--text-main);
}

/* Modal */
.modal-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop.open {
  display: flex;
  animation: fadeIn 0.2s ease-out;
}

.modal-card {
  background: white;
  width: 100%;
  max-width: 450px;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 0.75rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 700;
}

.form-group input,
.form-select {
  padding: 0.75rem;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  background: white;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s;
}

.form-select:focus,
.form-group input:focus {
  border-color: var(--primary);
}

.input-with-action {
  display: flex;
  gap: 6px;
  align-items: center;
}

.input-with-action input {
  flex: 1;
}

.small-icon-btn {
  background: #f1f5f9;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
}

.small-icon-btn:active {
  background: #e2e8f0;
}

.form-group small {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.platform-info {
  display: flex;
  justify-content: space-between;
  background: #f1f5f9;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1e293b;
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  z-index: 300;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}
