/*
 * style.css — ClearAsk styles
 *
 * Design principles:
 *   - Calm, friendly, non-judgmental
 *   - WCAG AA contrast, 44px touch targets
 *   - Mobile-first responsive
 *   - Theming via CSS custom properties
 *   - Visible focus rings, never rely on color alone
 */

/* ── Fonts ────────────────────────────────────────────────── */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

@font-face {
  font-family: "OpenDyslexic";
  src: url("https://cdn.jsdelivr.net/npm/open-dyslexic@1.0.3/woff/OpenDyslexic-Regular.woff") format("woff");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "OpenDyslexic";
  src: url("https://cdn.jsdelivr.net/npm/open-dyslexic@1.0.3/woff/OpenDyslexic-Bold.woff") format("woff");
  font-weight: 700;
  font-display: swap;
}

/* ── Theme Variables ──────────────────────────────────────── */

:root {
  /* Light theme (default) */
  --bg-primary: #f0f2ff;
  --bg-secondary: #e8ecff;
  --surface: #ffffff;
  --surface-hover: #f5f6ff;
  --text-primary: #1a1a2e;
  --text-secondary: #555770;
  --text-tertiary: #8888a0;
  --accent: #6C63FF;
  --accent-hover: #5A52D5;
  --accent-light: #ededff;
  --accent-text: #ffffff;
  --success: #00B894;
  --success-bg: #e6f9f3;
  --warning: #e17055;
  --warning-bg: #fff0ec;
  --info: #0984e3;
  --info-bg: #e8f4fd;
  --border: #dfe1f0;
  --border-strong: #c0c4e0;
  --shadow-sm: 0 1px 3px rgba(108, 99, 255, 0.06);
  --shadow-md: 0 4px 16px rgba(108, 99, 255, 0.08);
  --shadow-lg: 0 8px 32px rgba(108, 99, 255, 0.12);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 100px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  /* Highlight colors */
  --hl-time: #6C63FF;
  --hl-time-bg: #ededff;
  --hl-quantity: #e17055;
  --hl-quantity-bg: #fff0ec;
  --hl-quality: #00b894;
  --hl-quality-bg: #e6f9f3;
  --hl-scope: #0984e3;
  --hl-scope-bg: #e8f4fd;
  --hl-hedging: #d63031;
  --hl-hedging-bg: #ffe5e5;
  --hl-filler: #636e72;
  --hl-filler-bg: #f0f0f0;

  /* User overrides */
  --user-font-size: 100%;
  --user-line-height: 1.6;

  /* Font */
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
}

/* ── Dark Theme ───────────────────────────────────────────── */

[data-theme="dark"] {
  --bg-primary: #0f0f1a;
  --bg-secondary: #16162a;
  --surface: #1e1e38;
  --surface-hover: #28284a;
  --text-primary: #e8e8f0;
  --text-secondary: #a0a0c0;
  --text-tertiary: #707090;
  --accent: #8b83ff;
  --accent-hover: #a09aff;
  --accent-light: #2a2850;
  --accent-text: #ffffff;
  --success: #55efc4;
  --success-bg: #1a3a30;
  --warning: #ff7675;
  --warning-bg: #3a1a1a;
  --info: #74b9ff;
  --info-bg: #1a2a3a;
  --border: #30305a;
  --border-strong: #4a4a7a;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --hl-time-bg: #2a2850;
  --hl-quantity-bg: #3a2020;
  --hl-quality-bg: #1a3a30;
  --hl-scope-bg: #1a2a3a;
  --hl-hedging-bg: #3a1a1a;
  --hl-filler-bg: #2a2a2a;
}

/* ── High Contrast Theme ──────────────────────────────────── */

