  :root {
    --ink:      #0c0d10;
    --panel:    #15171c;
    --panel-2:  #1b1e25;
    --line:     #262a33;
    --text:     #e8e6e1;
    --muted:    #8b8f99;
    --ember:    #f0a23c;
    --ember-dim:#7a5526;
    --radius:   14px;
  }

  * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

  html, body { height: 100%; }

  /* Fixed full-viewport gradient — never repeats or stretches on tall/mobile pages. */
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background: radial-gradient(120% 80% at 50% -10%, #16181e 0%, var(--ink) 55%);
  }

  body {
    margin: 0;
    background: var(--ink);
    color: var(--text);
    font-family: "Space Grotesk", system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    display: flex;
    justify-content: center;
    padding: 56px 22px 80px;
  }

  .card {
    width: 100%;
    max-width: 440px;
  }

  /* --- header / monogram --- */
  .head {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 44px;
  }

  .mono {
    width: 112px;
    height: 112px;
    border-radius: 50%;
    background: var(--panel);
    border: 1px solid var(--line);
    position: relative;
    overflow: hidden;
  }
  .mono img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }
  /* the "live current" ring (sits outside the clipped photo) */
  .avatar { position: relative; width: 112px; height: 112px; }
  .avatar::after {
    content: "";
    position: absolute;
    inset: -5px;
    border-radius: 50%;
    border: 1px solid transparent;
    border-top-color: var(--ember);
    animation: spin 4.5s linear infinite;
    pointer-events: none;
  }

  h1 {
    font-size: 23px;
    font-weight: 500;
    margin: 20px 0 6px;
    letter-spacing: -0.01em;
  }

  .tag {
    font-family: "JetBrains Mono", monospace;
    font-size: 12px;
    color: var(--muted);
    letter-spacing: 0.02em;
    line-height: 1.5;
  }
  .tag .dot { color: var(--ember); }

  .bio {
    max-width: 320px;
    margin: 16px auto 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    opacity: .85;
  }

  /* --- links --- */
  .links { display: flex; flex-direction: column; gap: 11px; }

  .link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    overflow: hidden;
    transition: transform .18s ease, border-color .18s ease, background .18s ease;
  }
  /* charging bar on the left edge */
  .link::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--ember);
    transform: scaleY(0);
    transform-origin: bottom;
    transition: transform .2s ease;
  }
  .link:hover, .link:focus-visible {
    transform: translateY(-2px);
    border-color: var(--ember-dim);
    background: var(--panel-2);
    outline: none;
  }
  .link:hover::before, .link:focus-visible::before { transform: scaleY(1); }

  .ic {
    flex: 0 0 20px;
    width: 20px; height: 20px;
    color: var(--muted);
    transition: color .18s ease;
  }
  .link:hover .ic, .link:focus-visible .ic { color: var(--ember); }

  .label { flex: 1; font-size: 15px; font-weight: 500; }

  .meta {
    font-family: "JetBrains Mono", monospace;
    font-size: 11px;
    color: var(--muted);
  }

  .arrow {
    flex: 0 0 16px;
    color: var(--muted);
    transform: translateX(-2px);
    opacity: 0;
    transition: opacity .18s ease, transform .18s ease;
  }
  .link:hover .arrow, .link:focus-visible .arrow {
    opacity: 1;
    transform: translateX(0);
  }

  footer {
    margin-top: 40px;
    text-align: center;
    font-family: "JetBrains Mono", monospace;
    font-size: 11px;
    color: var(--muted);
  }
  footer a { color: var(--muted); text-decoration: none; border-bottom: 1px dotted var(--line); }
  footer a:hover { color: var(--ember); }

  /* --- timeline --- */
  .tl-head {
    font-family: "JetBrains Mono", monospace;
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 40px 0 18px;
    padding-left: 2px;
  }
  .tl {
    position: relative;
    margin: 0;
    padding: 0 0 0 24px;
    list-style: none;
  }
  .tl::before {
    content: "";
    position: absolute;
    left: 4px; top: 6px; bottom: 6px;
    width: 1px;
    background: var(--line);
  }
  .tl-item { position: relative; padding: 0 0 22px; }
  .tl-item:last-child { padding-bottom: 0; }
  .tl-item::before {
    content: "";
    position: absolute;
    left: -23px; top: 5px;
    width: 9px; height: 9px;
    border-radius: 50%;
    background: var(--panel);
    border: 1px solid var(--muted);
  }
  .tl-item.now::before {
    background: var(--ember);
    border-color: var(--ember);
    animation: pulse 2.2s ease-out infinite;
  }
  .tl-role { font-size: 14px; font-weight: 500; }
  .tl-co   { font-size: 13px; color: var(--text); opacity: .8; margin-top: 1px; }
  .tl-date {
    font-family: "JetBrains Mono", monospace;
    font-size: 11px;
    color: var(--muted);
    margin-top: 4px;
  }

  @keyframes spin { to { transform: rotate(360deg); } }

  @keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(240,162,60,0.5); }
    70%  { box-shadow: 0 0 0 8px rgba(240,162,60,0); }
    100% { box-shadow: 0 0 0 0 rgba(240,162,60,0); }
  }

  @media (prefers-reduced-motion: reduce) {
    .avatar::after, .tl-item.now::before, .chat-panel { animation: none; }
    .tl-item.now::before { box-shadow: 0 0 0 4px rgba(240,162,60,0.12); }
    .link, .arrow, .ic, .link::before { transition: none; }
    .chat-msg.thinking .dots span { animation: none; opacity: 1; }
  }
  /* ===== language toggle ===== */
  .lang-toggle {
    position: fixed; top: 18px; right: 18px; z-index: 60;
    display: flex; align-items: center; gap: 8px;
    background: none; border: none; cursor: pointer; padding: 4px;
    font-family: "JetBrains Mono", monospace;
  }
  .lang-lbl { font-size: 11px; font-weight: 500; color: var(--muted); transition: color .15s ease; letter-spacing: .04em; }
  .lang-toggle[data-lang="sv"] .lbl-sv,
  .lang-toggle[data-lang="en"] .lbl-en { color: var(--ember); }
  .lang-pill {
    position: relative; width: 46px; height: 24px; border-radius: 12px;
    background: var(--panel-2); border: 1px solid var(--line);
    overflow: hidden; display: block; flex: 0 0 auto;
  }
  /* flag inset from the pill edge → a thin frame for depth */
  .lang-flag {
    position: absolute; inset: 2px; border-radius: 8px; overflow: hidden;
    opacity: 0; transition: opacity .2s ease;
    box-shadow: inset 0 1px 3px rgba(0,0,0,.55);
  }
  .lang-flag svg { display: block; width: 100%; height: 100%; }
  .lang-toggle[data-lang="sv"] .flag-sv,
  .lang-toggle[data-lang="en"] .flag-en { opacity: 1; }
  .lang-knob {
    position: absolute; top: 3px; left: 4px; width: 16px; height: 16px; z-index: 1;
    border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.55);
    transition: left .2s ease;
  }
  .lang-toggle[data-lang="en"] .lang-knob { left: 24px; }
  .lang-toggle:focus-visible { outline: 2px solid var(--ember); outline-offset: 3px; border-radius: 8px; }

  /* Turnstile page-load check (bottom-left, hidden once verified) */
  .ts-check { position: fixed; left: 14px; bottom: 14px; z-index: 55; }
  .ts-check[hidden] { display: none; }

  /* ===== floating chat widget ===== */
  .chat-fab {
    position: fixed; right: 22px; bottom: 22px; z-index: 60;
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--ember); color: #1a1206; border: none; cursor: pointer;
    display: grid; place-items: center;
    box-shadow: 0 8px 24px rgba(0,0,0,.45);
    transition: transform .18s ease, box-shadow .18s ease;
  }
  .chat-fab:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(0,0,0,.55); }
  .chat-fab:focus-visible { outline: 2px solid var(--ember); outline-offset: 3px; }
  .chat-fab svg { width: 26px; height: 26px; }

  .chat-panel {
    position: fixed; right: 22px; bottom: 90px; z-index: 60;
    width: min(380px, calc(100vw - 32px));
    height: min(560px, calc(100vh - 130px));
    display: flex; flex-direction: column;
    background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
    box-shadow: 0 18px 50px rgba(0,0,0,.6);
    overflow: hidden; animation: chatIn .18s ease;
  }
  .chat-panel[hidden] { display: none; }
  @keyframes chatIn { from { opacity:0; transform: translateY(10px) scale(.98); } to { opacity:1; transform:none; } }

  .chat-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
  .chat-head strong { font-size: 14px; font-weight: 500; display: block; }
  .chat-head span { font-family: "JetBrains Mono", monospace; font-size: 11px; color: var(--muted); }
  .chat-close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 17px; line-height: 1; padding: 4px; border-radius: 6px; }
  .chat-close:hover { color: var(--text); }

  .chat-log { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 14px; }
  .chat-msg { padding: 10px 13px; border-radius: 12px; border: 1px solid var(--line); line-height: 1.45; font-size: 14px; white-space: pre-wrap; max-width: 85%; }
  .chat-msg.user { background: var(--panel-2); align-self: flex-end; border-bottom-right-radius: 4px; }
  .chat-msg.bot { background: #101216; align-self: flex-start; border-bottom-left-radius: 4px; }
  .chat-msg.bot.thinking { color: var(--muted); }
  /* "thinking" indicator: three animated ember dots (mobile + web) */
  .chat-msg.thinking .dots { display: inline-flex; align-items: center; gap: 5px; padding: 2px 0; }
  .chat-msg.thinking .dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--ember); animation: dotPulse 1.2s infinite ease-in-out both; }
  .chat-msg.thinking .dots span:nth-child(2) { animation-delay: .18s; }
  .chat-msg.thinking .dots span:nth-child(3) { animation-delay: .36s; }
  @keyframes dotPulse { 0%, 70%, 100% { opacity: .25; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-4px); } }
  .chat-empty { color: var(--muted); font-size: 13px; text-align: center; margin: auto 12px; line-height: 1.5; }

  .chat-gate { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 14px; flex: 0 0 auto; }
  .chat-gate[hidden] { display: none; }
  .chat-gate p { margin: 0; color: var(--muted); font-size: 13px; }

  .chat-composer { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); flex: 0 0 auto; }
  .chat-composer[hidden] { display: none; }
  .chat-composer textarea { flex: 1; resize: none; height: 40px; max-height: 110px; padding: 10px 12px; border-radius: 10px; background: #101216; border: 1px solid var(--line); color: var(--text); font-family: inherit; font-size: 14px; line-height: 1.3; }
  .chat-composer textarea:focus { outline: none; border-color: var(--ember-dim); }
  .chat-composer textarea:disabled { opacity: .5; }
  .chat-send { flex: 0 0 auto; width: 40px; border-radius: 10px; background: var(--ember); color: #1a1206; border: none; cursor: pointer; font-size: 18px; font-weight: 700; }
  .chat-send:disabled { opacity: .4; cursor: not-allowed; }

  .chat-hint { font-family: "JetBrains Mono", monospace; font-size: 11px; color: var(--muted); text-align: center; padding: 0 14px 12px; margin: 0; }
  .chat-hint[hidden] { display: none; }
  .chat-hint.err { color: #e0775c; }

  @media (max-width: 480px) {
    /* Chat goes fullscreen on phones, scaling up from the bubble. */
    .chat-panel {
      inset: 0;
      width: 100%; height: 100%;
      border-radius: 0; border: none;
      transform-origin: bottom right;
      animation: chatInMobile .24s cubic-bezier(.22, .61, .36, 1);
    }
    @keyframes chatInMobile { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: scale(1); } }
    .chat-head { padding-top: calc(14px + env(safe-area-inset-top)); }
    .chat-close { font-size: 24px; padding: 6px 8px; }
    .chat-composer { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
    /* Hide the bubble while the fullscreen panel is open. */
    .chat-fab[aria-expanded="true"] { display: none; }
    .chat-fab { right: 16px; bottom: 16px; }
  }
