  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  :root {
    --teal: #0ea5e9; --teal-hover: #0284c7; --teal-light: #e0f2fe; --teal-muted: rgba(14,165,233,.1);
    --bg: #f8fafc; --bg-2: #ffffff;
    --text: #0f172a; --muted: #64748b; --border: #e2e8f0;
    --green: #10b981; --amber: #d97706; --orange: #d97706; --red: #ef4444; --purple: #8b5cf6;
    --indigo: #6366f1;
    --shadow: 0 1px 4px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 20px rgba(0,0,0,.10);
    --radius: 12px; --sidebar-w: 230px;
  }
  body { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
         background: var(--bg); color: var(--text); min-height: 100vh; display: flex; }

  /* Sidebar */
  #sidebar { width: var(--sidebar-w); min-height: 100vh;
             background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
             display: flex; flex-direction: column;
             position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; }
  .sb-brand { padding: 24px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
  .sb-logo { font-size: 1.5rem; font-weight: 800; color: var(--teal); letter-spacing: -1px; }
  .sb-tagline { font-size: .68rem; color: rgba(255,255,255,.4); font-weight: 500; margin-top: 2px; letter-spacing: .3px; }
  .sb-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; }
  .sb-tab { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px;
            border: none; border-radius: 8px; font-size: .875rem; font-weight: 500;
            color: rgba(255,255,255,.55); background: transparent; cursor: pointer;
            transition: background .15s, color .15s; text-align: left; font-family: inherit; }
  .sb-tab:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.9); }
  .sb-tab.active { background: rgba(14,165,233,.2); color: var(--teal); font-weight: 600; }
  .sb-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
  .sb-bottom { padding: 16px 12px; border-top: 1px solid rgba(255,255,255,.08); }
  .sb-ctx { font-size: .73rem; color: rgba(255,255,255,.35); padding: 4px 12px 10px;
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* Main content */
  #content { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; }
  main { max-width: 760px; width: 100%; margin: 0 auto; padding: 32px 24px 80px; }

  /* Step progress: horizontal-with-labels on narrow, vertical rail on wide */
  #prog { display: flex; align-items: center; gap: 6px; margin-bottom: 28px; flex-wrap: wrap; }
  .pb-row { display: flex; align-items: center; gap: 8px; flex-shrink: 0; padding: 4px 6px; border-radius: 6px; transition: background .15s; }
  .pb-row.done:hover { background: var(--teal-muted); }
  .pb-row.done:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
  .pb-label { font-size: .78rem; color: var(--muted); font-weight: 600; transition: color .25s; white-space: nowrap; }
  .pb-row.done .pb-label { color: var(--text); }
  .pb-row.active .pb-label { color: var(--teal-hover); font-weight: 700; }
  .pb { width: 28px; height: 28px; border-radius: 50%; font-size: .72rem; font-weight: 700;
        display: flex; align-items: center; justify-content: center;
        background: var(--border); color: var(--muted); transition: all .25s; flex-shrink: 0; }
  .pb.done { background: var(--teal); color: #fff; }
  .pb.active { background: var(--teal); color: #fff; box-shadow: 0 0 0 4px var(--teal-muted); }
  .pb-line { flex: 1; height: 2px; min-width: 16px; background: var(--border); border-radius: 1px; transition: background .25s; }
  .pb-line.done { background: var(--teal); }

  /* Wide screens: stepper becomes a sticky vertical rail to the left of main */
  @media (min-width: 1280px) {
    main { padding-left: 232px; max-width: 1000px; position: relative; }
    #prog {
      flex-direction: column;
      align-items: flex-start;
      gap: 0;
      position: absolute;
      left: 24px;
      top: 32px;
      width: 192px;
      margin-bottom: 0;
      flex-wrap: nowrap;
    }
    #prog .pb-row { width: 100%; }
    #prog .pb-line { width: 2px; height: 22px; min-width: 0; flex: none; margin-left: 13px; }
  }

  /* Very narrow screens: hide labels, keep the dots */
  @media (max-width: 600px) {
    .pb-label { display: none; }
  }

  /* Cards */
  .card { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius);
          padding: 22px 24px; margin-bottom: 16px; box-shadow: var(--shadow);
          transition: box-shadow .15s; }
  .card:hover { box-shadow: var(--shadow-md); }

  .slabel { font-size: .68rem; font-weight: 700; text-transform: uppercase;
            letter-spacing: 1.2px; color: var(--teal-hover); margin-bottom: 6px; }
  .stitle { font-size: 1.25rem; font-weight: 700; color: var(--text); margin-bottom: 4px; letter-spacing: -.3px; }
  .ssub { font-size: .875rem; color: var(--muted); margin-bottom: 22px; line-height: 1.5; }

  .section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
  .section-title { font-size: .72rem; font-weight: 700; text-transform: uppercase;
                   letter-spacing: .9px; color: var(--text); }
  hr.divider { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

  /* Forms */
  textarea { width: 100%; border: 1.5px solid var(--border); border-radius: 10px;
             padding: 12px 14px; font-size: .875rem; font-family: inherit;
             color: var(--text); background: #fff; resize: vertical; outline: none;
             transition: border-color .2s, box-shadow .2s; line-height: 1.6; }
  textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-muted); }

  .preview { background: var(--bg-2); border: 1.5px solid var(--border); border-radius: 10px;
             padding: 16px 18px; font-size: .8rem; font-family: 'Consolas','Courier New',monospace;
             white-space: pre-wrap; word-break: break-word; line-height: 1.7;
             max-height: 380px; overflow-y: auto; color: var(--text); }

  /* Markdown-rendered preview — used for LLM output like match/pointers.
     Overrides the monospace/pre-wrap defaults so lists, paragraphs, and
     emphasis render readably instead of as raw asterisks. */
  .preview.preview-md { font-family: inherit; font-size: .88rem; white-space: normal; line-height: 1.55; }
  .preview-md p { margin: 0 0 10px; }
  .preview-md p:last-child { margin-bottom: 0; }
  .preview-md ul, .preview-md ol { margin: 4px 0 10px; padding-left: 22px; }
  .preview-md ul:last-child, .preview-md ol:last-child { margin-bottom: 0; }
  .preview-md li { margin: 3px 0; }
  .preview-md li + li { margin-top: 4px; }
  .preview-md strong { font-weight: 700; color: var(--text); }
  .preview-md em { font-style: italic; }
  .preview-md code { background: rgba(0,0,0,.06); padding: 1px 6px; border-radius: 4px; font-size: .85em;
                     font-family: 'Consolas','Courier New',monospace; }
  .preview-md h3, .preview-md h4, .preview-md h5 {
    margin: 0 0 8px; font-size: .95rem; font-weight: 700; color: var(--text);
  }
  .preview-md h3:not(:first-child), .preview-md h4:not(:first-child), .preview-md h5:not(:first-child) {
    margin-top: 14px;
  }

  /* Accordion section using native <details>/<summary>. Used on the
     Analysis screen to collapse the noisier deep-dive sections so the
     user sees the fit-summary hero first and opens detail only on demand. */
  .acc-section { margin-bottom: 10px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
  .acc-head { padding: 11px 14px; cursor: pointer; display: flex; align-items: center; gap: 8px;
              font-size: .84rem; font-weight: 700; color: var(--text); list-style: none;
              background: var(--bg-2); user-select: none; }
  .acc-head::-webkit-details-marker { display: none; } /* Chrome/Safari */
  .acc-head:hover { background: rgba(0,0,0,.04); }
  .acc-caret { display: inline-block; transition: transform .15s ease; color: var(--muted); font-size: .85rem; }
  details[open] > .acc-head .acc-caret { transform: rotate(90deg); color: var(--teal); }
  .acc-meta { margin-left: 8px; font-size: .74rem; font-weight: 500; color: var(--muted); text-transform: none; letter-spacing: 0; }
  .acc-body { padding: 14px 16px; }

  /* Buttons - all pill shaped */
  .btn-row { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
  button { padding: 9px 20px; border: none; border-radius: 9999px; font-size: .875rem;
           font-weight: 600; cursor: pointer; transition: all .15s; font-family: inherit; }
  button:active { transform: scale(.97); }
  button:disabled { opacity: .4; cursor: not-allowed; }
  .btn-p { background: var(--teal); color: #fff; }
  .btn-p:hover:not(:disabled) { background: var(--teal-hover); box-shadow: 0 4px 12px rgba(0,209,255,.3); }
  .btn-s { background: var(--green); color: white; }
  .btn-s:hover:not(:disabled) { filter: brightness(1.08); }
  .btn-w { background: white; color: var(--text); border: 1.5px solid var(--border); }
  .btn-w:hover:not(:disabled) { border-color: var(--teal); color: var(--teal-hover); background: var(--teal-light); }
  .btn-g { background: transparent; color: var(--text); border: 1.5px solid var(--border); }
  .btn-g:hover:not(:disabled) { border-color: var(--teal); color: var(--teal-hover); background: var(--teal-muted); }
  .btn-sm { padding: 5px 12px; font-size: .78rem; }

  /* Mode cards */
  .mode-card { flex: 1; border: 2px solid var(--border); border-radius: 12px;
               padding: 16px 18px; cursor: pointer; transition: all .2s; background: #fff; }
  .mode-card:hover { border-color: var(--teal); }
  .mode-card.selected { border-color: var(--teal); background: var(--teal-light); }
  .mode-title { font-size: .9rem; font-weight: 700; color: var(--text); margin-bottom: 5px; }
  .mode-desc { font-size: .78rem; color: var(--muted); line-height: 1.5; }

  /* Profile picker */
  .profile-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; margin-bottom: 20px; }
  .pcard { border: 2px solid var(--border); border-radius: 10px; padding: 14px 16px;
           cursor: pointer; transition: all .2s; }
  .pcard:hover { border-color: var(--teal); background: var(--teal-light); }
  .pcard.selected { border-color: var(--teal); background: var(--teal-light); }
  .pname { font-weight: 700; color: var(--text); font-size: .9rem; }
  .ptag { font-size: .73rem; color: var(--muted); margin-top: 3px; }

  .detect-box { background: var(--teal-light); border-left: 3px solid var(--teal);
                padding: 10px 14px; border-radius: 0 8px 8px 0; margin-bottom: 20px; font-size: .875rem; }

  /* Questions */
  .q-block { margin-bottom: 22px; }
  .q-block label { display: block; font-size: .875rem; font-weight: 600;
                   color: var(--text); margin-bottom: 8px; line-height: 1.45; }
  .qnum { display: inline-flex; align-items: center; justify-content: center;
          background: var(--teal); color: white; border-radius: 50%;
          width: 22px; height: 22px; font-size: .72rem; font-weight: 700;
          margin-right: 8px; flex-shrink: 0; }

  /* File rows */
  .file-row { display: flex; align-items: center; gap: 8px; padding: 10px 14px;
              background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px;
              margin-bottom: 8px; font-size: .84rem; font-family: monospace; color: var(--text); }

  /* Job rec cards */
  .job-rec-card { display:block; padding:12px 16px; border:1.5px solid var(--border);
                  border-radius:10px; margin-bottom:8px; text-decoration:none; color:inherit;
                  transition:border-color .15s,box-shadow .15s; }
  .job-rec-card:hover { border-color:var(--teal); box-shadow:0 2px 12px rgba(0,209,255,.15); }
  .job-rec-title { font-size:.875rem; font-weight:600; color:var(--text); margin-bottom:3px; }
  .job-rec-meta  { font-size:.78rem; color:var(--muted); }
  .job-rec-badge { display:inline-block; font-size:.66rem; font-weight:700; letter-spacing:.5px;
                   text-transform:uppercase; padding:2px 8px; border-radius:9999px; margin-top:6px; }
  .job-rec-badge.reed   { background:var(--teal-light); color:var(--teal-hover); }
  .job-rec-badge.adzuna { background:#fff7ed; color:#c2410c; }

  /* Loading overlay */
  #loading { position: fixed; inset: 0; background: rgba(15,23,42,.6);
             backdrop-filter: blur(3px); display: none; flex-direction: column;
             align-items: center; justify-content: center; z-index: 999; }
  #loading.on { display: flex; }
  .spin { width: 42px; height: 42px; border: 3px solid rgba(255,255,255,.15);
          border-top-color: var(--teal); border-radius: 50%;
          animation: spin .7s linear infinite; margin-bottom: 16px; }
  @keyframes spin { to { transform: rotate(360deg); } }
  #lmsg { color: white; font-size: .9rem; font-weight: 500; letter-spacing: .2px; }

  /* Error */
  #err { background: #fef2f2; border: 1px solid #fecaca; border-radius: 10px;
         padding: 11px 16px; margin-bottom: 18px; font-size: .875rem;
         color: var(--red); display: none; }

  .edit-wrap { display: none; margin-top: 10px; }
  .edit-wrap.open { display: block; }

  /* ATS Review — three-dimension readout */
  #ats-score { background: var(--bg-2); border: 1.5px solid var(--border); border-radius: 10px;
               padding: 14px 16px; margin: 20px 0 4px; display: none; }
  .ats-label { font-size: .72rem; font-weight: 700; text-transform: uppercase;
               letter-spacing: .9px; color: var(--text); margin-bottom: 10px; }
  .ats-row { margin-bottom: 12px; }
  .ats-row:last-of-type { margin-bottom: 6px; }
  .ats-row-head { display: flex; justify-content: space-between; align-items: baseline;
                  margin-bottom: 4px; }
  .ats-row-name { font-size: .82rem; font-weight: 700; color: var(--text); }
  .ats-row-pct  { font-size: .82rem; font-weight: 700; color: var(--teal);
                  font-variant-numeric: tabular-nums; }
  .ats-bar-bg { height: 6px; background: var(--border); border-radius: 3px;
                overflow: hidden; margin-bottom: 4px; }
  .ats-fill   { height: 100%; width: 0%; border-radius: 3px; background: var(--teal);
                transition: width .7s ease, background .3s ease; }
  .ats-row-hint { font-size: .72rem; color: var(--muted); }
  #ats-missing { font-size: .78rem; color: var(--muted); margin-top: 8px;
                 padding-top: 8px; border-top: 1px dashed var(--border); }

  /* Settings */
  .set-section { margin-bottom: 20px; }
  .set-field { width: 100%; padding: 9px 14px; border: 1.5px solid var(--border); border-radius: 9999px;
               font-size: .875rem; font-family: inherit; color: var(--text); background: #fff;
               outline: none; transition: border-color .2s, box-shadow .2s; margin-top: 6px; }
  .set-field:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-muted); }
  .radio-group { display: flex; gap: 20px; margin-top: 10px; flex-wrap: wrap; }
  .radio-group label { display: flex; align-items: center; gap: 7px; cursor: pointer; font-size: .875rem; }
  #settings-msg { display: none; padding: 9px 14px; background: #f0fdf4; border: 1px solid #bbf7d0;
                  border-radius: 8px; font-size: .84rem; color: var(--green); margin-bottom: 16px; }

  /* Tracker */
  .tracker-toolbar { display: flex; align-items: center; justify-content: space-between;
                     flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
  .filter-pills { display: flex; gap: 6px; flex-wrap: wrap; }
  .pill { padding: 5px 14px; border-radius: 9999px; font-size: .78rem; font-weight: 600;
          cursor: pointer; border: 1.5px solid var(--border); background: white; color: var(--muted); transition: all .15s; }
  .pill:hover { border-color: var(--teal); color: var(--teal-hover); }
  .pill.active { background: var(--teal); color: white; border-color: var(--teal); }
  .tracker-stats { font-size: .8rem; color: var(--muted); }
  .tracker-stats strong { color: var(--text); }

  .tracker-table { width: 100%; border-collapse: collapse; font-size: .83rem; }
  .tracker-table th { text-align: left; padding: 9px 12px; font-size: .7rem; font-weight: 700;
                       text-transform: uppercase; letter-spacing: .7px; color: var(--muted);
                       border-bottom: 2px solid var(--border); }
  .tracker-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
  .tracker-table tr:hover td { background: var(--bg-2); }

  .status-sel { padding: 4px 10px; border: 1.5px solid var(--border); border-radius: 9999px;
                font-size: .76rem; font-weight: 600; cursor: pointer; background: white; font-family: inherit; }
  .status-applied   { border-color: var(--teal); color: var(--teal-hover); background: var(--teal-light); }
  .status-interview { border-color: var(--purple); color: var(--purple); background: #f5f3ff; }
  .status-offer     { border-color: var(--green); color: var(--green); background: #f0fdf4; }
  .status-rejected  { border-color: var(--red); color: var(--red); background: #fef2f2; }
  .status-withdrawn { border-color: var(--muted); color: var(--muted); background: var(--bg-2); }
  .status-saved     { border-color: var(--orange); color: var(--orange); background: #fffbeb; }

  .notes-field { width: 100%; min-width: 120px; padding: 3px 8px; border: 1px solid transparent;
                 border-radius: 6px; font-size: .78rem; font-family: inherit; resize: none;
                 background: transparent; color: var(--text); height: 28px; overflow: hidden; }
  .notes-field:focus { border-color: var(--border); background: white; height: 60px; outline: none; }

  .del-btn { padding: 4px 10px; font-size: .75rem; border-radius: 9999px; cursor: pointer;
             border: 1.5px solid #fecaca; background: #fef2f2; color: var(--red); font-weight: 600; }
  .del-btn:hover { background: var(--red); color: white; border-color: var(--red); }

  .import-row { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
  .import-input { flex: 1; padding: 8px 14px; border: 1.5px solid var(--border); border-radius: 9999px;
                  font-size: .875rem; font-family: inherit; outline: none; transition: border-color .2s; }
  .import-input:focus { border-color: var(--teal); }
  .empty-state { text-align: center; padding: 56px 24px; color: var(--muted); }
  .empty-state .big { font-size: 2.8rem; margin-bottom: 10px; }
  .empty-state p { font-size: .875rem; }
  /* Quick-apply sticky bar */
  #quick-apply-bar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 9999;
    background: #0f172a; color: #fff;
    padding: 12px 20px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    box-shadow: 0 -4px 24px rgba(0,0,0,.25);
    transform: translateY(100%); transition: transform .3s cubic-bezier(.22,.68,0,1.2);
  }
  #quick-apply-bar.visible { transform: translateY(0); }
  #quick-apply-bar .qab-title { flex: 1; min-width: 0; }
  #quick-apply-bar .qab-title strong { display: block; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #quick-apply-bar .qab-title span  { font-size: .75rem; color: #94a3b8; }
  #quick-apply-bar .qab-actions { display: flex; gap: 8px; flex-shrink: 0; }
  #quick-apply-bar button { font-size: .8rem; padding: 6px 14px; border-radius: 6px; cursor: pointer; border: none; font-weight: 600; }
  #quick-apply-bar .qab-build { background: var(--teal); color: #000; }
  #quick-apply-bar .qab-build:hover { background: var(--teal-hover); }
  #quick-apply-bar .qab-save  { background: rgba(255,255,255,.12); color: #fff; }
  #quick-apply-bar .qab-save:hover  { background: rgba(255,255,255,.22); }
  #quick-apply-bar .qab-dismiss { background: transparent; color: #94a3b8; font-size: 1rem; padding: 4px 8px; }
  #quick-apply-bar .qab-dismiss:hover { color: #fff; }
  /* Variant picker cards */
  .variant-card { border: 2px solid var(--border); border-radius: 12px; padding: 16px 18px;
                  cursor: pointer; transition: all .2s; background: #fff; }
  .variant-card:hover { border-color: var(--teal); box-shadow: var(--shadow-md); }
  .variant-card.selected { border-color: var(--teal); background: var(--teal-light); }
  .variant-label { font-size: .7rem; font-weight: 700; text-transform: uppercase;
                   letter-spacing: 1px; color: var(--teal-hover); margin-bottom: 6px; }
  .variant-text { font-size: .875rem; color: var(--text); line-height: 1.6; }

  /* ── Mobile layout ── */
  @media (max-width: 640px) {
    :root { --sidebar-w: 0px; }
    body { flex-direction: column; }

    /* Sidebar becomes a horizontal top bar */
    #sidebar { width: 100%; min-height: unset; height: auto; position: fixed;
               top: 0; left: 0; right: 0; bottom: auto; z-index: 200;
               flex-direction: row; align-items: center; justify-content: space-between;
               padding: 0 12px; }
    .sb-brand { padding: 10px 8px; border-bottom: none; border-right: 1px solid rgba(255,255,255,.08); }
    .sb-tagline { display: none; }
    .sb-logo { font-size: 1.2rem; }
    .sb-nav { flex-direction: row; padding: 8px 4px; gap: 4px; flex: 1; overflow-x: auto;
              scrollbar-width: none; }
    .sb-nav::-webkit-scrollbar { display: none; }
    .sb-tab { padding: 7px 10px; font-size: .78rem; white-space: nowrap; border-radius: 6px; }
    .sb-icon { display: none; }
    .sb-bottom { padding: 8px; border-top: none; border-left: 1px solid rgba(255,255,255,.08); }
    .sb-ctx { display: none; }

    /* Push main content below top bar */
    #content { margin-left: 0; padding-top: 54px; }
    main { padding: 16px 12px 80px; }

    /* Quick apply bar full width on mobile */
    #quick-apply-bar { left: 0; right: 0; flex-wrap: wrap; gap: 8px; }
    #quick-apply-bar .qab-actions { flex-wrap: wrap; }
  }