[data-theme="high-contrast"] {
  --bg-primary: #000000;
  --bg-secondary: #0a0a0a;
  --surface: #000000;
  --surface-hover: #1a1a1a;
  --text-primary: #ffffff;
  --text-secondary: #e0e0e0;
  --text-tertiary: #c0c0c0;
  --accent: #ffff00;
  --accent-hover: #ffff66;
  --accent-light: #333300;
  --accent-text: #000000;
  --success: #00ff00;
  --success-bg: #003300;
  --warning: #ff4444;
  --warning-bg: #440000;
  --info: #00ccff;
  --info-bg: #002233;
  --border: #ffffff;
  --border-strong: #ffffff;
  --shadow-sm: 0 0 0 1px #fff;
  --shadow-md: 0 0 0 2px #fff;
  --shadow-lg: 0 0 0 3px #fff;
  --hl-time: #ffff00;
  --hl-time-bg: #333300;
  --hl-quantity: #ff6600;
  --hl-quantity-bg: #331a00;
  --hl-quality: #00ff00;
  --hl-quality-bg: #003300;
  --hl-scope: #00ccff;
  --hl-scope-bg: #002233;
  --hl-hedging: #ff4444;
  --hl-hedging-bg: #440000;
  --hl-filler: #cc99ff;
  --hl-filler-bg: #220044;
}

/* ── Calm Theme ───────────────────────────────────────────── */

[data-theme="calm"] {
  --bg-primary: #f5f0eb;
  --bg-secondary: #ece5dc;
  --surface: #fffdf8;
  --surface-hover: #f8f4ee;
  --text-primary: #3d3d3d;
  --text-secondary: #6b6b5e;
  --text-tertiary: #9a9a8c;
  --accent: #7B8F6B;
  --accent-hover: #698060;
  --accent-light: #e8efe0;
  --accent-text: #ffffff;
  --success: #7B8F6B;
  --success-bg: #e8efe0;
  --warning: #c5874f;
  --warning-bg: #faebd7;
  --info: #6b8fa0;
  --info-bg: #e0eff5;
  --border: #d8d0c4;
  --border-strong: #c0b8a8;
  --shadow-sm: 0 1px 3px rgba(100, 80, 50, 0.06);
  --shadow-md: 0 4px 16px rgba(100, 80, 50, 0.08);
  --shadow-lg: 0 8px 32px rgba(100, 80, 50, 0.12);
  --hl-time: #7B8F6B;
  --hl-time-bg: #e8efe0;
  --hl-quantity: #c5874f;
  --hl-quantity-bg: #faebd7;
  --hl-quality: #6b8fa0;
  --hl-quality-bg: #e0eff5;
  --hl-scope: #a07b5f;
  --hl-scope-bg: #f0e0d0;
  --hl-hedging: #b06060;
  --hl-hedging-bg: #f0e0e0;
  --hl-filler: #8a8a7a;
  --hl-filler-bg: #eeeedf;
}

/* ── Dyslexia Font ────────────────────────────────────────── */

.dyslexia-font {
  --font-body: "OpenDyslexic", "Inter", system-ui, sans-serif;
}

/* ── Reduced Motion ───────────────────────────────────────── */

.reduced-motion,
.reduced-motion * {
  animation-duration: 0.01ms !important;
  transition-duration: 0.01ms !important;
}

/* ── Base Reset & Typography ──────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: var(--user-font-size);
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: var(--user-line-height);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ── Skip Link ────────────────────────────────────────────── */

.skip-link {
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: var(--accent-text);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  z-index: 10000;
  text-decoration: none;
  transition: top var(--transition);
}

.skip-link:focus {
  top: 12px;
}

/* ── Focus Styles ─────────────────────────────────────────── */

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ── Screen Reader Only ───────────────────────────────────── */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Background Decoration ────────────────────────────────── */

.bg-decoration {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
}

.bg-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.12;
  animation: float 20s ease-in-out infinite;
}

.bg-blob:nth-child(1) {
  width: 500px;
  height: 500px;
  background: var(--accent);
  top: -200px;
  right: -100px;
  animation-delay: -5s;
}

.bg-blob:nth-child(2) {
  width: 400px;
  height: 400px;
  background: var(--success);
  bottom: -150px;
  left: -100px;
  animation-delay: -10s;
}

.bg-blob:nth-child(3) {
  width: 300px;
  height: 300px;
  background: var(--info);
  top: 40%;
  right: 30%;
  animation-delay: -15s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -30px) scale(1.05); }
  66% { transform: translate(-20px, 20px) scale(0.95); }
}

