:root {
  --bg: #080d16;
  --surface: #111827;
  --surface-2: #1a2335;
  --border: rgba(100, 255, 218, 0.12);
  --border-soft: rgba(255, 255, 255, 0.08);
  --accent: #64ffda;
  --accent-dim: rgba(100, 255, 218, 0.14);
  --text-primary: #e2eaf5;
  --text-secondary: #8892b0;
  --text-muted: #4a5568;
  --radius: 10px;
  --radius-lg: 16px;
  --font-sans: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-serif: Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }
/* Author styles on .badge etc. can outrank the UA [hidden] rule at equal
   specificity, so the hidden attribute stops hiding things. Force it. */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.topbar h1 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.01em;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.counter {
  font-family: var(--font-sans);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}
.lang-toggle {
  display: flex;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 2px;
}
.btn-lang {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: calc(var(--radius) - 2px);
  color: var(--text-secondary);
  border: 1px solid transparent;
}
.btn-lang:hover { color: var(--text-primary); }
.btn-lang.active {
  background: var(--accent);
  color: #06131f;
  border-color: var(--accent);
}

.nav {
  display: flex;
  gap: 4px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}
.card-head {
  margin-bottom: 16px;
}
.card-head h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--text-primary);
}
.meta {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.5;
}
.meta span + span::before {
  content: " · ";
  color: var(--text-muted);
  margin: 0 2px;
}

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  margin: 0 0 8px;
  vertical-align: middle;
}
.badge-nonfit {
  background: rgba(255, 123, 123, 0.14);
  color: #ff9a9a;
  border: 1px solid rgba(255, 123, 123, 0.3);
}
.badge-kind {
  background: rgba(123, 180, 255, 0.14);
  color: #9ac3ff;
  border: 1px solid rgba(123, 180, 255, 0.3);
  margin-right: 6px;
}

.cv-line {
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 0.875rem;
}
.cv-name {
  color: var(--accent);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.85em;
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.actions-top {
  margin: 0 0 16px;
}

textarea#letter {
  width: 100%;
  min-height: 420px;
  padding: 16px 18px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.97rem;
  line-height: 1.65;
  resize: vertical;
  white-space: pre-wrap;
}
textarea#letter:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* Read-only 이력서 display */
.letter-display {
  width: 100%;
  min-height: 420px;
  padding: 16px 18px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: 'Noto Sans KR', var(--font-sans);
  font-size: 0.95rem;
  line-height: 1.7;
  overflow-y: auto;
}
.letter-display h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text-primary);
}
.letter-display h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 20px 0 8px;
  color: var(--accent);
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 4px;
}
.letter-display h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 16px 0 6px;
  color: var(--text-primary);
}
.letter-display h4 {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 12px 0 6px;
  color: var(--text-secondary);
}
.letter-display p {
  margin: 4px 0;
}
.letter-display ul {
  margin: 4px 0 8px 1.2em;
  padding: 0;
}
.letter-display li {
  margin: 2px 0;
}
.letter-display hr {
  border: none;
  border-top: 1px solid var(--border-soft);
  margin: 16px 0;
}
.letter-display table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 12px;
  font-size: 0.9rem;
}
.letter-display th,
.letter-display td {
  border: 1px solid var(--border-soft);
  padding: 6px 10px;
  vertical-align: top;
  text-align: left;
}
.letter-display th {
  background: var(--surface);
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
}
.letter-display td:first-child {
  white-space: nowrap;
  color: var(--text-secondary);
  width: 30%;
}
.letter-display a {
  color: var(--accent);
  text-decoration: none;
}
.letter-display a:hover { text-decoration: underline; }
.letter-display .md-spacer { height: 6px; }

/* --- Mammoth docx output styles --- */

/* Name / title header block */
.letter-display .cv-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 4px;
}
.letter-display .cv-name-block { flex: 1; }
.letter-display .cv-name {
  font-size: 1.8rem !important;
  font-weight: 700;
  color: #4472c4;
  margin: 0 0 4px !important;
  line-height: 1.2;
}
.letter-display .cv-title {
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin: 0 !important;
  font-weight: 500;
}

/* Personal info table (floated right in header) */
.letter-display .cv-personal table {
  width: auto;
  min-width: 220px;
  font-size: 0.82rem;
  margin: 0;
}
.letter-display .cv-personal td {
  padding: 3px 8px;
}
.letter-display .cv-personal td:first-child {
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
  width: auto;
}

/* Strong-only paragraphs = section dividers */
.letter-display p > strong:only-child {
  display: block;
  font-size: 0.95rem;
  color: var(--accent);
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 3px;
  margin-top: 14px;
}

/* Projects: mammoth emits one <ol> per company so numbering resets at 1 each
   time — hide counters on outer ol entirely */
