/* ==========================================================================
   다듬 스튜디오 (Dadeum Studio) 맞춤법 & 띄어쓰기 검사기 CSS Design System
   ========================================================================== */

@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css');

:root {
  /* Color Palette - Light Mode */
  --bg-primary: #f8f9fa;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f3f5;
  --border-color: #e9ecef;
  --border-focus: #4b6bfb;

  --text-main: #191f28;
  --text-muted: #4e5968;
  --text-subtle: #8b95a1;

  /* Brand Accents */
  --brand-primary: #2b3a4a;
  --brand-accent: #4b6bfb;
  --brand-hover: #3b56d9;
  --brand-subtle: #edf0ff;

  /* Error Categories - National Institute of Korean Language Standards
     NOTE: category 'red' = spacing errors, category 'blue' = spelling errors,
     but per product decision spacing is rendered in BLUE and spelling in RED,
     so the --error-red/--error-blue variable VALUES are intentionally swapped
     here. Every ".red"/".blue" class (chips, underlines, cards) just uses
     these variables, so the swap propagates consistently everywhere. */
  --error-red: #1890ff;
  --error-red-bg: #e6f7ff;
  --error-red-border: #91d5ff;

  --error-blue: #ff4d4f;
  --error-blue-bg: #fff1f0;
  --error-blue-border: #ffa39e;

  --error-green: #52c41a;
  --error-green-bg: #f6ffed;
  --error-green-border: #b7eb8f;

  --error-purple: #722ed1;
  --error-purple-bg: #f9f0ff;
  --error-purple-border: #d3ade6;

  /* Layout & Shadows */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.12);
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);

  /* Slim white pointing-hand cursor (drawn inline as SVG so no extra file is
     needed), used on anything clickable inside the text so it reads as
     tappable. A narrow single-finger silhouette rather than a rounded mitten,
     so it stays crisp and doesn't cover the word underneath.
     Falls back to the OS hand cursor if data-URI cursors are unsupported. */
  --cursor-hand: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="26" height="26" viewBox="0 0 26 26"><path d="M9.6 13.2V4.4a1.35 1.35 0 012.7 0v6.7h.9V6.2a1.3 1.3 0 012.6 0v5h.9V7.6a1.25 1.25 0 012.5 0v6.9c0 4.6-2.1 8-6.2 8-2.6 0-4.1-1.2-5.2-3.4l-2.5-5a1.4 1.4 0 012.3-1.5z" fill="white" stroke="black" stroke-width="1.25" stroke-linejoin="round"/></svg>') 10 2, pointer;
}

/* Dark Mode Tokens */
[data-theme="dark"] {
  --bg-primary: #0f1218;
  --bg-surface: #181d26;
  --bg-subtle: #222936;
  --border-color: #2d3648;
  --border-focus: #637eff;

  --text-main: #f0f4f8;
  --text-muted: #a0aec0;
  --text-subtle: #718096;

  --brand-primary: #e2e8f0;
  --brand-accent: #637eff;
  --brand-hover: #7b93ff;
  --brand-subtle: #1c264d;

  --error-red: #40a9ff;
  --error-red-bg: #112138;
  --error-red-border: #15395b;

  --error-blue: #ff7875;
  --error-blue-bg: #2a1215;
  --error-blue-border: #5c1d24;

  --error-green: #73d13d;
  --error-green-bg: #162613;
  --error-green-border: #274917;

  --error-purple: #9254de;
  --error-purple-bg: #221338;
  --error-purple-border: #441d6e;
}

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

body {
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */
.app-header {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 32px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-container {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
}

.brand-logo {
  height: 48px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.05));
  transition: transform var(--transition-fast);
}

.brand-logo:hover {
  transform: scale(1.03);
}

.brand-title-wrap {
  display: flex;
  flex-direction: column;
}

/* SEO를 위해 <h1> 태그로 바꿨으므로 브라우저 기본 여백/크기를 초기화합니다. */
.brand-name {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
  margin: 0;
  line-height: 1.3;
}

.brand-badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--brand-accent);
  background: var(--brand-subtle);
  padding: 2px 8px;
  border-radius: 20px;
  display: inline-block;
  margin-top: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Tool Buttons */
