/* =========================================================
   CVForge — design tokens
   ========================================================= */
:root {
  --bg-base:      #0B0E14;
  --bg-panel:     #12161F;
  --bg-alt:       #171C26;
  --bg-input:     #1A2029;
  --border:       #262D3A;
  --border-soft:  #1E2430;

  --text-primary:   #E7E9ED;
  --text-secondary: #8B93A7;
  --text-dim:       #565F72;

  --accent:      #3ECF8E;
  --accent-dim:  rgba(62, 207, 142, .14);
  --accent-2:    #7C8CF8;
  --accent-2-dim: rgba(124, 140, 248, .14);
  --danger:      #F2617A;
  --danger-dim:  rgba(242, 97, 122, .12);

  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --ease: cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { overflow-x: hidden; }
body {
  margin: 0;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  width: 100%;
}

/* subtle dot-grid texture, purely decorative */
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(var(--border-soft) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 40%, transparent 100%);
  opacity: .6;
}

a { color: inherit; }

::selection { background: var(--accent-dim); color: var(--text-primary); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* =========================================================
   Typography helpers
   ========================================================= */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: .04em;
  color: var(--accent);
  margin: 0 0 .6rem;
}
.step-title { font-size: 1.5rem; font-weight: 700; margin: 0 0 .35rem; letter-spacing: -.01em; }
.step-hint { color: var(--text-secondary); font-size: .9rem; margin: 0 0 1.6rem; }
.step-head-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  margin-bottom: 1rem;
}
.step-head-row .step-title { margin-bottom: .25rem; }
.step-head-row .step-hint { margin-bottom: 0; }

/* =========================================================
   Window chrome (editor-window look)
   ========================================================= */
.window-chrome, .editor-window {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.window-titlebar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}
.window-dots { display: flex; gap: 6px; }
.window-dots .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-r { background: #F2617A; }
.dot-y { background: #F5C15A; }
.dot-g { background: #3ECF8E; }
.window-tab {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
}

/* =========================================================
   App shell / layout
   ========================================================= */
.app-shell {
  position: relative;
  z-index: 1;
  max-width: 980px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.brand { display: flex; align-items: center; gap: .5rem; font-family: var(--font-mono); }
.brand-mark { color: var(--accent); font-size: 1.1rem; }
.brand-path { font-size: .95rem; color: var(--text-primary); font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: .6rem; }

/* =========================================================
   Resumes list page
   ========================================================= */
.directory-body { padding: 1.75rem 2.25rem 2.25rem; }
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.page-head .eyebrow { margin-bottom: .35rem; }
.page-head .step-title { margin: 0; }

.resume-list { display: flex; flex-direction: column; gap: .9rem; }
.resume-card {
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  transition: border-color .18s var(--ease);
}
.resume-card:hover { border-color: var(--border); }
.resume-card-top .eyebrow { margin-bottom: .3rem; }
.resume-title { font-size: 1.05rem; font-weight: 700; margin: 0 0 .3rem; }
.resume-meta { font-size: .8rem; color: var(--text-dim); margin: 0; }
.resume-actions { display: flex; align-items: center; gap: .5rem; flex: none; }
.btn-danger-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--danger);
}
.btn-danger-outline:hover { border-color: var(--danger); background: var(--danger-dim); }
.btn-danger-outline.is-confirming { background: var(--danger); color: #1a0a0d; border-color: var(--danger); }

.editor-body {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-width: 0;
}
.editor-body > * { min-width: 0; }

/* =========================================================
   Pipeline / stepper
   ========================================================= */
.pipeline {
  position: relative;
  padding: 1.75rem 1.25rem;
  border-right: 1px solid var(--border);
  background: var(--bg-alt);
}
.pipeline-rail {
  position: absolute;
  left: 2.05rem;
  top: 2.35rem;
  bottom: 2.35rem;
  width: 2px;
  background: var(--border);
  border-radius: 1px;
}
.pipeline-rail-fill {
  position: absolute;
  top: 0; left: 0; width: 100%;
  height: 0%;
  background: var(--accent);
  border-radius: 1px;
  transition: height .35s var(--ease);
}
.pipeline-list { list-style: none; margin: 0; padding: 0; position: relative; }
.pipeline-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .5rem 0;
  cursor: pointer;
}
.pipeline-item:hover .pipeline-label { color: var(--text-primary); }

.pipeline-node {
  flex: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--bg-panel);
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  transition: all .25s var(--ease);
  position: relative;
  z-index: 1;
}
.pipeline-item.is-completed .pipeline-node {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-base);
}
.pipeline-item.is-active .pipeline-node {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-dim);
}
.pipeline-label {
  font-size: .85rem;
  color: var(--text-secondary);
  transition: color .2s var(--ease);
}
.pipeline-item.is-active .pipeline-label { color: var(--text-primary); font-weight: 600; }

