:root {
  --ink: #1d1812;
  --ink-soft: #4a3f31;
  --ink-date: #7a6a52;
  --paper: #efe4cf;
  --brass: #b58a4a;
  --brass-hi: #e8c58a;
  --brass-deep: #8a6634;
  --caret: #b06a1e;
  --glow: 255, 190, 110;
  --night: #14110e;
  --night-deep: #0b0907;
  --title: #f3e6cf;
  --dim: #8e7f68;
  --dim-2: #7f715c;
  --fab-ink: #21170c;
  --key-ink: #22180e;
  --key-light: #f0dfc2;
  --mono: "PT Mono", "Courier New", monospace;
  --serif: "PT Serif", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  --keyfont: "PT Sans", "Helvetica Neue", Arial, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--night-deep);
}

body {
  font-family: var(--sans);
  color: #e9dcc6;
  background: radial-gradient(900px 600px at 50% 35%, #2a2016 0%, #16110c 55%, var(--night-deep) 100%) fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

button { font: inherit; color: inherit; }
button:focus-visible { outline: 2px solid var(--brass-hi); outline-offset: 2px; }

#app {
  position: relative;
  height: 100vh;
  height: 100dvh;
  max-width: 680px;
  margin: 0 auto;
  background: var(--night);
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.paper {
  background-color: var(--paper);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .35  0 0 0 0 .27  0 0 0 0 .17  0 0 0 .16 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* lamp */
.lamp { position: absolute; width: 34px; height: 30px; }
.lamp .hood {
  position: absolute; left: 2px; top: 4px; width: 30px; height: 17px; z-index: 2;
  border-radius: 15px 15px 4px 4px;
  background: linear-gradient(100deg, #5e4220 0%, #c9a05e 35%, #f1d9a6 48%, #a87d40 70%, #4f3719 100%);
  box-shadow: 0 2px 3px rgba(0, 0, 0, .45);
}
.lamp .hood::before {
  content: ""; position: absolute; left: 12px; top: -5px; width: 6px; height: 6px;
  border-radius: 2px; background: var(--brass-deep);
}
.lamp .bulb {
  position: absolute; left: 10px; top: 18px; width: 14px; height: 8px; z-index: 1;
  border-radius: 0 0 8px 8px; background: #fff3d6;
  box-shadow: 0 0 10px 4px rgba(var(--glow), .85), 0 0 30px 10px rgba(var(--glow), .35);
}

/* list */
.lhead { flex: none; padding: calc(var(--safe-top) + 22px) 24px 0; }
.ltitle { display: flex; align-items: baseline; justify-content: space-between; }
.ltitle h1 { margin: 0; font: 400 32px/1.15 var(--serif); color: var(--title); }
.count { font-size: 14px; color: var(--dim); }
.rail { position: relative; height: 16px; margin-top: 14px; }
.rail .bar { position: absolute; left: -8px; right: -8px; top: 6px; height: 3px; border-radius: 2px; background: linear-gradient(#e2bf83, var(--brass-deep)); }
.rail .end { position: absolute; top: 2px; width: 6px; height: 11px; border-radius: 2px; background: linear-gradient(#d2ad6f, #6f512a); }
.rail .end.l { left: -10px; }
.rail .end.r { right: -10px; }
.rail .lamp { left: calc(58% - 17px); top: -10px; }

.cards {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  margin: 0; padding: 20px 16px calc(var(--safe-bottom) + 130px); list-style: none;
  scrollbar-width: none;
}
.cards::-webkit-scrollbar { display: none; }
.cards li { margin-bottom: 10px; }
.card {
  position: relative; display: block; width: 100%; overflow: hidden;
  padding: 15px 18px 14px; border: 0; border-radius: 14px;
  text-align: left; color: var(--ink); cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .25) inset, 0 6px 18px rgba(0, 0, 0, .35);
  -webkit-tap-highlight-color: transparent;
}
.card h3 {
  margin: 0; font: 400 17px/1.3 var(--mono); letter-spacing: -.2px;
  text-shadow: .5px 0 0 currentColor;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card p {
  margin: 5px 0 0; font: 14px/1.38 var(--mono); color: var(--ink-soft);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card time { display: block; margin-top: 8px; font-size: 12.5px; color: var(--ink-date); }
.card.lit::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(260px 120px at 58% 0%, rgba(var(--glow), .38), transparent 75%);
}
.card.d1 { filter: brightness(.86); }
.card.d2 { filter: brightness(.74); }
.card.d3 { filter: brightness(.64); }
.card.d4 { filter: brightness(.58); }
.card:active { filter: brightness(1.02); }

.empty { flex: 1; margin: 0; padding: 40px 24px 160px; display: grid; place-items: center; text-align: center; font-size: 16px; color: var(--dim); }

.fabwrap {
  position: absolute; left: 0; right: 0; bottom: 0; pointer-events: none;
  padding: 70px 24px calc(var(--safe-bottom) + 24px);
  background: linear-gradient(rgba(20, 17, 14, 0), rgba(20, 17, 14, .96) 55%);
}
.fab {
  pointer-events: auto; width: 100%; height: 56px; border: 0; border-radius: 28px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 17px; font-weight: 600; color: var(--fab-ink);
  background: linear-gradient(#f0cf93, #c99a55);
  box-shadow: 0 10px 30px rgba(var(--glow), .25), 0 1px 0 #fff3d9 inset;
  -webkit-tap-highlight-color: transparent;
}
.fab span { font-size: 24px; font-weight: 400; line-height: 1; margin-top: -2px; }
.fab:active { filter: brightness(.95); }

/* note */
.note { --fs: 17.5px; --lh: 38px; }
.ehead {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  height: calc(var(--safe-top) + 50px); padding: var(--safe-top) 10px 0;
}
.link {
  background: none; border: 0; padding: 8px; cursor: pointer;
  font-size: 17px; color: var(--brass-hi); -webkit-tap-highlight-color: transparent;
}
.done { font-weight: 600; }
.eright { display: flex; align-items: center; gap: 6px; }
.saved { font-size: 13px; color: var(--dim-2); }
.saved.bad { color: #e0806a; }

.sheet {
  position: relative; flex: 1; min-height: 0; margin: 2px 10px 0;
  border-radius: 6px 6px 0 0; overflow: hidden; color: var(--ink);
  box-shadow: 0 -8px 30px rgba(0, 0, 0, .4);
}
.scroll {
  position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.scroll::-webkit-scrollbar { display: none; }
.page { padding: 0 18px 0 22px; }
.ndate { display: block; height: var(--lh); font: 13px/var(--lh) var(--mono); color: var(--ink); opacity: .42; }
.field { position: relative; }
.ink, .field textarea {
  font-family: var(--mono); font-size: var(--fs); line-height: var(--lh);
  font-weight: 400; letter-spacing: 0; tab-size: 4;
  white-space: pre-wrap; overflow-wrap: break-word; word-break: normal;
}
.ink { min-height: var(--lh); }
.ink .ln { color: var(--ink); opacity: var(--a, 1); }
.ink .ln.t { text-shadow: .5px 0 0 currentColor; }
.field textarea {
  position: absolute; inset: 0; width: 100%; height: 100%;
  margin: 0; padding: 0; border: 0; outline: none; resize: none; overflow: hidden;
  background: transparent; color: transparent; -webkit-text-fill-color: transparent;
  caret-color: var(--caret); border-radius: 0; appearance: none;
  -webkit-tap-highlight-color: transparent;
}
.field textarea::selection { background: rgba(176, 106, 30, .3); }

.curl {
  position: absolute; top: 0; left: 0; right: 0; height: 46px; z-index: 2; pointer-events: none;
  background: linear-gradient(rgba(20, 15, 10, .55), rgba(20, 15, 10, 0));
}
.shade {
  --x: 70%; --y: 80%;
  position: absolute; inset: 0; z-index: 1; pointer-events: none; mix-blend-mode: multiply;
  background:
    radial-gradient(420px 150px at var(--x) var(--y), rgba(var(--glow), .42), rgba(var(--glow), .1) 55%, rgba(var(--glow), 0) 75%),
    linear-gradient(rgba(96, 52, 14, .58) 0, rgba(120, 70, 22, .26) calc(var(--y) - 150px), rgba(120, 70, 22, 0) calc(var(--y) - 30px), rgba(120, 70, 22, 0) calc(var(--y) + 50px), rgba(96, 52, 14, .3) calc(var(--y) + 200px));
}
.carriage {
  position: absolute; left: 0; right: 0; top: 0; height: 14px; z-index: 3; pointer-events: none;
  transform: translateY(var(--cy, -100px));
}
.carriage .bar { position: absolute; left: 4px; right: 4px; top: 5px; height: 2.5px; border-radius: 2px; background: linear-gradient(#e6c48a, var(--brass-deep)); opacity: .9; }
.carriage .lamp { top: -14px; left: 0; transform: translateX(var(--cx, 0px)) scale(.85); transform-origin: 50% 100%; transition: transform 110ms ease-out; }
.carriage .bulb { box-shadow: 0 0 12px 5px rgba(var(--glow), .95), 0 0 46px 18px rgba(var(--glow), .45); }
.carriage.off { visibility: hidden; }

/* typewriter keyboard */
.kb {
  position: relative; flex: none; z-index: 5;
  padding: 26px 0 calc(var(--safe-bottom) + 10px);
  background: radial-gradient(300px 150px at 72% 0%, rgba(var(--glow), .2), transparent 70%), linear-gradient(#2a1d13, #18110b 45%, #0e0a07);
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.note.reading .kb { display: none; }
.platen {
  position: absolute; top: -12px; left: 6px; right: 6px; height: 24px; border-radius: 12px;
  background: linear-gradient(#4a423d 0%, #14110f 35%, #26211e 60%, #060505 100%);
  box-shadow: 0 4px 8px rgba(0, 0, 0, .65), 0 -1px 0 rgba(255, 220, 170, .15) inset;
}
.platen .kn { position: absolute; top: 2px; width: 10px; height: 20px; border-radius: 4px; background: linear-gradient(90deg, #6d6862, #e7e2da 45%, #8b857d 70%, #4a4640); }
.platen .kn.l { left: -4px; }
.platen .kn.r { right: -4px; }
.note.reading .sheet { border-radius: 6px; margin-bottom: calc(var(--safe-bottom) + 10px); }
.trim { position: absolute; top: 20px; left: 14px; right: 14px; height: 1px; background: linear-gradient(90deg, transparent, rgba(232, 197, 138, .55), transparent); }

.keys { width: min(100%, 640px); margin: 0 auto; padding: 0 3px; container-type: inline-size; }
.kr { --u: calc(100cqw / 11); display: flex; justify-content: center; height: min(calc(var(--u) * 1.3), 58px); }
.kr.r4 { gap: 8px; padding: 0 6px; margin-top: 2px; }
.k {
  position: relative; flex: 0 0 var(--u); height: 100%; min-width: 0;
  display: grid; place-items: center; padding: 0; border: 0; background: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.k:focus-visible { outline: none; }
.k:focus-visible .cap { outline: 2px solid var(--brass-hi); outline-offset: 3px; }
.cap {
  position: relative; display: grid; place-items: center;
  width: min(calc(var(--u) - 5px), 48px); aspect-ratio: 1; border-radius: 50%;
  font: 700 min(calc(var(--u) * .46), 20px)/1 var(--keyfont); color: var(--key-ink);
  background: radial-gradient(circle at 42% 32%, #fffaf0 0%, #f1e6cf 40%, #dccaa6 78%, #bfa77c 100%);
  box-shadow: inset 0 -2px 3px rgba(80, 55, 20, .35), inset 0 1px 1px rgba(255, 255, 255, .9), 0 0 0 1.6px #e6e1d8, 0 0 0 2.6px #6f685f, 0 4px 0 1.2px #050302, 0 7px 9px rgba(0, 0, 0, .65);
  transition: transform 50ms ease-out, box-shadow 50ms ease-out;
}
.cap[data-alt]::after {
  content: attr(data-alt); position: absolute; top: 9%; right: 17%;
  font-size: min(calc(var(--u) * .24), 10px); font-weight: 700; opacity: .5;
}
.k.dark .cap { background: radial-gradient(circle at 42% 30%, #5a5049 0%, #2a231e 45%, #120e0b 100%); color: var(--key-light); }
.k.small .cap { font-size: min(calc(var(--u) * .34), 15px); }
.k.icon .cap svg { width: 52%; height: 52%; }
.k.on .cap {
  transform: translateY(2.5px);
  box-shadow: inset 0 -2px 3px rgba(80, 55, 20, .3), inset 0 1px 1px rgba(255, 255, 255, .9), 0 0 0 1.6px #f2e1bd, 0 0 0 2.6px var(--brass-deep), 0 1.5px 0 1.2px #050302, 0 0 16px 4px rgba(var(--glow), .55);
}
.k.shift[data-state="once"] .cap, .k.shift[data-state="lock"] .cap {
  color: #ffe2a8;
  box-shadow: inset 0 -2px 3px rgba(0, 0, 0, .35), 0 0 0 1.6px #f2e1bd, 0 0 0 2.6px var(--brass), 0 4px 0 1.2px #050302, 0 0 14px 3px rgba(var(--glow), .45);
}
.k.shift[data-state="lock"] .cap::after {
  content: ""; position: absolute; bottom: 18%; left: 32%; right: 32%; height: 2px; border-radius: 1px; background: #ffe2a8;
}
.k.pill { flex: 0 0 calc(var(--u) * 1.75); }
.k.pill .cap, .k.space .cap, .k.enter .cap { width: 100%; aspect-ratio: auto; border-radius: 999px; }
.k.pill .cap { height: min(calc(var(--u) - 2px), 46px); font-size: min(calc(var(--u) * .42), 17px); }
.k.space { flex: 1 1 auto; }
.k.space .cap {
  height: min(calc(var(--u) * .74), 34px);
  font: 400 min(calc(var(--u) * .3), 12px)/1 var(--keyfont); letter-spacing: 2px; text-transform: uppercase; color: #4d463e;
  background: linear-gradient(#fbf8f2 0%, #cfcac2 35%, #8d877f 70%, #d9d4cc 100%);
  box-shadow: 0 0 0 1px #4e4842, 0 4px 0 1px #050302, 0 7px 9px rgba(0, 0, 0, .6);
}
.k.space.on .cap { box-shadow: 0 0 0 1px var(--brass-deep), 0 1.5px 0 1px #050302, 0 0 16px 4px rgba(var(--glow), .45); }
.k.enter { flex: 0 0 calc(var(--u) * 2.7); }
.k.enter .cap {
  height: min(calc(var(--u) - 2px), 46px); font-size: min(calc(var(--u) * .42), 17px); color: #24170a;
  background: linear-gradient(#f3d79f, #c99a55 60%, #a87a3c);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, .35), 0 0 0 1.6px #e6e1d8, 0 0 0 2.6px #6f685f, 0 4px 0 1.2px #050302, 0 7px 9px rgba(0, 0, 0, .65);
}

/* sound */
.lmeta { display: flex; align-items: center; gap: 4px; }
.sndbtn {
  display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%;
  background: none; color: var(--brass-hi); cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.sndbtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sndbtn .spk { fill: currentColor; fill-opacity: .18; }
.sndbtn .slash { display: none; }
.muted .sndbtn .wave { display: none; }
.muted .sndbtn .slash { display: inline; }
.muted .sndbtn { color: var(--dim); }
.sndbtn[aria-expanded="true"] { background: rgba(var(--glow), .14); }
.eright { gap: 2px; }

.sndpanel {
  position: absolute; z-index: 20; top: calc(var(--safe-top) + 54px); right: 10px; width: min(260px, calc(100% - 20px));
  display: grid; gap: 14px; padding: 16px 16px 18px; border-radius: 14px;
  background: linear-gradient(#2a1d13, #17110c); border: 1px solid rgba(232, 197, 138, .22);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .6), 0 0 40px rgba(var(--glow), .08);
  color: #e9dcc6; font-size: 15px;
}
.sndpanel label { display: grid; gap: 8px; }
.sndpanel .sw { grid-template-columns: 1fr auto; align-items: center; cursor: pointer; }
.sndpanel .sw span { font-weight: 600; }
.sndpanel .rg span { color: var(--dim); font-size: 13px; }
.sndpanel input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; margin: 0; width: 46px; height: 28px; border-radius: 14px; cursor: pointer;
  position: relative; background: #3a2f26; box-shadow: inset 0 1px 3px rgba(0, 0, 0, .6); transition: background 120ms;
}
.sndpanel input[type="checkbox"]::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 42% 32%, #fffaf0, #dccaa6 78%, #bfa77c);
  box-shadow: 0 0 0 1px #6f685f, 0 2px 3px rgba(0, 0, 0, .5); transition: transform 120ms;
}
.sndpanel input[type="checkbox"]:checked { background: linear-gradient(#f0cf93, #c99a55); }
.sndpanel input[type="checkbox"]:checked::after { transform: translateX(18px); }
.sndpanel input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; margin: 0; background: transparent; cursor: pointer; }
.sndpanel input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--brass-deep), var(--brass-hi)); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .6); }
.sndpanel input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--brass-deep), var(--brass-hi)); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .6); }
.sndpanel input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -9px; border-radius: 50%; border: 0; background: radial-gradient(circle at 42% 32%, #fffaf0, #dccaa6 78%, #bfa77c); box-shadow: 0 0 0 2px #6f685f, 0 2px 4px rgba(0, 0, 0, .55); }
.sndpanel input[type="range"]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; border: 0; background: radial-gradient(circle at 42% 32%, #fffaf0, #dccaa6 78%, #bfa77c); box-shadow: 0 0 0 2px #6f685f, 0 2px 4px rgba(0, 0, 0, .55); }
.sndpanel input:focus-visible { outline: 2px solid var(--brass-hi); outline-offset: 3px; }
.sndpanel.off .rg { opacity: .45; }

@media (min-width: 700px) {
  .note { --fs: 19px; --lh: 40px; }
  #app { box-shadow: 0 0 120px rgba(var(--glow), .06); }
}

@media (prefers-reduced-motion: reduce) {
  .cap, .carriage .lamp, .sndpanel input[type="checkbox"], .sndpanel input[type="checkbox"]::after { transition: none; }
}
