:root {
  --desk: #6b4f3a;
  --desk-2: #5a412f;
  --desk-ink: #f3e9d2;
  --shell: #e6d8b8;
  --shell-hi: #f3e9d2;
  --shell-lo: #b9a77f;
  --shell-edge: #9c8a63;
  --key: #f6efdc;
  --key-lo: #cfc2a0;
  --ink: #4a3f2c;
  --ink-soft: #7a6a4c;
  --lcd: #a7b58a;
  --lcd-hi: #bcc99c;
  --lcd-ink: #26301a;
  --lcd-ghost: rgba(38, 48, 26, 0.12);
  --red: #b8392b;
  --red-lo: #7e2219;
  --green: #4f7a3a;
  --paper: #fbf6e6;
  --paper-line: #c7d6e8;
  --pen: #1d3a8a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --desk: #2a211a;
    --desk-2: #1f1813;
    --desk-ink: #d8cbb0;
  }
}
:root[data-theme="dark"] {
  --desk: #2a211a;
  --desk-2: #1f1813;
  --desk-ink: #d8cbb0;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    repeating-linear-gradient(92deg, transparent 0 38px, rgba(0,0,0,.05) 38px 40px, transparent 40px 90px),
    linear-gradient(180deg, var(--desk), var(--desk-2));
  background-color: var(--desk);
  color: var(--ink);
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 28px 16px 40px;
  -webkit-tap-highlight-color: transparent;
}

.phone { width: 100%; max-width: 380px; position: relative; padding-top: 58px; }

/* ---- handset resting on the cradle ---- */
.handset {
  position: absolute; left: 50%; top: 0; width: 92%; height: 70px;
  transform: translateX(-50%);
  transition: transform .35s cubic-bezier(.3,1.4,.6,1);
  z-index: 2;
}
.handset .grip {
  position: absolute; left: 22%; right: 22%; top: 14px; height: 30px;
  background: linear-gradient(180deg, var(--shell-hi), var(--shell) 60%, var(--shell-lo));
  border-radius: 14px; box-shadow: 0 3px 0 var(--shell-edge), 0 8px 14px rgba(0,0,0,.35);
}
.handset .cup {
  position: absolute; top: 0; width: 30%; height: 58px;
  background: radial-gradient(ellipse at 50% 30%, var(--shell-hi), var(--shell) 55%, var(--shell-lo));
  border-radius: 26px 26px 20px 20px;
  box-shadow: 0 4px 0 var(--shell-edge), 0 10px 16px rgba(0,0,0,.35);
}
.handset .cup::after {
  content: ""; position: absolute; left: 22%; right: 22%; top: 14px; height: 18px; border-radius: 50%;
  background: radial-gradient(circle, var(--shell-edge) 1.5px, transparent 2px) 0 0 / 6px 6px;
  opacity: .7;
}
.handset .cup.l { left: 0; } .handset .cup.r { right: 0; }
.phone.offhook .handset { transform: translate(-50%, -26px) rotate(-6deg); }

/* ---- body ---- */
.body {
  position: relative;
  background: linear-gradient(180deg, var(--shell-hi) 0, var(--shell) 18%, var(--shell) 80%, var(--shell-lo));
  border-radius: 34px 34px 22px 22px;
  padding: 26px 20px 18px;
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,.6),
    inset 0 -4px 0 var(--shell-lo),
    0 6px 0 var(--shell-edge),
    0 18px 30px rgba(0,0,0,.45);
}
.cradle {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  width: 70%; height: 22px; border-radius: 12px 12px 0 0;
  background: linear-gradient(180deg, var(--shell-lo), var(--shell));
}
.brand {
  display: flex; justify-content: space-between; align-items: baseline;
  font-weight: 700; letter-spacing: .18em; font-size: 12px; color: var(--ink-soft);
  text-transform: uppercase; margin: 0 4px 10px;
}
.brand b { color: var(--red); letter-spacing: .08em; font-size: 15px; font-style: italic; }