/* ── App Container ────────────────────────────────────────── */

.app {
  max-width: 860px;
  margin: 0 auto;
  padding: 16px;
  position: relative;
}

/* ── Header ───────────────────────────────────────────────── */

.app-header {
  text-align: center;
  padding: 28px 16px 20px;
  position: relative;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.logo-icon {
  font-size: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  border-radius: var(--radius-md);
  color: var(--accent-text);
  box-shadow: var(--shadow-md);
}

.app-header h1 {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--success));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.tagline {
  color: var(--text-secondary);
  font-size: 0.95rem;
  max-width: 440px;
  margin: 4px auto 0;
}

.header-actions {
  position: absolute;
  top: 28px;
  right: 16px;
  display: flex;
  gap: 8px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.15rem;
  transition: all var(--transition);
  position: relative;
}

.icon-btn:hover, .icon-btn:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.header-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ── Card ─────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow-md);
  transition: box-shadow var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

/* ── Input Screen ─────────────────────────────────────────── */

.input-label {
  display: block;
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.input-label-hint {
  display: block;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-secondary);
  margin-top: 2px;
}

.message-textarea {
  width: 100%;
  min-height: 160px;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: var(--user-line-height);
  color: var(--text-primary);
  background: var(--bg-primary);
  resize: vertical;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.message-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-light);
}

.input-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
  align-items: center;
}

.sender-select {
  flex: 1;
  min-width: 180px;
  padding: 10px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--surface);
  cursor: pointer;
  min-height: 44px;
  transition: border-color var(--transition);
}

.sender-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-light);
}

.voice-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  cursor: pointer;
  min-height: 44px;
  transition: all var(--transition);
}

.voice-btn:hover, .voice-btn:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

.voice-btn.listening {
  border-color: var(--warning);
  color: var(--warning);
  animation: pulse-border 1.5s ease-in-out infinite;
}

@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 0 0 rgba(225, 112, 85, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(225, 112, 85, 0); }
}

.char-count {
  color: var(--text-tertiary);
  font-size: 0.8rem;
  margin-left: auto;
}

/* ── Primary Button ───────────────────────────────────────── */

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px 32px;
  margin-top: 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: var(--accent-text);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 56px;
  transition: all var(--transition);
  box-shadow: 0 4px 16px rgba(108, 99, 255, 0.3);
  letter-spacing: 0.01em;
}

.btn-primary:hover, .btn-primary:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(108, 99, 255, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(108, 99, 255, 0.3);
}

.btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

/* ── Spinner ──────────────────────────────────────────────── */

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--accent-text);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Examples Section ─────────────────────────────────────── */

.examples-section {
  margin-top: 24px;
  text-align: center;
}

.examples-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.example-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.example-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
  transition: all var(--transition);
}

.example-btn:hover, .example-btn:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
  transform: translateY(-1px);
}

/* ── Encouragement Banner ─────────────────────────────────── */

.encouragement {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  padding: 14px 18px;
  background: var(--accent-light);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--accent);
}

.encouragement-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.encouragement p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── Results Screen ───────────────────────────────────────── */

.screen {
  outline: none;
}

.results-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  cursor: pointer;
  min-height: 44px;
  transition: all var(--transition);
}

.back-btn:hover, .back-btn:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

.read-all-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  cursor: pointer;
  min-height: 44px;
  margin-left: auto;
  transition: all var(--transition);
}

.read-all-btn:hover, .read-all-btn:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Section Tabs ─────────────────────────────────────────── */

.section-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 20px;
  padding: 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

.section-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
  transition: all var(--transition);
  white-space: nowrap;
}

.section-tab:hover {
  color: var(--accent);
  background: var(--surface);
}

.section-tab.active {
  color: var(--accent);
  background: var(--surface);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* ── Clarity Score ────────────────────────────────────────── */

#clarity-score {
  text-align: center;
  padding: 20px;
}

.clarity-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: var(--radius-full);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.clarity-icon {
  font-size: 1.3rem;
}

