/* Self-hosted Outfit and Fraunces (latin). */
@font-face{font-family:"Outfit";font-style:normal;font-weight:400;font-display:swap;src:url("fonts/outfit-latin-400-normal.woff2") format("woff2");}
@font-face{font-family:"Outfit";font-style:normal;font-weight:500;font-display:swap;src:url("fonts/outfit-latin-500-normal.woff2") format("woff2");}
@font-face{font-family:"Outfit";font-style:normal;font-weight:600;font-display:swap;src:url("fonts/outfit-latin-600-normal.woff2") format("woff2");}
@font-face{font-family:"Fraunces";font-style:normal;font-weight:500;font-display:swap;src:url("fonts/fraunces-latin-500-normal.woff2") format("woff2");}
@font-face{font-family:"Fraunces";font-style:normal;font-weight:600;font-display:swap;src:url("fonts/fraunces-latin-600-normal.woff2") format("woff2");}

    :root {
      --sand: #17181b;
      --cream: #edf1ed;
      --paper: #f8faf7;
      --ink: #181a1d;
      --muted: #717873;
      --line: #dde3dd;
      --accent: #dfff6b;
      --accent-ink: #17191b;
      --ok: #25825a;
      --bad: #b33d48;
      --sage: #bdcbc1;
      --shadow: 0 24px 70px rgba(20, 27, 22, .18);
      --ease: cubic-bezier(.2,.8,.2,1);
    }
    * { box-sizing: border-box; }
    html, body { margin: 0; min-height: 100%; }
    body {
      min-height: 100vh; color: var(--ink);
      font-family: Outfit, "Segoe UI", system-ui, sans-serif;
      display: grid; place-items: center; padding: 1rem;
      background:
        radial-gradient(900px 520px at 78% 5%, rgba(223, 255, 107, .18), transparent 56%),
        linear-gradient(145deg, #cbd7cf 0%, var(--sage) 48%, #aabbb0 100%);
    }
    [hidden] { display: none !important; }
    .shell {
      width: min(26rem, 100%);
      background: var(--paper);
      border: 1px solid rgba(255,255,255,.55);
      border-radius: 28px;
      padding: 1.45rem 1.35rem 1.3rem;
      box-shadow: var(--shadow);
      animation: in .4s var(--ease) both;
      transition: width .25s var(--ease);
    }
    .shell.with-hist { width: min(54rem, 100%); }
    @keyframes in {
      from { opacity: 0; transform: translateY(14px) scale(.98); }
      to { opacity: 1; transform: translateY(0) scale(1); }
    }
    .brand {
      display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.85rem;
    }
    .brand-mark {
      width: 44px; height: 44px; border-radius: 14px; flex: 0 0 auto;
      display: grid; place-items: center;
      background: var(--accent); color: var(--accent-ink);
      font-family: Fraunces, Georgia, serif; font-weight: 600; font-size: 1.05rem;
      box-shadow: inset 0 0 0 1px rgba(255,255,255,.45);
    }
    .brand-mark svg {
      width: 22px; height: 22px; stroke: currentColor; fill: none;
      stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
    }
    h1 {
      margin: 0; font-family: Fraunces, Georgia, serif; font-weight: 500;
      font-size: 1.45rem; line-height: 1.15;
    }
    .sub { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.82rem; line-height: 1.4; }
    .who {
      display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
      margin: 0 0 0.9rem; color: var(--muted); font-size: 0.78rem;
    }
    .who strong { color: var(--ink); font-weight: 500; }
    label { display: block; font-size: 0.75rem; color: var(--muted); margin: 0.55rem 0 0.25rem; }
    input {
      width: 100%; background: #fff; border: 1px solid var(--line); color: var(--ink);
      border-radius: 12px; padding: 0.55rem 0.75rem; font: inherit;
      outline: none; transition: border-color .2s ease, box-shadow .2s ease;
    }
    input:focus { border-color: var(--ok); box-shadow: 0 0 0 3px rgba(37,130,90,.13); }
    .screen {
      background: var(--cream); border: 1px solid var(--line); border-radius: 16px;
      padding: 1rem 1.05rem; min-height: 3.4rem; margin: 0.2rem 0 0.85rem;
      font-size: 1.55rem; letter-spacing: 0.06em; word-break: break-all;
      font-variant-numeric: tabular-nums;
    }
    input.screen {
      display: block; width: 100%; color: var(--ink); font: inherit;
      font-size: 1.55rem; letter-spacing: 0.06em; text-align: left;
    }
    input.screen:focus { border-color: var(--ok); box-shadow: 0 0 0 3px rgba(37,130,90,.13); }
    input.screen:read-only { opacity: 0.7; }
    .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.45rem; }
    .grid button {
      border: 0; border-radius: 14px; padding: 0.85rem 0; font: inherit;
      background: var(--cream); color: var(--ink); font-size: 1.2rem; font-weight: 500;
      cursor: pointer; transition: transform .15s var(--ease), background .15s ease;
    }
    .grid button:hover { background: rgba(223,255,107,.35); }
    .grid button:active { transform: scale(.97); }
    .row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem; margin-top: 0.7rem; }
    button.primary, button.ghost, button.go {
      border: 0; border-radius: 999px; font: inherit; cursor: pointer;
      transition: transform .2s var(--ease), box-shadow .2s ease, background .2s ease;
    }
    button.primary, button.go {
      width: 100%; margin-top: 0.75rem; background: var(--sand); color: #fff;
      font-weight: 500; padding: 0.85rem 1rem;
      display: flex; align-items: center; justify-content: center; gap: 0.45rem;
    }
    button.primary:hover, button.go:hover { transform: translateY(-2px); box-shadow: 0 9px 22px rgba(20,25,22,.18); }
    button.go:disabled, button.primary:disabled { opacity: 0.5; cursor: wait; transform: none; box-shadow: none; }
    #dialer.busy #pad button,
    #dialer.busy #call,
    #dialer.busy #back,
    #dialer.busy #clear,
    #dialer.busy #hist-list button { pointer-events: none; opacity: 0.45; }
    .busy-msg { margin: 0.55rem 0 0; font-size: 0.82rem; color: #8a5a18; }
    button.go svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
    button.ghost {
      background: transparent; border: 1px solid var(--line); color: var(--ink);
      padding: 0.55rem 0.85rem; font-size: 0.85rem;
    }
    button.ghost:hover { background: var(--cream); }
    .linkish {
      background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer;
      padding: 0; text-decoration: underline; text-underline-offset: 2px;
    }
    #status, #login-err {
      min-height: 1.4rem; font-size: 0.82rem; color: var(--muted);
      margin-top: 0.65rem; white-space: pre-wrap;
    }
    .ok { color: var(--ok); }
    .err { color: var(--bad); }
    details {
      margin-top: 0.75rem; border-top: 1px solid var(--line); padding-top: 0.55rem;
      color: var(--muted); font-size: 0.8rem;
    }
    summary { cursor: pointer; color: var(--ink); font-weight: 500; }
    .switch {
      display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem;
      margin: 0 0 0.85rem; padding: 0.25rem; background: var(--cream);
      border: 1px solid var(--line); border-radius: 999px;
    }
    .switch button {
      border: 0; border-radius: 999px; padding: 0.45rem 0.6rem;
      font: inherit; font-size: 0.82rem; font-weight: 500; cursor: pointer;
      background: transparent; color: var(--muted);
    }
    .switch button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 6px rgba(20,27,22,.08); }
    .chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0 0 0.55rem; }
    .chips button {
      border: 1px solid var(--line); background: #fff; color: var(--muted);
      border-radius: 999px; padding: 0.28rem 0.65rem; font: inherit; font-size: 0.75rem;
      cursor: pointer;
    }
    .chips button.on { background: var(--sand); color: #fff; border-color: var(--sand); }
    .hist-hint { margin: 0 0 0.5rem; color: var(--muted); font-size: 0.75rem; line-height: 1.35; }
    #hist-q { margin-bottom: 0.55rem; }
    #hist-list {
      max-height: 16.5rem; overflow-y: auto; margin: 0 -0.15rem;
      display: flex; flex-direction: column; gap: 0.4rem;
    }
    .hist-item {
      display: grid; grid-template-columns: 1fr auto; gap: 0.35rem 0.55rem;
      align-items: center; background: var(--cream); border: 1px solid var(--line);
      border-radius: 14px; padding: 0.55rem 0.65rem; cursor: pointer; text-align: left;
    }
    .hist-item:hover { border-color: var(--ok); }
    .hist-item strong { display: block; font-size: 0.92rem; letter-spacing: 0.02em; }
    .hist-item small { color: var(--muted); font-size: 0.72rem; }
    .hist-item button {
      border: 0; border-radius: 999px; padding: 0.4rem 0.7rem; font: inherit;
      font-size: 0.75rem; font-weight: 500; cursor: pointer;
      background: var(--sand); color: #fff;
    }
    .hist-item button:hover { background: #2a2c30; }
    .pill-in, .pill-out {
      display: inline-block; border-radius: 999px; padding: 0.08rem 0.4rem;
      font-size: 0.68rem; font-weight: 500; margin-right: 0.25rem;
    }
    .pill-in { background: #dceee4; color: var(--ok); }
    .pill-out { background: #eef6c8; color: #4a5a12; }
    .hist-empty, .hist-err { color: var(--muted); font-size: 0.82rem; margin: 0.4rem 0; }
    .hist-err { color: var(--bad); }
    .dial-body { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; }
    .shell.with-hist .dial-body {
      grid-template-columns: minmax(16rem, 1fr) minmax(16rem, 1fr);
      gap: 0.2rem 1.15rem;
    }
    .shell.with-hist #panel-hist {
      border-left: 1px solid var(--line);
      padding-left: 1rem;
      min-width: 0;
    }
    #hist-list { max-height: min(28rem, 70vh); }
    .opt {
      display: flex; align-items: flex-start; gap: 0.5rem;
      margin: 0.75rem 0 0; font-size: 0.8rem; color: var(--ink); line-height: 1.35;
    }
    .opt input { width: auto; margin-top: 0.15rem; }
    @media (max-width: 760px) {
      .shell.with-hist { width: min(26rem, 100%); }
      .shell.with-hist .dial-body { grid-template-columns: 1fr; }
      .shell.with-hist #panel-hist {
        border-left: 0; padding-left: 0;
        border-top: 1px solid var(--line); padding-top: 0.85rem; margin-top: 0.35rem;
      }
    }
    @media (prefers-reduced-motion: reduce) {
      *, *::before, *::after { animation: none !important; transition: none !important; }
    }
  