.btn-icon-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon-text:hover {
  color: var(--text-main);
  background-color: var(--border-color);
  border-color: var(--text-subtle);
}

/* Theme Toggle Button */
.theme-toggle {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.theme-toggle:hover {
  color: var(--brand-accent);
  background-color: var(--bg-subtle);
}

/* ==========================================================================
   Main App Workspace (Split View)
   ========================================================================== */
.main-container {
  max-width: 1600px;
  width: 100%;
  margin: 24px auto;
  padding: 0 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Top Toolbar Bar */
.control-toolbar {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
  gap: 12px;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mode-select-group {
  display: flex;
  background-color: var(--bg-subtle);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.mode-btn {
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  background: none;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.mode-btn.active {
  background-color: var(--bg-surface);
  color: var(--brand-accent);
  box-shadow: var(--shadow-sm);
}

.tone-selector-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.tone-select {
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-main);
  outline: none;
  cursor: pointer;
}

/* Split Workspace Container */
.workspace-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  min-height: 680px;
}

@media (max-width: 1024px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

/* Card Container */
.card-panel {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-surface);
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title-icon {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--brand-accent);
}

/* Input Card Specifics */
.input-area-wrap {
  flex: 1;
  min-height: 520px;
  position: relative;
}

/* Shared box model for the textarea and its highlight overlay so text
   lines up pixel-for-pixel between the two stacked layers. */
.input-area-wrap .editor-textarea,
.input-area-wrap .input-highlight-layer {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 20px;
  font-family: inherit;
  font-size: 1.05rem;
  /* A little extra line-height (vs. the 1.6 used in the result panel) leaves
     just enough headroom for the small correction hint that floats above
     flagged words, without overlapping the line above it. */
  line-height: 2.05;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
  box-sizing: border-box;
}

.editor-textarea {
  width: 100%;
  height: 100%;
  color: transparent;
  caret-color: var(--text-main);
  background: transparent;
  border: none;
  resize: none;
  outline: none;
  z-index: 2;
  overflow-y: auto;
}

.editor-textarea::placeholder {
  color: var(--text-subtle);
  font-size: 0.98rem;
}

/* The textarea's own text is transparent (the overlay draws the visible
   text), so an opaque selection background would read as a solid gray block.
   A translucent accent tint lets the overlay text stay readable through it,
   matching how selection looks in the 교정 결과 panel. */
.editor-textarea::selection {
  background-color: rgba(75, 107, 251, 0.25);
}

/* Stacked ON TOP of the (text-transparent) textarea, but click-through:
   the layer itself has pointer-events:none so typing/selection still reach
   the textarea underneath, while individual correction hints re-enable
   pointer events so they can be clicked to apply/undo a fix. */
.input-highlight-layer {
  color: var(--text-main);
  pointer-events: none;
  overflow: hidden;
  z-index: 3;
}

/* A plain inline span (not <ruby>) so the floating hint is taken out of
   normal flow via absolute positioning — it never widens the element, which
   would otherwise desync this layer's line-wrapping from the textarea's.
   pointer-events is re-enabled here (the parent layer is click-through) so
   ONLY the flagged word itself is clickable — clicking anywhere else falls
   through to the textarea and just moves the caret. */
.input-mark {
  position: relative;
  display: inline;
  padding-bottom: 1px;
  pointer-events: auto;
  cursor: var(--cursor-hand);
}

.input-mark.cat-red { border-bottom: 2px solid var(--error-red); }
.input-mark.cat-blue { border-bottom: 2px solid var(--error-blue); }
.input-mark.cat-green { border-bottom: 2px solid var(--error-green); }
.input-mark.cat-purple { border-bottom: 2px solid var(--error-purple); }

.input-mark .hint {
  position: absolute;
  left: 0;
  bottom: 100%;
  white-space: nowrap;
  font-size: 0.62em;
  font-weight: 800;
  line-height: 1;
  user-select: none;
  pointer-events: auto;
  cursor: var(--cursor-hand);
  padding: 0 2px;
  border-radius: 3px;
  transition: background-color var(--transition-fast);
}

.input-mark .hint:hover {
  background-color: var(--bg-subtle);
}

.input-mark.cat-red .hint { color: var(--error-red); }
.input-mark.cat-blue .hint { color: var(--error-blue); }
.input-mark.cat-green .hint { color: var(--error-green); }
.input-mark.cat-purple .hint { color: var(--error-purple); }

/* Card Footer Toolbar */
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.text-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.82rem;
  color: var(--text-subtle);
  font-weight: 500;
}

.stat-item span {
  font-weight: 700;
  color: var(--text-main);
}

/* Primary CTA Button */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  background-color: var(--brand-accent);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(75, 107, 251, 0.3);
  transition: all var(--transition-fast);
}

.btn-primary:hover {
  background-color: var(--brand-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(75, 107, 251, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

/* Secondary Button */
.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--brand-accent);
  background-color: var(--brand-subtle);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-secondary:hover {
  background-color: var(--brand-accent);
  color: #ffffff;
}

/* ==========================================================================
   Output / Correction Panel
   ========================================================================== */
.error-summary-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.summary-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.summary-chip:hover {
  transform: translateY(-1px);
}

.summary-chip.red {
  color: var(--error-red);
  background-color: var(--error-red-bg);
  border: 1px solid var(--error-red-border);
}

.summary-chip.blue {
  color: var(--error-blue);
  background-color: var(--error-blue-bg);
  border: 1px solid var(--error-blue-border);
}

.summary-chip.green {
  color: var(--error-green);
  background-color: var(--error-green-bg);
  border: 1px solid var(--error-green-border);
}

.summary-chip.purple {
  color: var(--error-purple);
  background-color: var(--error-purple-bg);
  border: 1px solid var(--error-purple-border);
}

/* Banner shown above the result panel while an 어조 변환 is active,
   making it obvious the result differs from the (untouched) 원문. */
.tone-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background-color: var(--brand-subtle);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--brand-accent);
}

.tone-notice-reset {
  flex-shrink: 0;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--brand-accent);
  background-color: var(--bg-surface);
  border: 1px solid var(--brand-accent);
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tone-notice-reset:hover {
  background-color: var(--brand-accent);
  color: #ffffff;
}

/* Correction View Box */
.output-content-wrap {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  min-height: 480px;
  max-height: 580px;
}

/* Interactive Highlighted Render Text */
.rendered-text {
  font-size: 1.05rem;
  line-height: 2;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Error Highlight Underlines & Badges */
.mark-error {
  padding: 2px 4px;
  border-radius: 4px;
  font-weight: 600;
  cursor: var(--cursor-hand);
  position: relative;
  transition: all var(--transition-fast);
}

.mark-error.red {
  color: var(--error-red);
  background-color: var(--error-red-bg);
  border-bottom: 2px solid var(--error-red);
}

.mark-error.blue {
  color: var(--error-blue);
  background-color: var(--error-blue-bg);
  border-bottom: 2px solid var(--error-blue);
}

.mark-error.green {
  color: var(--error-green);
  background-color: var(--error-green-bg);
  border-bottom: 2px solid var(--error-green);
}

.mark-error.purple {
  color: var(--error-purple);
  background-color: var(--error-purple-bg);
  border-bottom: 2px solid var(--error-purple);
}

.mark-error:hover {
  filter: brightness(0.95);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Correction Card List */
.cards-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 20px;
}

.correction-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
  background-color: var(--bg-surface);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.correction-card:hover {
  border-color: var(--brand-accent);
  box-shadow: var(--shadow-sm);
}

.correction-card.red { border-left: 4px solid var(--error-red); }
.correction-card.blue { border-left: 4px solid var(--error-blue); }
.correction-card.green { border-left: 4px solid var(--error-green); }
.correction-card.purple { border-left: 4px solid var(--error-purple); }

.card-top-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.error-tag {
  font-size: 0.75rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}

.error-tag.red { color: var(--error-red); background: var(--error-red-bg); }
.error-tag.blue { color: var(--error-blue); background: var(--error-blue-bg); }
.error-tag.green { color: var(--error-green); background: var(--error-green-bg); }
.error-tag.purple { color: var(--error-purple); background: var(--error-purple-bg); }

.comparison-box {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1rem;
  margin-bottom: 10px;
}

.original-word {
  text-decoration: line-through;
  color: var(--text-subtle);
  font-weight: 600;
}

.arrow-icon {
  color: var(--text-subtle);
  font-size: 0.9rem;
}

.suggested-word {
  font-weight: 800;
  color: var(--brand-accent);
  background-color: var(--brand-subtle);
  padding: 2px 8px;
  border-radius: 4px;
}

.card-explanation {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  background-color: var(--bg-primary);
  padding: 10px 12px;
  border-radius: 6px;
  margin-bottom: 12px;
}

.card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.btn-apply {
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #ffffff;
  background-color: var(--brand-accent);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.btn-apply:hover {
  background-color: var(--brand-hover);
}

.btn-ignore {
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-subtle);
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
}

.btn-ignore:hover {
  color: var(--text-main);
  background-color: var(--bg-subtle);
}

/* Placeholder Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 380px;
  color: var(--text-subtle);
  text-align: center;
  gap: 12px;
}

.empty-icon {
  font-size: 3rem;
  opacity: 0.6;
}

.empty-text {
  font-size: 0.95rem;
  font-weight: 500;
}

/* ==========================================================================
   Modals & Drawers
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background-color: var(--bg-surface);
  border-radius: var(--radius-md);
  width: 90%;
  max-width: 540px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.modal-title {
  font-size: 1.15rem;
  font-weight: 800;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-subtle);
  cursor: pointer;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dict-input-wrap {
  display: flex;
  gap: 8px;
}

.input-text {
  flex: 1;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-primary);
  color: var(--text-main);
  outline: none;
}

.dict-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
  padding: 8px;
  background-color: var(--bg-primary);
  border-radius: var(--radius-sm);
}

.dict-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background-color: var(--brand-subtle);
  color: var(--brand-accent);
  font-weight: 700;
  font-size: 0.85rem;
  border-radius: 16px;
}

.dict-remove {
  cursor: pointer;
  font-weight: 900;
  opacity: 0.7;
}

.dict-remove:hover { opacity: 1; }

/* Engine Status Indicator */
.engine-status {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-subtle);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  white-space: nowrap;
}

/* Korean Dictionary Result Panel */
.ko-dict-result {
  max-height: 340px;
  overflow-y: auto;
  padding: 4px 2px;
}

.ko-dict-empty {
  color: var(--text-subtle);
  font-size: 0.9rem;
  text-align: center;
  padding: 24px 0;
}

.ko-dict-entry {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ko-dict-word-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.ko-dict-word {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-main);
}

.ko-dict-hanja, .ko-dict-pron {
  font-size: 0.9rem;
  color: var(--text-subtle);
  font-weight: 500;
}

.ko-dict-defs {
  list-style: none;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ko-dict-defs li {
  display: flex;
  gap: 8px;
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.5;
  background-color: var(--bg-primary);
  padding: 10px 12px;
  border-radius: 8px;
}

.ko-dict-defs .def-index {
  font-weight: 800;
  color: var(--brand-accent);
  flex-shrink: 0;
}

/* 국립국어원 오픈 API 이용약관상 출처 표기가 필요합니다. */
.ko-dict-source {
  margin-top: 12px;
  font-size: 0.75rem;
  color: var(--text-subtle);
  text-align: right;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  background-color: var(--brand-primary);
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ==========================================================================
   SEO 콘텐츠 영역 & 푸터
   도구 UI 아래에 놓이는 읽을거리 영역입니다. 검색엔진 색인과 애드센스 심사
   양쪽에 필요하며, 방문자의 체류 시간을 늘려 광고 수익에도 직접 기여합니다.
   ========================================================================== */
.seo-content {
  max-width: 860px;
  width: 100%;
  margin: 40px auto 0;
  padding: 0 4px 20px;
  color: var(--text-muted);
  line-height: 1.75;
  font-size: 0.95rem;
}

.seo-content h2 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.4px;
  margin: 44px 0 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border-color);
}

.seo-content h2:first-child {
  margin-top: 0;
}

.seo-content h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 6px;
}