.clarity-clear {
  background: var(--success-bg);
  color: var(--success);
  border: 2px solid var(--success);
}

.clarity-partly-clear {
  background: var(--info-bg);
  color: var(--info);
  border: 2px solid var(--info);
}

.clarity-mostly-unclear {
  background: var(--warning-bg);
  color: var(--warning);
  border: 2px solid var(--warning);
}

.clarity-description {
  margin-top: 10px;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ── Highlighted Text ─────────────────────────────────────── */

.highlight-summary {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.highlighted-message {
  padding: 20px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  line-height: 1.9;
  font-size: 1.05rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.vague-highlight {
  background: var(--hl-time-bg);
  color: var(--hl-time);
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: wavy;
  text-underline-offset: 3px;
  text-decoration-thickness: 2px;
  font-weight: 600;
  position: relative;
  transition: background var(--transition);
  display: inline;
}

/* Category-specific highlight colors */
.vague-highlight[data-category="time"] {
  background: var(--hl-time-bg);
  color: var(--hl-time);
  text-decoration-color: var(--hl-time);
}
.vague-highlight[data-category="quantity"] {
  background: var(--hl-quantity-bg);
  color: var(--hl-quantity);
  text-decoration-color: var(--hl-quantity);
}
.vague-highlight[data-category="quality"] {
  background: var(--hl-quality-bg);
  color: var(--hl-quality);
  text-decoration-color: var(--hl-quality);
}
.vague-highlight[data-category="scope"] {
  background: var(--hl-scope-bg);
  color: var(--hl-scope);
  text-decoration-color: var(--hl-scope);
}
.vague-highlight[data-category="hedging"] {
  background: var(--hl-hedging-bg);
  color: var(--hl-hedging);
  text-decoration-color: var(--hl-hedging);
}
.vague-highlight[data-category="filler"] {
  background: var(--hl-filler-bg);
  color: var(--hl-filler);
  text-decoration-color: var(--hl-filler);
}

.vague-highlight:hover, .vague-highlight:focus-visible {
  filter: brightness(0.92);
}

.vague-icon {
  margin-right: 2px;
  font-size: 0.85em;
}

/* ── Vague Word Tooltip ───────────────────────────────────── */

.vague-tooltip {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: min(340px, 90vw);
  padding: 18px;
  background: var(--surface);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  text-align: left;
  animation: tooltip-in 0.2s ease-out;
}

@keyframes tooltip-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.tooltip-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.tooltip-close:hover {
  color: var(--text-primary);
  background: var(--bg-primary);
}

.tooltip-title {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.tooltip-explanation {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
  line-height: 1.5;
  text-decoration: none;
}

.tooltip-interp-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-tertiary);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tooltip-interps {
  list-style: none;
  padding: 0;
}

.tooltip-interps li {
  font-size: 0.9rem;
  color: var(--text-primary);
  padding: 6px 0;
  border-top: 1px solid var(--border);
  line-height: 1.4;
  text-decoration: none;
}

/* ── Info Checklist ────────────────────────────────────────── */

.checklist-summary {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.info-checklist {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 6px;
}

.info-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  transition: background var(--transition);
}

.info-found {
  background: var(--success-bg);
}

.info-missing {
  background: var(--warning-bg);
  font-weight: 500;
}

.info-status {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.info-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.found-detail {
  color: var(--text-tertiary);
  font-size: 0.85rem;
  font-style: italic;
}

/* ── Questions ────────────────────────────────────────────── */

.questions-intro, .no-questions {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.questions-list {
  padding: 0;
  counter-reset: question;
  list-style: none;
}

.question-item {
  padding: 16px 20px;
  margin-bottom: 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  counter-increment: question;
  position: relative;
  padding-left: 52px;
}

.question-item::before {
  content: counter(question);
  position: absolute;
  left: 16px;
  top: 16px;
  width: 28px;
  height: 28px;
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
}

.question-text {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.question-why {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.why-label {
  font-weight: 600;
  color: var(--text-tertiary);
}

/* ── Message Writer ───────────────────────────────────────── */

.messages-intro {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.tone-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.tone-tab {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
  transition: all var(--transition);
}

.tone-tab:hover {
  color: var(--accent);
}

.tone-tab.active {
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.tone-panel {
  display: none;
}

.tone-panel.active {
  display: block;
}

.message-textarea {
  width: 100%;
  min-height: 180px;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-primary);
  resize: vertical;
  transition: border-color var(--transition);
}

.message-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-light);
}

.message-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.copy-btn, .tts-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
  transition: all var(--transition);
}

.copy-btn:hover, .copy-btn:focus-visible,
.tts-btn:hover, .tts-btn:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

/* ── Assumptions ──────────────────────────────────────────── */

.assumptions-intro, .no-assumptions {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.assumptions-list {
  list-style: none;
  padding: 0;
}

.assumption-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 18px;
  margin-bottom: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--accent);
}

.assumption-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-tertiary);
}

.assumption-value {
  font-size: 0.95rem;
  color: var(--text-primary);
}

.assumptions-advice {
  margin-top: 16px;
  padding: 14px 18px;
  background: var(--accent-light);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── Simplify Mode ────────────────────────────────────────── */

.simplify-toggle-wrapper {
  margin-bottom: 14px;
}

.simplify-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  cursor: pointer;
  min-height: 44px;
}

.simplify-toggle input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  cursor: pointer;
}

.simplify-content {
  display: grid;
  gap: 16px;
  transition: all var(--transition);
}

.simplify-content.side-by-side {
  grid-template-columns: 1fr 1fr;
}

.simplified-text, .original-text-side {
  padding: 18px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.simplified-text h4, .original-text-side h4 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  margin-bottom: 10px;
}

.simplified-text p, .original-text-side p {
  white-space: pre-wrap;
  line-height: 1.7;
}

/* ── AI Analysis Banner ──────────────────────────────────── */

.ai-banner {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 16px;
}

.ai-banner.ai-success {
  background: #e6f9e6;
  color: #1a7a1a;
  border: 1px solid #9ae69a;
}

.ai-banner.ai-fallback {
  background: #fff8e6;
  color: #7a5a00;
  border: 1px solid #e6d080;
}

/* ── Side Panels (Settings & History) ─────────────────────── */

.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 900;
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}