/* ---- LCD ---- */
.lcd {
  font-family: "VT323", ui-monospace, monospace;
  background: linear-gradient(180deg, var(--lcd-hi), var(--lcd));
  color: var(--lcd-ink);
  border-radius: 6px; padding: 8px 12px 6px;
  box-shadow: inset 0 3px 6px rgba(0,0,0,.35), 0 0 0 4px #3b3427, 0 0 0 6px var(--shell-lo);
  margin: 6px 6px 22px; min-height: 76px; position: relative; overflow: hidden;
  text-transform: uppercase;
}
.lcd::before { /* ghost segments */
  content: "8888888888888888888"; position: absolute; left: 12px; top: 8px; font-size: 30px;
  color: var(--lcd-ghost); letter-spacing: .02em; pointer-events: none; white-space: nowrap;
}
.lcd .l1 { font-size: 30px; line-height: 1; position: relative; white-space: nowrap; overflow: hidden; text-overflow: clip; }
.lcd .l2 { font-size: 21px; line-height: 1.15; position: relative; display: flex; justify-content: space-between; gap: 8px; }
.lcd .blink { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---- speed dial card ---- */
.speed { display: grid; gap: 10px; margin: 0 4px 20px; }
.speed .row { display: grid; grid-template-columns: 58px 1fr; gap: 10px; align-items: stretch; }
.mem {
  appearance: none; border: 0; cursor: pointer; font: inherit;
  background: linear-gradient(180deg, var(--key), var(--key-lo));
  border-radius: 8px; color: var(--ink); font-weight: 700; font-size: 13px; letter-spacing: .1em;
  box-shadow: 0 4px 0 var(--shell-edge), 0 6px 8px rgba(0,0,0,.25);
  transition: transform .05s, box-shadow .05s;
  min-height: 52px;
}
.mem:active, .mem.down { transform: translateY(3px); box-shadow: 0 1px 0 var(--shell-edge), 0 2px 3px rgba(0,0,0,.25); }
.label {
  background: repeating-linear-gradient(180deg, var(--paper) 0 21px, var(--paper-line) 21px 22px);
  background-color: var(--paper);
  border-radius: 3px; padding: 8px 12px; display: flex; align-items: center;
  font-family: "Gochi Hand", "Comic Sans MS", cursive; color: var(--pen); font-size: 24px; line-height: 1.1;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08), inset 0 2px 3px rgba(0,0,0,.08);
  border: 2px solid var(--shell-lo);
  cursor: pointer;
}
.speed .empty { font-family: "VT323", monospace; color: var(--ink-soft); text-align: center; font-size: 20px; padding: 8px; }

/* ---- keypad ---- */
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 14px; margin: 0 18px 20px; }
.key {
  appearance: none; border: 0; cursor: pointer;
  background: linear-gradient(180deg, var(--key), var(--key-lo));
  border-radius: 10px; color: var(--ink); height: 50px;
  box-shadow: 0 4px 0 var(--shell-edge), 0 6px 8px rgba(0,0,0,.22);
  font-family: "Barlow Condensed", sans-serif; font-size: 26px; font-weight: 700; line-height: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: transform .05s, box-shadow .05s;
}
.key small { font-size: 9px; letter-spacing: .2em; color: var(--ink-soft); font-weight: 600; margin-top: 2px; }
.key:active, .key.down { transform: translateY(3px); box-shadow: 0 1px 0 var(--shell-edge), 0 2px 3px rgba(0,0,0,.2); }

/* ---- controls ---- */
.controls { display: grid; grid-template-columns: 1fr 1.6fr; gap: 14px; margin: 0 4px 14px; }
.ctl {
  appearance: none; border: 0; cursor: pointer; height: 52px; border-radius: 10px;
  font-family: "Barlow Condensed", sans-serif; font-weight: 700; font-size: 17px; letter-spacing: .14em;
  text-transform: uppercase;
  transition: transform .05s, box-shadow .05s, opacity .2s;
}
.ctl:disabled { opacity: .45; cursor: default; }
.ctl.mute { background: linear-gradient(180deg, var(--key), var(--key-lo)); color: var(--ink); box-shadow: 0 4px 0 var(--shell-edge); }
.ctl.mute[aria-pressed="true"] { background: linear-gradient(180deg, #e9c66b, #c99d2e); }
.ctl.hang { background: linear-gradient(180deg, #d4513f, var(--red)); color: #fff4e8; box-shadow: 0 4px 0 var(--red-lo), 0 6px 10px rgba(0,0,0,.25); }
.ctl:not(:disabled):active { transform: translateY(3px); box-shadow: 0 1px 0 var(--shell-edge); }

.led { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #5a4d35; margin-right: 6px; vertical-align: 1px; box-shadow: inset 0 1px 1px rgba(0,0,0,.4); }
.led.on { background: #ff5b3d; box-shadow: 0 0 8px #ff5b3d; }

.foot {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); margin: 4px 6px 0;
}
.foot button { appearance: none; background: none; border: 0; color: var(--ink-soft); font: inherit; letter-spacing: inherit; text-decoration: underline; cursor: pointer; padding: 6px 0; }
.grille { height: 14px; margin: 0 30% 10px; background: repeating-linear-gradient(90deg, var(--shell-lo) 0 3px, transparent 3px 7px); border-radius: 4px; opacity: .8; }

/* ---- login ---- */
.signin { display: grid; gap: 10px; margin: 0 4px 18px; }
.signin label { font-size: 13px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-soft); font-weight: 700; }
.signin input {
  width: 100%; font-family: "Gochi Hand", cursive; font-size: 24px; color: var(--pen);
  background: repeating-linear-gradient(180deg, var(--paper) 0 21px, var(--paper-line) 21px 22px);
  background-color: var(--paper);
  border: 2px solid var(--shell-lo); border-radius: 3px; padding: 6px 12px; outline: none;
}
.signin input:focus { border-color: var(--pen); }
.signin .ctl { margin-top: 8px; width: 100%; background: linear-gradient(180deg, #6c9a52, var(--green)); color: #f4ffe8; box-shadow: 0 4px 0 #2f4a22, 0 6px 10px rgba(0,0,0,.25); }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 3px solid var(--pen); outline-offset: 2px; }

@media (max-width: 360px) {
  .keypad { margin: 0 6px 18px; gap: 8px 10px; }
  .lcd .l1 { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  .handset, .mem, .key, .ctl { transition: none; }
  .lcd .blink { animation: none; }
}