/* =========================================================
   Main panel
   ========================================================= */
.panel { display: flex; flex-direction: column; min-height: 560px; max-height: 78vh; }
.panel-scroll { flex: 1; overflow-y: auto; padding: 2rem 2.25rem 1rem; }
.panel-scroll::-webkit-scrollbar { width: 8px; }
.panel-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.step-panel { display: none; animation: step-in .28s var(--ease); }
.step-panel.active { display: block; }
@keyframes step-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
}
.footer-right { display: flex; align-items: center; gap: 1rem; }
.step-counter { font-family: var(--font-mono); font-size: 12px; color: var(--text-dim); }

.foot-note { text-align: center; color: var(--text-dim); font-size: .8rem; margin-top: 1.25rem; }

/* =========================================================
   Forms
   ========================================================= */
.field { margin-bottom: 1.1rem; }
.field label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: .4rem;
}
.input, select.input, textarea.input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: .6rem .7rem;
  font-family: var(--font-sans);
  font-size: .9rem;
  outline: none;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.input::placeholder { color: var(--text-dim); }
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.input:invalid:not(:placeholder-shown):not(:focus) { border-color: var(--danger); }
textarea.input { resize: vertical; min-height: 5rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.check-row { display: flex; align-items: center; gap: .5rem; padding-top: 1.5rem; }
.check-row input { accent-color: var(--accent); width: 16px; height: 16px; }
.check-row label { margin: 0; font-size: .8rem; color: var(--text-secondary); }

.form-error {
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--danger);
  background: var(--danger-dim);
  border: 1px solid rgba(242,97,122,.3);
  padding: .5rem .7rem;
  border-radius: var(--radius-sm);
  margin: 0 0 .9rem;
}

/* =========================================================
   Photo upload (personal info step)
   ========================================================= */
.photo-upload { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.photo-preview {
  flex: none;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-placeholder { font-size: 1.9rem; color: var(--text-dim); }
.photo-upload-actions { display: flex; flex-direction: column; align-items: flex-start; gap: .5rem; }
.field-hint { font-size: .75rem; color: var(--text-dim); margin: 0; }

/* =========================================================
   Crop modal
   ========================================================= */
.crop-modal { max-width: 420px; }
.crop-modal-body { padding: 1.5rem 1.5rem 1.75rem; }
.crop-stage {
  position: relative;
  width: 100%;
  max-width: 300px;
  aspect-ratio: 1 / 1;
  margin: 0 auto 1.2rem;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-input);
  border: 1px solid var(--border);
  cursor: grab;
  touch-action: none;
}
.crop-stage:active { cursor: grabbing; }
.crop-stage canvas { display: block; width: 100%; height: 100%; }
.crop-controls { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.25rem; }
.crop-controls input[type="range"] { flex: 1; accent-color: var(--accent); }
.crop-zoom-label { font-size: 1rem; }
.crop-actions { display: flex; justify-content: flex-end; gap: .6rem; }

/* =========================================================
   Buttons
   ========================================================= */
.btn {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: .875rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: .6rem 1.1rem;
  cursor: pointer;
  transition: all .18s var(--ease);
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: .4rem .75rem; font-size: .8rem; }

.btn-accent { background: var(--accent); color: #0B1710; }
.btn-accent:hover { background: #34ba7e; }

.btn-accent-2 { background: var(--accent-2); color: #0B0E1F; }
.btn-accent-2:hover { background: #6b7cf2; }
.btn-accent-2:disabled, .btn-accent:disabled { opacity: .6; cursor: wait; }

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--accent-2); color: var(--text-primary); }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text-primary); }
.btn-ghost:disabled { opacity: .35; cursor: not-allowed; }

.btn-remove {
  background: transparent;
  border: none;
  color: var(--danger);
  font-size: .78rem;
  font-family: var(--font-mono);
  cursor: pointer;
  padding: .2rem 0;
}
.btn-remove:hover { color: #ff8a9c; }

.hidden { display: none !important; }

/* =========================================================
   Entry cards (dynamic repeatable items)
   ========================================================= */
.entry-list { display: flex; flex-direction: column; gap: 1rem; }
.entry-card {
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  position: relative;
}
.entry-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .1rem;
}
.entry-index {
  font-family: var(--font-mono);
  font-size: .72rem;
  color: var(--text-dim);
}
.empty-state {
  font-size: .85rem;
  color: var(--text-dim);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
  margin-top: .25rem;
}

/* =========================================================
   Review step
   ========================================================= */
.review-content { display: flex; flex-direction: column; gap: 1rem; }
.review-card {
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
}
.review-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .6rem;
}
.review-card-head h3 {
  font-family: var(--font-mono);
  font-size: .8rem;
  letter-spacing: .03em;
  color: var(--accent);
  margin: 0;
  text-transform: uppercase;
}
.review-edit {
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--accent-2);
  background: none;
  border: none;
  cursor: pointer;
}
.review-edit:hover { text-decoration: underline; }
.review-empty { color: var(--text-dim); font-size: .85rem; }
.review-row { font-size: .88rem; color: var(--text-primary); margin: .15rem 0; }
.review-row span { color: var(--text-secondary); }
.review-item + .review-item { margin-top: .7rem; padding-top: .7rem; border-top: 1px dashed var(--border); }