.panel-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.side-panel {
  position: fixed;
  top: 0;
  right: -400px;
  width: min(380px, 90vw);
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  overflow-y: auto;
  transition: right var(--transition);
  padding: 24px;
}

.side-panel.open {
  right: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.panel-close {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.panel-close:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* ── Settings Form ────────────────────────────────────────── */

.settings-group {
  margin-bottom: 22px;
}

.settings-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.settings-group .hint {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}

.settings-select {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--bg-primary);
  min-height: 44px;
}

.settings-select:focus {
  outline: none;
  border-color: var(--accent);
}

.settings-range {
  width: 100%;
  height: 8px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 4px;
  outline: none;
  margin-top: 4px;
}

.settings-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
}

.settings-range::-moz-range-thumb {
  width: 24px;
  height: 24px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.range-value {
  display: inline-block;
  margin-left: 8px;
  font-size: 0.85rem;
  color: var(--text-tertiary);
  font-weight: 500;
}

.settings-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  min-height: 44px;
}

.settings-checkbox input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.api-key-group {
  padding: 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 8px;
}

.api-key-input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--text-primary);
  background: var(--surface);
  min-height: 44px;
  margin-top: 6px;
}

.api-key-input:focus {
  outline: none;
  border-color: var(--accent);
}

.api-key-note {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  margin-top: 6px;
  line-height: 1.4;
}

/* ── History List ─────────────────────────────────────────── */

.history-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.history-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 40px;
  transition: all var(--transition);
}

.history-action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.history-action-btn.danger:hover {
  border-color: var(--warning);
  color: var(--warning);
}

.history-empty {
  font-size: 0.9rem;
  color: var(--text-tertiary);
  text-align: center;
  padding: 24px;
}

.history-entry {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  background: var(--bg-primary);
  transition: background var(--transition);
}

