/* ── Design tokens ───────────────────────────────────────────────── */
:root {
  --ink:        #0f0f0f;
  --ink-mid:    #444;
  --ink-light:  #888;
  --paper:      #faf9f7;
  --cream:      #f2f0eb;
  --rule:       #e0ddd7;
  --accent:     #1a3a2a;
  --accent-lt:  #e8f0eb;
  --accent-mid: #2d6a4f;
  --gold:       #b08d57;
  --lightgold:  #d7bf9a;
  --red:        #c0392b;
  --red-lt:     #fdecea;
  --radius:     8px;
  --radius-sm:  4px;
  --shadow:     0 1px 4px rgba(0,0,0,.08);
  --shadow-md:  0 4px 16px rgba(0,0,0,.12);
  --mono:       'DM Mono', monospace;
  --serif:      'DM Serif Display', Georgia, serif;
  --sans:       'DM Sans', system-ui, sans-serif;
  --nav-width:  240px;
  --header-h:   56px;
}

/* ── Reset ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

h1 {
  font-family: var(--serif);
  font-size: 26px;
  color: var(--accent);
  margin-bottom: 6px;
  line-height: 1.2;
}
h2 {
  font-family: var(--serif);
  font-size: 20px;
  color: var(--accent);
  margin-bottom: 6px;
  line-height: 1.2;
}


/* ── Shell layout ────────────────────────────────────────────────── */
.shell {
  display: grid;
  grid-template-columns: var(--nav-width) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  min-height: 100vh;
}

/* ── Header ──────────────────────────────────────────────────────── */
.tm-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  padding: 0 24px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 16px;
}
.tm-logo {
  font-family: var(--serif);
  font-size: 20px;
  color: var(--accent);
  text-decoration: none;
}
.tm-logo span { color: var(--gold); }
.tm-header-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

/* hamburger — mobile only */
.tm-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--ink-mid);
  font-size: 20px;
}

/* ── Left nav ────────────────────────────────────────────────────── */
.tm-nav {
  border-right: 1px solid var(--rule);
  background: var(--cream);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  height: calc(100vh - var(--header-h));  /* ← full viewport height minus header */
  position: sticky;                        /* ← stick to viewport */
  top: var(--header-h);                   /* ← start below header */
}
.tm-nav-greeting {
  font-size: 13px;
  color: var(--ink-mid);
  padding: 0 8px 16px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 8px;
}
.tm-nav-greeting strong {
  display: block;
  font-size: 15px;
  color: var(--ink);
  font-weight: 500;
}
.tm-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-mid);
  text-decoration: none;
  font-size: 14px;
  transition: background .12s, color .12s;
  cursor: pointer;
}
.tm-nav-link:hover  { background: var(--rule); color: var(--ink); }
.tm-nav-link.active { background: var(--accent-lt); color: var(--accent); font-weight: 500; }
.tm-nav-link .icon  { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }

.tm-nav-divider { height: 1px; background: var(--rule); margin: 12px 0; }

.tm-nav-status {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--paper);
  border: 1px solid var(--rule);
  margin-top: auto;
}
.tm-nav-status-label {
  font-size: 10px;
  font-family: var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-light);
  margin-bottom: 4px;
}
.tm-nav-status-value {
  font-size: 13px;
  color: var(--ink-mid);
}
.tm-beta-note {
  font-size: 11px;
  color: var(--ink-light);
  line-height: 1.5;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-lt);
  margin-top: 8px;
}

/* ── Main content ────────────────────────────────────────────────── */
.tm-main {
  padding: 32px;
  overflow-y: auto;
  max-width: 860px;
}
.tm-page-title {
  font-family: var(--serif);
  font-size: 36px;
  color: var(--accent);
  margin-bottom: 6px;
}
.tm-page-subtitle {
  font-size: 14px;
  color: var(--ink-light);
  margin-bottom: 28px;
}

/* ── Cards ───────────────────────────────────────────────────────── */
.tm-card {
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.tm-card-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 12px;
}

/* ── Sections (CV editor) ────────────────────────────────────────── */
.section-card {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
  transition: border-color .15s;
}
.section-card:hover { border-color: #bbb; }

.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  background: #fff;
}
.section-header:hover { background: var(--cream); }

.section-source-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.section-type-badge {
  font-size: 10px;
  font-family: var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 20px;
  flex-shrink: 0;
}
.section-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.section-chevron {
  font-size: 12px;
  color: var(--ink-light);
  transition: transform .2s;
  flex-shrink: 0;
}
.section-card.open .section-chevron { transform: rotate(90deg); }

.section-body {
  display: none;
  padding: 0 16px 16px;
  background: #fff;
  border-top: 1px solid var(--rule);
}
.section-card.open .section-body { display: block; }

.section-content-view {
  font-size: 13px;
  color: var(--ink-mid);
  line-height: 1.7;
  white-space: pre-wrap;
  padding: 12px 0;
}
.section-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* ── Source legend ───────────────────────────────────────────────── */
.source-legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 10px 14px;
  background: var(--cream);
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.source-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--ink-mid);
}
.source-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity .15s, transform .1s;
  text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled)  { opacity: .88; }