.seo-content p {
  margin: 0 0 14px;
}

.seo-content strong {
  color: var(--text-main);
  font-weight: 700;
}

/* 기능 소개 카드 */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 8px;
}

.feature-item {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md, 12px);
  padding: 18px;
}

.feature-item p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.65;
}

/* 자주 틀리는 맞춤법 목록 */
.rule-list {
  margin: 0;
}

.rule-list dt {
  font-weight: 800;
  color: var(--brand-accent);
  font-size: 1rem;
  margin-top: 20px;
}

.rule-list dt:first-of-type {
  margin-top: 4px;
}

.rule-list dd {
  margin: 6px 0 0;
  padding-left: 14px;
  border-left: 3px solid var(--border-color);
  font-size: 0.92rem;
}

/* FAQ 아코디언 */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.faq-list details {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm, 8px);
  padding: 14px 18px;
  transition: border-color var(--transition-fast, 0.15s);
}

.faq-list details[open] {
  border-color: var(--brand-accent);
}

.faq-list summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--text-main);
  font-size: 0.95rem;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.faq-list summary::-webkit-details-marker {
  display: none;
}

.faq-list summary::after {
  content: "+";
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--brand-accent);
  flex-shrink: 0;
  transition: transform var(--transition-fast, 0.15s);
}