.history-entry:hover {
  background: var(--surface-hover);
}

.history-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.history-date {
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

.history-clarity {
  font-size: 0.72rem;
  padding: 3px 10px;
}

.history-preview {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 8px;
}

.history-delete {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 0.78rem;
  cursor: pointer;
  min-height: 32px;
  transition: all var(--transition);
}

.history-delete:hover {
  border-color: var(--warning);
  color: var(--warning);
}

/* ── Result Section Cards ─────────────────────────────────── */

.result-section {
  outline: none;
}

.result-section .card {
  margin-bottom: 0;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title-icon {
  font-size: 1.2rem;
}

/* ── Footer ───────────────────────────────────────────────── */

.app-footer {
  text-align: center;
  padding: 28px 16px;
  color: var(--text-tertiary);
  font-size: 0.82rem;
  line-height: 1.6;
}

.app-footer a {
  color: var(--accent);
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 600px) {
  .app {
    padding: 10px;
  }

  .app-header h1 {
    font-size: 1.5rem;
  }

  .header-actions {
    position: static;
    justify-content: center;
    margin-top: 12px;
  }

  .card {
    padding: 20px 16px;
  }

  .section-tabs {
    gap: 2px;
    padding: 3px;
  }

  .section-tab {
    padding: 8px 10px;
    font-size: 0.78rem;
  }

  .simplify-content.side-by-side {
    grid-template-columns: 1fr;
  }

  .results-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .read-all-btn {
    margin-left: 0;
  }

  .tone-tabs {
    flex-direction: column;
  }
}

@media (min-width: 768px) {
  .app {
    padding: 24px;
  }

  .app-header {
    padding: 40px 24px 28px;
  }
}

/* ── Print Styles ─────────────────────────────────────────── */

@media print {
  .bg-decoration,
  .header-actions,
  .skip-link,
  .panel-overlay,
  .side-panel,
  .copy-btn,
  .tts-btn,
  .voice-btn,
  .back-btn,
  .read-all-btn,
  .example-buttons,
  .section-tabs {
    display: none !important;
  }

  .result-section {
    display: block !important;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ccc;
  }

  body {
    background: white;
    color: black;
  }
}

/* ── Layout Overrides ─────────────────────────────────────── */
body { background:#f1f4ff; }
.app { max-width:720px !important; margin:0 auto !important; padding:16px !important; }
label { display:block !important; font-weight:600; margin-bottom:6px; }
#message-input { display:block !important; width:100% !important; min-height:180px !important; font-size:16px !important; padding:12px !important; border:2px solid #1d4ed8 !important; border-radius:12px !important; box-sizing:border-box !important; }
select, input[type="text"], input[type="password"] { min-height:44px !important; font-size:16px !important; border:2px solid #1d4ed8 !important; border-radius:8px !important; padding:6px 10px !important; background:#fff !important; }
button { min-height:44px !important; font-size:16px !important; border-radius:10px !important; cursor:pointer; padding:8px 16px !important; background:#fff !important; color:#1d4ed8 !important; border:2px solid #1d4ed8 !important; }
#decode-btn { background:#1d4ed8 !important; color:#fff !important; font-size:18px !important; font-weight:700 !important; min-height:52px !important; width:100% !important; margin-top:12px !important; }
#decode-btn:hover { background:#1e40af !important; }
button:focus-visible, select:focus-visible, textarea:focus-visible, input:focus-visible, a:focus-visible { outline:3px solid #f59e0b !important; outline-offset:2px !important; }
.example-btn { border-radius:9999px !important; margin:4px !important; }
.result-section, section.result-section { background:#fff !important; border:1px solid #cbd5e1 !important; border-radius:12px !important; padding:16px !important; margin-top:16px !important; }
@media (max-width:480px){ button { width:100%; } .example-btn { width:auto; } }

#highlighted-text, .highlighted-message, .highlight-summary, .highlight-hint { margin:0 !important; padding:8px 0 !important; min-height:0 !important; }
#highlighted-text { line-height:2 !important; font-size:18px !important; }
.result-section p { margin:8px 0 !important; }