.btn-outline   { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn-outline:hover:not(:disabled)  { background: var(--accent-lt); }
.btn-ghost     { background: transparent; color: var(--ink-mid); border: 1px solid var(--rule); }
.btn-ghost:hover:not(:disabled)    { background: var(--cream); }
.btn-danger    { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled)   { opacity: .88; }
.btn-sm        { padding: 5px 12px; font-size: 12px; }
.btn-full      { width: 100%; }

/* ── Forms ───────────────────────────────────────────────────────── */
.tm-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-mid);
  margin-bottom: 5px;
  letter-spacing: .02em;
}
.tm-input, .tm-textarea, .tm-select {
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  background: var(--paper);
  outline: none;
  transition: border-color .15s;
}
.tm-input:focus, .tm-textarea:focus, .tm-select:focus { border-color: var(--accent); }
.tm-textarea { resize: vertical; min-height: 120px; line-height: 1.6; }
.tm-char-count { font-size: 11px; color: var(--ink-light); text-align: right; margin-top: 3px; }
.tm-char-count.warn { color: var(--red); }
.tm-field { margin-bottom: 16px; }

/* ── Visibility pills ────────────────────────────────────────────── */
.visibility-group { display: flex; gap: 8px; flex-wrap: wrap; }
.visibility-pill {
  padding: 7px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--rule);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
  background: var(--paper);
  color: var(--ink-mid);
}
.visibility-pill:hover { border-color: var(--accent); color: var(--accent); }
.visibility-pill.selected { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Upload zone ─────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--rule);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  color: var(--ink-light);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-lt);
  color: var(--accent);
}
.upload-zone input { display: none; }
.upload-icon { font-size: 32px; margin-bottom: 8px; }
.upload-hint { font-size: 12px; margin-top: 6px; color: var(--ink-light); }

/* ── Wizard breadcrumbs ──────────────────────────────────────────── */
.wizard-steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 36px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.wizard-step {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.wizard-step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  border: 2px solid var(--rule);
  color: var(--ink-light);
  background: var(--paper);
  transition: all .2s;
}
.wizard-step.done   .wizard-step-num { background: var(--accent); border-color: var(--accent); color: #fff; }
.wizard-step.active .wizard-step-num { border-color: var(--accent); color: var(--accent); background: var(--accent-lt); }
.wizard-step-label {
  font-size: 13px;
  color: var(--ink-light);
  transition: color .2s;
}
.wizard-step.done   .wizard-step-label { color: var(--accent); }
.wizard-step.active .wizard-step-label { color: var(--ink); font-weight: 500; }
.wizard-step-connector {
  width: 32px;
  height: 2px;
  background: var(--rule);
  margin: 0 4px;
  flex-shrink: 0;
}
.wizard-step.done + .wizard-step-connector { background: var(--accent); }

/* ── Toast ───────────────────────────────────────────────────────── */
.tm-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #fff;
  background: var(--ink);
  box-shadow: var(--shadow-md);
  z-index: 999;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  max-width: 320px;
}
.tm-toast--show  { opacity: 1; transform: translateY(0); }
.tm-toast--error { background: var(--red); }
.tm-toast--ok    { background: var(--accent-mid); }

/* ── Spinner ─────────────────────────────────────────────────────── */
.tm-spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--rule);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ─────────────────────────────────────────────────── */
.tm-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--ink-light);
}
.tm-empty-icon { font-size: 40px; margin-bottom: 12px; }
.tm-empty-title { font-size: 16px; font-weight: 500; color: var(--ink-mid); margin-bottom: 6px; }
.tm-empty-body  { font-size: 14px; margin-bottom: 20px; }

/* ── Confirm modal ───────────────────────────────────────────────── */
.tm-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.tm-modal-overlay.open { display: flex; }
.tm-modal {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 28px;
  width: min(420px, 90vw);
  box-shadow: var(--shadow-md);
}
.tm-modal-title { font-size: 17px; font-weight: 500; margin-bottom: 10px; }
.tm-modal-body  { font-size: 14px; color: var(--ink-mid); margin-bottom: 22px; line-height: 1.6; }
.tm-modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ── formatting toolbar ───────────────────────────────────────────────── */

formatting-toolbar {
  display: flex;
  gap: 2px;
  margin-bottom: 8px;
  padding: 8px;
  background: var(--cream);
  border-radius: 4px;
  border: 1px solid var(--rule);
  align-items: center;
}
 
.format-btn {
  padding: 6px 10px;
  background: white;
  border: 1px solid var(--rule);
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  transition: all 0.15s;
}
 
.format-btn:hover {
  background: var(--accent-lt);
  border-color: var(--accent);
  color: var(--accent);
}
 
.format-btn:active {
  transform: scale(0.95);
}
 
.format-divider {
  width: 1px;
  height: 20px;
  background: var(--rule);
  margin: 0 4px;
}

.sidebar-contact {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  margin-top: 8px;
  text-decoration: underline;
  color: var(--color-text-secondary); /* or whatever your muted link colour is */
}

/* ── Mobile ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-h) 1fr;
  }
  .tm-hamburger { display: block; }
  .tm-nav {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: var(--nav-width);
    z-index: 100;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: var(--shadow-md);
  }
  .tm-nav.open { transform: translateX(0); }
  .tm-nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    top: var(--header-h);
    background: rgba(0,0,0,.3);
    z-index: 99;
  }
  .tm-nav-backdrop.open { display: block; }
  .tm-main { padding: 20px 16px; }
  .wizard-steps { gap: 0; }
  .wizard-step-label { display: none; }
}