/* =========================================================
   Auth / crop modal overlay
   ========================================================= */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(6, 8, 12, .72);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  padding: 1rem;
}
.modal { max-width: 420px; width: 100%; }
.modal-body { padding: 1.75rem 1.75rem 2rem; }
.modal-title { font-size: 1.4rem; font-weight: 700; margin: 0 0 .4rem; }
.modal-sub { color: var(--text-secondary); font-size: .85rem; margin: 0 0 1.5rem; }

/* =========================================================
   Toasts
   ========================================================= */
.toast-host {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%);
  z-index: 100; display: flex; flex-direction: column; gap: .5rem; align-items: center;
}
.toast {
  font-family: var(--font-mono);
  font-size: .82rem;
  padding: .65rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-primary);
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  animation: toast-in .22s var(--ease);
}
.toast.toast-success { border-color: var(--accent); color: var(--accent); }
.toast.toast-error { border-color: var(--danger); color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================================
   Responsive — tablets & small laptops
   ========================================================= */
@media (max-width: 900px) {
  .app-shell { padding: 1.75rem 1rem 2rem; }
  .directory-body { padding: 1.5rem 1.25rem 1.75rem; }
}

/* =========================================================
   Responsive — phones & narrow tablets
   ========================================================= */
@media (max-width: 800px) {
  .editor-body { grid-template-columns: 1fr; }
  .pipeline {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.1rem;
  }
  .pipeline-rail { display: none; }
  .pipeline-list { display: flex; gap: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .pipeline-item {
    flex-direction: column;
    gap: .3rem;
    padding: .25rem .6rem;
    flex: none;
  }
  .pipeline-label { display: none; }
  .pipeline-item.is-active .pipeline-node { transform: scale(1.05); }

  .panel { max-height: none; min-height: 0; }
  .panel-scroll { padding: 1.5rem 1.25rem .5rem; max-height: 62vh; }
  .panel-footer { padding: .9rem 1.25rem; flex-wrap: wrap; gap: .6rem; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .step-head-row { flex-direction: column; align-items: stretch; }
  .footer-right { gap: .6rem; flex-wrap: wrap; justify-content: flex-end; }
  .step-counter { display: none; }

  /* Topbar */
  .topbar { flex-wrap: wrap; gap: .6rem; }
  .brand-path { max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-actions { flex-wrap: wrap; gap: .5rem; }

  /* Resumes list page */
  .page-head { flex-direction: column; align-items: stretch; }
  .resume-card { flex-direction: column; align-items: stretch; }
  .resume-actions { justify-content: flex-end; flex-wrap: wrap; }

  /* Modals */
  .modal-body { padding: 1.4rem 1.25rem 1.6rem; }
  .crop-modal { max-width: 100%; }
  .crop-stage { max-width: 100%; }

  .toast-host { left: 1rem; right: 1rem; transform: none; width: auto; }
  .toast { text-align: center; }
}

/* =========================================================
   Responsive — small phones
   ========================================================= */
@media (max-width: 480px) {
  body { font-size: 14px; }
  .app-shell { padding: 1.25rem .75rem 1.75rem; }
  .directory-body { padding: 1.25rem 1rem 1.5rem; }

  .brand-path { max-width: 32vw; }
  .topbar-actions .btn-sm, .footer-right .btn { flex: 1 1 auto; justify-content: center; }
  .topbar-actions { width: 100%; }

  .window-tab { display: none; }

  .step-title { font-size: 1.25rem; }
  .step-hint { margin-bottom: 1.2rem; }

  .panel-scroll { padding: 1.25rem 1rem .5rem; max-height: 58vh; }
  .panel-footer { padding: .8rem 1rem; }
  .panel-footer { flex-direction: column; align-items: stretch; }
  .panel-footer #backBtn { order: 3; }
  .footer-right { width: 100%; justify-content: stretch; }
  .footer-right .btn { flex: 1 1 auto; }

  .photo-upload { flex-direction: column; align-items: flex-start; }

  .resume-card { padding: .9rem 1rem; }
  .resume-actions { width: 100%; }
  .resume-actions .btn { flex: 1 1 auto; justify-content: center; }

  .modal-overlay { padding: .75rem; }
  .modal-title { font-size: 1.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}