.faq-list details[open] summary::after {
  content: "\2212";
}

.faq-list details p {
  margin: 12px 0 0;
  font-size: 0.9rem;
  line-height: 1.7;
}

/* 사이트 푸터 */
.site-footer {
  margin-top: 48px;
  padding: 32px 24px;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
}

.footer-inner {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.footer-brand strong {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-main);
}

.footer-brand span {
  font-size: 0.8rem;
  color: var(--text-subtle);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 20px;
}

.footer-links a {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition-fast, 0.15s);
}

.footer-links a:hover {
  color: var(--brand-accent);
  text-decoration: underline;
}

.footer-note {
  font-size: 0.78rem;
  color: var(--text-subtle);
  line-height: 1.7;
  margin: 0;
}

/* 정책/소개 등 글 위주 페이지 (about, privacy, terms, contact) */
.doc-page {
  max-width: 780px;
  width: 100%;
  margin: 32px auto;
  padding: 36px 32px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md, 12px);
  color: var(--text-muted);
  line-height: 1.8;
  font-size: 0.95rem;
}

.doc-page h1 {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.6px;
  margin: 0 0 8px;
}

.doc-page .doc-updated {
  font-size: 0.82rem;
  color: var(--text-subtle);
  margin: 0 0 28px;
}

.doc-page h2 {
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 32px 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.doc-page p {
  margin: 0 0 14px;
}

.doc-page ul,
.doc-page ol {
  margin: 0 0 14px;
  padding-left: 22px;
}

.doc-page li {
  margin-bottom: 7px;
}

.doc-page strong {
  color: var(--text-main);
}

.doc-page a {
  color: var(--brand-accent);
}

.doc-page .doc-callout {
  background-color: var(--bg-subtle);
  border-left: 3px solid var(--brand-accent);
  border-radius: 6px;
  padding: 14px 16px;
  margin: 0 0 20px;
  font-size: 0.9rem;
}

/* ==========================================================================
   모바일 대응
   ==========================================================================
   휴대폰에서 화면이 잘려 보이던 원인은 헤더였습니다.
   .header-container 와 .header-actions 가 flex 인데 flex-wrap 이 없어서,
   오른쪽 버튼 5개(상태표시 + 국어사전 + 사용자 사전 + 파일 불러오기 + 테마)가
   한 줄에 억지로 늘어섰습니다. 그 줄의 너비(700px 이상)가 페이지 전체 너비를
   밀어내면서, 390px 화면에서는 오른쪽이 화면 밖으로 나가 잘려 보였습니다.

   가로 스크롤은 모바일에서 "고장난 사이트"로 보이므로, 아래에서
   (1) 넘칠 수 있는 flex 줄을 전부 접히게 하고
   (2) html/body 에 가로 넘침 차단을 걸어 재발을 막습니다.
   ========================================================================== */

/* 어떤 요소가 삐져나와도 페이지 자체가 옆으로 밀리지 않도록 하는 안전장치 */
html,
body {
  overflow-x: hidden;
  max-width: 100%;
}

img {
  max-width: 100%;
  height: auto;
}

@media (max-width: 768px) {
  .seo-content {
    padding: 0 16px 20px;
  }
  .doc-page {
    margin: 16px;
    padding: 24px 20px;
  }

  /* --- 헤더: 두 줄로 접기 --- */
  .app-header {
    padding: 10px 14px;
  }
  .header-container {
    flex-wrap: wrap;
    gap: 10px;
  }
  .header-brand {
    gap: 10px;
  }
  .brand-logo {
    height: 36px;
  }
  .brand-name {
    font-size: 1rem;
  }
  .header-actions {
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }
  .header-actions .btn-icon-text {
    flex: 1 1 auto;
    justify-content: center;
    font-size: 0.8rem;
    padding: 8px 10px;
  }

  /* 검사 엔진 상태는 개발용 표시라 좁은 화면에서는 자리만 차지합니다. */
  .engine-status {
    display: none;
  }

  /* --- 본문 --- */
  .main-container {
    margin: 14px auto;
    padding: 0 12px;
    gap: 14px;
  }

  /* --- 상단 툴바: 세로로 쌓기 --- */
  .control-toolbar {
    padding: 12px;
    gap: 10px;
  }
  .toolbar-left,
  .toolbar-right {
    flex-wrap: wrap;
    width: 100%;
    gap: 8px;
  }
  .toolbar-right .btn-primary,
  .toolbar-right .btn-secondary {
    flex: 1 1 auto;
    justify-content: center;
  }
  .tone-selector-wrap {
    flex-wrap: wrap;
  }
  .tone-select {
    max-width: 100%;
  }

  /* --- 작업 영역 ---
     데스크톱의 min-height 680px 를 그대로 두면 원문·결과 두 패널이
     세로로 쌓이면서 화면이 1400px 넘게 길어집니다. */
  .workspace-grid {
    gap: 14px;
    min-height: 0;
  }
  .card-panel {
    min-height: 0;
  }
  .editor-textarea {
    min-height: 220px;
    font-size: 16px; /* iOS 는 16px 미만 입력창에 자동 확대가 걸립니다 */
  }

  /* --- 글자 수 통계: 줄바꿈 허용 --- */
  .text-stats {
    flex-wrap: wrap;
    gap: 8px 14px;
  }
  .stat-item {
    font-size: 0.75rem;
  }
  .error-summary-bar {
    flex-wrap: wrap;
  }

  /* --- 모달: 화면 밖으로 나가지 않게 --- */
  .modal-card {
    width: calc(100% - 24px);
    max-width: none;
    margin: 0 12px;
    max-height: 85vh;
  }
  .modal-body {
    overflow-y: auto;
  }

  /* --- 푸터 --- */
  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    text-align: left;
  }
  .footer-links {
    flex-wrap: wrap;
    gap: 10px 16px;
  }

  /* --- 안내 배너 --- */
  .setup-banner {
    padding: 12px 14px;
    font-size: 0.82rem;
  }
}