.letter-display ol {
  list-style: none;
  padding-left: 0;
  margin: 6px 0;
}
.letter-display ol > li { margin: 10px 0 4px; }

/* Company header bold */
.letter-display ol > li > strong { font-size: 0.9rem; }

/* Project title items: nested ol inside company li, or ul>li>ol (mammoth
   artifact for proj1b which falls outside the company li) */
.letter-display ol ol,
.letter-display ul > li > ol {
  list-style: disc;
  padding-left: 1.2em;
  margin: 4px 0;
}
.letter-display ol ol li,
.letter-display ul > li > ol > li {
  font-style: italic;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin: 2px 0 4px;
}
/* ul wrapper around overflow project ol — suppress bullet + reset indent */
.letter-display ul:has(> li > ol) {
  margin-left: 0;
}
.letter-display ul > li:has(> ol) {
  list-style: none;
  padding-left: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 9px 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  text-decoration: none;
  background: transparent;
  color: var(--text-primary);
  line-height: 1;
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn-primary {
  background: var(--accent);
  color: #06131f;
  border-color: var(--accent);
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-outline {
  border-color: var(--border);
  color: var(--accent);
}
.btn-outline:hover {
  background: var(--accent-dim);
}
.btn-ghost {
  color: var(--text-secondary);
}
.btn-ghost:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}
.btn[disabled], .btn[aria-disabled="true"] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.status {
  min-height: 1.2em;
  margin: 10px 0 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
}
.status.ok { color: var(--accent); }
.status.err { color: #ff7b7b; }

.empty, .error {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
}
.empty h2, .error h2 {
  margin: 0 0 10px;
  font-size: 1.3rem;
}
.empty p, .error p {
  color: var(--text-secondary);
  margin: 0 0 16px;
}
.error pre {
  text-align: left;
  background: var(--surface-2);
  padding: 12px;
  border-radius: var(--radius);
  font-size: 0.82rem;
  color: var(--text-secondary);
  overflow-x: auto;
}
code {
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.85em;
}

.footer {
  margin-top: 24px;
  text-align: right;
}
.linklike {
  background: none;
  border: 0;
  color: var(--text-muted);
  font: inherit;
  cursor: pointer;
  padding: 4px 6px;
  font-size: 0.85rem;
}
.linklike:hover { color: var(--text-secondary); }

.letter-print-area {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

@media print {
  @page { margin: 1.5cm 2cm; }
  body { background: #fff; color: #000; }
  .app { display: none !important; }
  .letter-print-area {
    position: static;
    left: auto;
    width: auto;
    height: auto;
    overflow: visible;
    display: block;
    font-family: 'Noto Sans KR', 'Noto Serif CJK KR', sans-serif;
    font-size: 10pt;
    line-height: 1.5;
    color: #000;
    background: #fff;
  }
  .letter-print-area .print-header {
    font-weight: bold;
    font-size: 12pt;
    margin-bottom: 1em;
    border-bottom: 1px solid #000;
    padding-bottom: 0.4em;
    display: none; /* CV has its own name header */
  }
  /* Cover letter plain text */
  .letter-print-area > div:not(.print-cv-body):not(.print-header) {
    white-space: pre-wrap;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 11pt;
  }
  /* Korean 이력서 rendered HTML */
  .letter-print-area .print-cv-body h1 { font-size: 18pt; font-weight: 700; margin: 0 0 4pt; }
  .letter-print-area .print-cv-body h2 { font-size: 11pt; font-weight: 700; margin: 12pt 0 4pt; border-bottom: 1px solid #000; padding-bottom: 2pt; }
  .letter-print-area .print-cv-body h3 { font-size: 10pt; font-weight: 700; margin: 8pt 0 3pt; }
  .letter-print-area .print-cv-body h4 { font-size: 10pt; font-weight: 600; margin: 6pt 0 2pt; }
  .letter-print-area .print-cv-body p { margin: 2pt 0; }
  .letter-print-area .print-cv-body ul { margin: 2pt 0 4pt 1.2em; padding: 0; }
  .letter-print-area .print-cv-body li { margin: 1pt 0; }
  .letter-print-area .print-cv-body hr { border: none; border-top: 0.5pt solid #ccc; margin: 8pt 0; }
  .letter-print-area .print-cv-body table { width: 100%; border-collapse: collapse; margin: 4pt 0 8pt; font-size: 9pt; }
  .letter-print-area .print-cv-body th,
  .letter-print-area .print-cv-body td { border: 0.5pt solid #aaa; padding: 4pt 6pt; vertical-align: top; }
  .letter-print-area .print-cv-body th { background: #f2f2f2; font-weight: 600; }
  .letter-print-area .print-cv-body td:first-child { width: 28%; white-space: nowrap; }
  .letter-print-area .print-cv-body a { color: #000; text-decoration: none; }
  .letter-print-area .print-cv-body .md-spacer { height: 3pt; }
}