/* 아주 좁은 화면(iPhone SE 등 375px 이하) */
@media (max-width: 400px) {
  .brand-badge {
    display: none; /* 로고 옆 부제까지 넣으면 제목이 두 줄로 깨집니다 */
  }
  .header-actions .btn-icon-text {
    font-size: 0.75rem;
    padding: 7px 8px;
  }
  .mode-select-group {
    width: 100%;
  }
  .mode-btn {
    flex: 1;
  }
}

/* ==========================================================================
   실행 방법 안내 배너
   index.html을 직접 열어(file://) 서버에 연결되지 않았을 때, 원인을 모른 채
   "기능이 안 된다"고 느끼지 않도록 화면 최상단에 눈에 띄게 안내합니다.
   ========================================================================== */
.setup-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 20px;
  background-color: #fff4e5;
  border-bottom: 1px solid #ffcc80;
  color: #7a4f01;
  font-size: 0.9rem;
  line-height: 1.6;
}

[data-theme="dark"] .setup-banner {
  background-color: #2e2210;
  border-bottom-color: #5c421a;
  color: #ffd08a;
}

.setup-banner-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  line-height: 1.5;
}

.setup-banner-body {
  flex: 1;
  min-width: 0;
}

.setup-banner-body strong {
  font-weight: 800;
}

.setup-banner-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: inherit;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.6;
  padding: 0 4px;
}

.setup-banner-close:hover {
  opacity: 1;
}
