/* Inbox Zero Hero – two looks.
   1. The studio frame (start, rule, day end, review, file, pause): square corners, 3px black outlines, hard offset
      shadows, flat colour, Rubik. A beige window under the arcade bar.
   2. The play screen is the game's world: HyperMail Online, a mid-90s dial-up mail client filling the screen.
      Navy and teal chrome, gold bevelled toolbar, pixel-font chrome labels, mail text in Rubik.
      Desktop: toolbar on top, folders left, message list, preview pane. Upright phones: folder strip, short list,
      preview, toolbar at the bottom. Short sideways screens: preview plus a toolbar column. */
:root {
  --paper: #FAF7F0; --beige: #EFE7D3; --slate: #4C5966; --ink: #1E2328; --k: #000;
  --coral: #FF6B57; --sunny: #FFC845; --sky: #3DA5F4; --glow: #80FF84; --grape: #7A5CFF; --slime: #22AA3A;
  /* HyperMail */
  --hm-navy: #14213D; --hm-navy2: #23365E; --hm-navy-l: #3E5688; --hm-teal: #1C7C8C; --hm-teal-l: #4FB3C1; --hm-teal-d: #0E4C57;
  --hm-gold: #F4C542; --hm-gold-l: #FFE58A; --hm-gold-d: #9C7410; --hm-pane: #FFFFFF; --hm-pale: #E4ECF4; --hm-pale-d: #9AABBF;
  --hm-alt: #F3F6FA; --hm-pixel: "Pixelify Sans", "Courier New", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden;
  background: var(--paper); color: var(--ink);
  font: 400 16px/1.35 Rubik, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }

#app {
  flex: 1; min-height: 0; display: flex; justify-content: center;
  padding: 12px max(12px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
.win {
  flex: 1; min-width: 0; max-width: 1000px; max-height: 680px; margin: auto 0;
  height: 100%; display: flex; flex-direction: column;
  background: var(--beige); border: 3px solid var(--k); box-shadow: 5px 5px 0 var(--k);
}

/* ---- Studio title bar ---- */
.titlebar {
  flex: none; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 4px 0 6px;
  background: var(--coral); border-bottom: 3px solid var(--k); white-space: nowrap;
}
.tb-icon canvas { display: block; width: 32px; height: 32px; image-rendering: pixelated; }
.tb-title { font-weight: 800; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tb-btn {
  width: 32px; height: 30px; padding: 0; font-weight: 800; cursor: pointer;
  background: var(--beige); border: 3px solid var(--k);
}
.tb-btn[aria-pressed="true"], .hm-tbtn[aria-pressed="true"] { text-decoration: line-through; }

.body { flex: 1; min-height: 0; position: relative; background: var(--paper); }
.screen {
  position: absolute; inset: 0; display: flex; gap: 18px; padding: 18px; overflow: auto;
}

/* ---- Shared studio bits ---- */
h1, h2 { font-weight: 800; margin: 0 0 6px; line-height: 1.1; }
h1 { font-size: clamp(30px, 6vw, 52px); }
h2 { font-size: clamp(24px, 4vw, 36px); }
p { margin: 0 0 10px; }
.kicker { font-weight: 700; text-transform: none; color: #1D6831; margin-bottom: 4px; }
.fine { font-size: 14px; color: var(--slate); }
.ex { background: var(--beige); border: 3px solid var(--k); padding: 8px 10px; font-weight: 500; }
.row { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  min-height: 44px; padding: 8px 16px; font-weight: 700; font-size: 17px; cursor: pointer;
  background: #fff; border: 3px solid var(--k); box-shadow: 4px 4px 0 var(--k);
}
.btn:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--k); }
.btn.primary { background: var(--coral); }
.btn.small { min-height: 36px; font-size: 15px; padding: 4px 12px; }
.btn:focus-visible, .act:focus-visible, .tb-btn:focus-visible, .hm-tbtn:focus-visible { outline: 3px solid var(--grape); outline-offset: 2px; }
.memo { flex: 1; min-width: 0; }
.side { flex: none; width: 230px; display: flex; flex-direction: column; gap: 12px; }
.side .btn { width: 100%; }
.keys { font-size: 14px; color: var(--slate); }
.status { font-size: 14px; font-weight: 500; min-height: 1.3em; }

/* ---- Start ---- */
#s-start { align-items: center; justify-content: center; gap: 28px; }
.start-art { flex: none; position: relative; width: 160px; height: 160px; }
.start-art canvas { position: absolute; image-rendering: pixelated; border: 3px solid var(--k); box-shadow: 4px 4px 0 var(--k); }
.start-text { max-width: 520px; }
.dek { font-size: 20px; font-weight: 500; }

/* ---- Review ---- */
.review h2 { font-size: clamp(26px, 4.6vw, 42px); }
.e-line { font-size: 18px; font-weight: 500; }
.e-days { font-size: 28px; letter-spacing: 4px; }
.e-card { display: block; width: min(100%, 300px); border: 3px solid var(--k); box-shadow: 4px 4px 0 var(--k); }
.e-card:not([src]) { display: none; }

/* ---- Performance file ---- */
.file { flex: 1; min-width: 0; }
.titles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.titles li { border: 3px solid var(--k); background: #fff; padding: 6px 10px; font-size: 14px; }
.titles li b { display: block; font-size: 16px; }
.titles li.got { background: var(--glow); }
.titles li.got b::before { content: "✓ "; }
.titles li:not(.got) { color: var(--slate); }

/* =====================================================================
   HyperMail Online: the play screen
   ===================================================================== */
.hm {
  flex: 1; min-height: 0; position: relative; display: grid;
  grid-template-rows: auto auto minmax(0, 1fr); grid-template-areas: "title" "tools" "main";
  background-color: var(--hm-navy);
  background-image: radial-gradient(var(--hm-navy2) 1px, transparent 1px); background-size: 6px 6px;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  color: var(--ink); user-select: none; -webkit-user-select: none;
}
.hm canvas { display: block; image-rendering: pixelated; }
/* Raised and sunken 90s bevels: hard 2px edges, no blur. */
.hm .raised, .hm-tools .act, .hm-tbtn {
  border: 1px solid #000;
  box-shadow: inset 2px 2px 0 var(--hm-gold-l), inset -2px -2px 0 var(--hm-gold-d);
}
.hm-sunk { border: 1px solid #000; box-shadow: inset 2px 2px 0 var(--hm-pale-d); }

/* Title bar */
.hm-title {
  grid-area: title; display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 6px;
  background: var(--hm-teal); border-bottom: 2px solid #000; box-shadow: inset 0 2px 0 var(--hm-teal-l), inset 0 -2px 0 var(--hm-teal-d);
  color: #fff; font-family: var(--hm-pixel); font-weight: 500; font-size: 17px; white-space: nowrap;
}
.hm-logo canvas { width: 32px; height: 32px; }
.hm-name b { color: var(--hm-gold); font-weight: 700; }
.hm-folder { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: #DDF3F6; }
.hm-folder::before { content: "· "; }
.hm-stat { font-variant-numeric: tabular-nums; }
/* Numbers in Rubik: the pixel font's 8 reads as an S. */
.hm-stat, .hm-folder, .unread, .fd b, .mult { font-family: Rubik, sans-serif; }
.hm-stat, .hm-folder { font-weight: 500; font-size: 15px; }
.hm-score { min-width: 4em; text-align: right; color: var(--hm-gold); font-weight: 700; }
.hm-tbtn {
  width: 32px; height: 28px; padding: 0; cursor: pointer; background: var(--hm-gold); color: #000;
  font-family: var(--hm-pixel); font-weight: 700; font-size: 15px;
}

/* Toolbar */
.hm-tools {
  grid-area: tools; display: flex; align-items: stretch; gap: 8px; padding: 8px;
  background: var(--hm-navy2); border-bottom: 2px solid #000;
}
.hm-tools .act {
  flex: 0 1 200px; min-height: 52px; display: flex; align-items: center; gap: 10px; padding: 6px 12px 6px 8px;
  cursor: pointer; background: var(--hm-gold); color: #000; text-align: left;
}
.hm-tools .act:active { box-shadow: inset 2px 2px 0 var(--hm-gold-d), inset -2px -2px 0 var(--hm-gold-l); transform: translate(1px, 1px); }
.ico canvas { width: 32px; height: 32px; }
.lbl { font-family: var(--hm-pixel); font-weight: 700; font-size: 20px; line-height: 1.05; }
.arr { font-family: Rubik, sans-serif; font-weight: 800; }
.hint { display: block; font-family: Rubik, sans-serif; font-size: 13px; font-weight: 500; line-height: 1.2; }
.meter {
  margin-left: auto; display: flex; align-items: baseline; gap: 6px; padding: 4px 10px; color: #fff;
  font-family: var(--hm-pixel);
}
.unread { font-size: 38px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; color: var(--hm-gold); }
.unread.warn { color: #FF9F43; } .unread.danger { color: #FF5A47; }
.u-label { font-weight: 500; font-size: 16px; }
.mult { align-self: center; font-weight: 700; padding: 0 8px; background: var(--glow); color: #000; border: 1px solid #000; }
.mult:empty { display: none; }

/* Main area */
.hm-main {
  grid-area: main; min-height: 0; display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 8px; padding: 8px;
}
.hm-folders {
  display: flex; flex-direction: column; gap: 2px; padding: 6px; min-height: 0;
  background: var(--hm-pale); border: 1px solid #000; box-shadow: inset 2px 2px 0 var(--hm-pale-d);
  font-family: var(--hm-pixel); font-size: 16px; font-weight: 500;
}
.fd { display: flex; align-items: center; gap: 8px; padding: 4px 6px; white-space: nowrap; }
.fd i canvas { width: 16px; height: 16px; }
.fd b { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.fd.on { background: var(--hm-navy2); color: #fff; }
.fd.on b { color: var(--hm-gold); }
.fd.bump b { animation: bump .3s ease-out; }
@keyframes bump { from { transform: scale(1.5); } to { transform: none; } }
.hm-right { min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 8px; }

/* Message list */
.hm-list {
  list-style: none; margin: 0; padding: 0; max-height: calc(5 * 27px + 2px); overflow: hidden;
  background: var(--hm-pane); border: 1px solid #000; box-shadow: inset 2px 2px 0 var(--hm-pale-d);
  font-size: 14px;
}
.hm-list li {
  display: grid; grid-template-columns: 150px minmax(0, 1fr) 76px; gap: 10px; align-items: center;
  height: 27px; padding: 0 8px; white-space: nowrap; border-bottom: 1px solid var(--hm-pale);
}
.hm-list li:nth-child(even) { background: var(--hm-alt); }
.hm-list li.sel { background: var(--hm-gold-l); font-weight: 700; }
.hm-list li.more { display: block; color: var(--slate); font-style: italic; line-height: 27px; }
.hm-list span { overflow: hidden; text-overflow: ellipsis; }
.l-from { font-weight: 700; }
.l-at { color: var(--slate); text-align: right; font-size: 13px; }
.l-tag {
  display: inline-block; margin-right: 6px; padding: 0 4px; font: 700 11px/16px var(--hm-pixel); font-style: normal;
  background: var(--hm-pale); border: 1px solid #000; vertical-align: 1px;
}
.l-tag.all { background: var(--grape); color: #fff; }
.l-tag.invite { background: var(--sky); }
.l-tag.back { background: var(--sunny); } .l-tag.angry { background: var(--coral); }

/* Preview pane (the swipeable message) */
.stage { position: relative; min-height: 0; }
.card {
  position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; overflow: hidden;
  background: var(--hm-pane); border: 1px solid #000; box-shadow: inset 2px 2px 0 var(--hm-pale-d);
  touch-action: none; cursor: grab;
}
.card.dragging { cursor: grabbing; box-shadow: 6px 6px 0 rgba(0, 0, 0, .55); }
.card.fly { transition: transform .22s ease-in, opacity .22s ease-in; opacity: 0; }
.card.enter { animation: enter .16s ease-out; }
@keyframes enter { from { opacity: .3; } to { opacity: 1; } }
.c-head {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  background: var(--hm-pale); border-bottom: 1px solid var(--hm-pale-d);
}
.avatar { flex: none; width: 64px; height: 64px; border: 1px solid #000; display: grid; place-items: center;
  font-weight: 800; font-size: 24px; overflow: hidden; background: #fff; }
.avatar canvas { width: 100%; height: 100%; }
.c-fields { min-width: 0; font-size: 15px; line-height: 1.45; }
.c-fields > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-fields .k { display: inline-block; width: 5.6em; font-family: var(--hm-pixel); font-weight: 500; color: var(--hm-navy-l); }
.c-role { color: var(--slate); }
.c-subj { font-size: 17px; }
.c-badges { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 14px 0; }
.c-badges:empty { display: none; }
.badge { font: 700 13px/1.5 var(--hm-pixel); padding: 0 8px; border: 1px solid #000; background: var(--hm-pale); }
.badge.all { background: var(--grape); color: #fff; }
.badge.invite { background: var(--sky); }
.badge.back { background: var(--sunny); }
.badge.angry { background: var(--coral); }
.c-body { padding: 12px 14px; font-size: 20px; max-width: 46em; }
.stamp {
  position: absolute; left: 50%; top: 52%; transform: translate(-50%, -50%) rotate(-10deg);
  padding: 2px 14px; border: 4px solid currentColor; font: 700 34px/1.2 var(--hm-pixel); letter-spacing: 1px;
  background: rgba(255, 255, 255, .88); opacity: 0; pointer-events: none;
}
.stamp.show { opacity: 1; }
.stamp.R { color: #1D6831; } .stamp.A { color: #155E9E; } .stamp.S { color: #8A5A00; } .stamp.no { color: #C2311E; }
.empty {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; text-align: center; color: #fff; border: 2px dashed var(--hm-teal-l); font-size: 18px;
}
.empty b { font: 700 28px var(--hm-pixel); color: var(--hm-gold); }
.gotmail {
  position: absolute; right: 12px; bottom: 12px; z-index: 4;
  display: flex; align-items: center; gap: 10px; padding: 6px 16px 6px 8px; white-space: nowrap;
  background: var(--hm-gold); border: 1px solid #000; box-shadow: inset 2px 2px 0 var(--hm-gold-l), inset -2px -2px 0 var(--hm-gold-d), 4px 4px 0 #000;
  font: 700 22px var(--hm-pixel); color: #000; pointer-events: none;
}
.gm-ico canvas { width: 32px; height: 32px; }
.gotmail.pop { animation: pop .25s ease-out; }
@keyframes pop { from { transform: scale(.6); } to { transform: none; } }
.toast {
  position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 3; padding: 8px 12px;
  background: #FFF4C2; border: 1px solid #000; box-shadow: inset 0 0 0 2px var(--coral), 4px 4px 0 #000; font-weight: 700;
}
.toast::before { content: "Mail system notice: "; font-family: var(--hm-pixel); color: #B4321F; }

/* Pause: a studio card over the client */
.pause { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(20, 33, 61, .82); }
.pause .memo { flex: none; max-width: 460px; background: var(--paper); border: 3px solid var(--k); box-shadow: 5px 5px 0 var(--k); padding: 16px; }

/* ---- Tall, narrow screens (phones held upright) ---- */
@media (max-aspect-ratio: 1/1) {
  .win { max-height: 900px; }
  .screen { flex-direction: column; padding: 14px; }
  .side { width: auto; }
  #s-start { justify-content: flex-start; gap: 14px; }
  .start-art { width: 120px; height: 120px; }

  .hm { grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: "title" "main" "tools"; }
  .hm-tools { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; border-bottom: 0; border-top: 2px solid #000; }
  .hm-tools .meter { grid-row: 1; grid-column: 1 / -1; margin: 0; padding: 0 2px; }
  .hm-tools .act { flex-direction: column; justify-content: center; gap: 2px; min-height: 76px; padding: 6px 4px; text-align: center; }
  .unread { font-size: 26px; }
  .hm-main { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); padding: 6px; gap: 6px; }
  .hm-folders { flex-direction: row; padding: 3px; gap: 2px; overflow: hidden; font-size: 14px; }
  .fd { flex: 1; justify-content: center; gap: 4px; padding: 3px 2px; }
  .fd b { margin-left: 2px; }
  .hm-right { gap: 6px; }
  .hm-list { max-height: calc(3 * 27px + 2px); font-size: 13px; }
  .hm-list li { grid-template-columns: 96px minmax(0, 1fr); gap: 8px; }
  .l-at { display: none; }
}
@media (max-aspect-ratio: 1/1) and (max-width: 420px) {
  .hm-title { gap: 6px; font-size: 15px; }
  .hm-name span, .hm-folder { display: none; }
  .hm-name { flex: 1; }
  .hm-score { min-width: 0; }
  .fd i { display: none; }
  .avatar { width: 48px; height: 48px; font-size: 18px; }
  .c-fields { font-size: 14px; }
  .c-fields .k { width: 4.9em; }
  .c-subj { font-size: 15px; }
  .c-body { font-size: 18px; }
  .lbl { font-size: 17px; }
  .hint { font-size: 12px; }
  .gotmail { font-size: 17px; }
}

/* ---- Short screens (phones held sideways): preview plus a toolbar column ---- */
@media (max-height: 520px) and (min-aspect-ratio: 1/1) {
  #app { padding-top: 6px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .titlebar { height: 34px; }
  .tb-btn { height: 26px; }
  .screen { padding: 10px 12px; gap: 12px; }
  h1 { font-size: 30px; } h2 { font-size: 24px; }
  p { margin-bottom: 6px; }
  .dek { font-size: 16px; }
  .ex { padding: 4px 8px; font-size: 15px; }
  .btn { min-height: 38px; font-size: 15px; padding: 4px 12px; box-shadow: 3px 3px 0 var(--k); }
  .side { width: 190px; gap: 8px; }
  .start-art { width: 110px; height: 110px; }
  .e-days { font-size: 22px; }
  .e-card { display: none; }
  .e-line { font-size: 15px; }

  .hm { grid-template-columns: minmax(0, 1fr) 176px; grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "title title" "main tools"; }
  .hm-title { height: 30px; font-size: 15px; }
  .hm-logo canvas { width: 16px; height: 16px; }
  .hm-tbtn { height: 24px; width: 28px; }
  .hm-tools { flex-direction: column; gap: 6px; padding: 6px 6px 6px 0; background: none; border: 0; }
  .hm-tools .meter { order: -1; margin: 0; padding: 0 2px; }
  .unread { font-size: 24px; }
  .u-label { font-size: 14px; }
  .hm-tools .act { flex: 1; min-height: 0; padding: 2px 8px; }
  .ico { display: none; }
  .lbl { font-size: 17px; }
  .hint { font-size: 12px; }
  .hm-main { display: block; padding: 6px; }
  .hm-folders, .hm-list { display: none; }
  .hm-right { display: block; height: 100%; }
  .stage { height: 100%; }
  .c-head { padding: 5px 10px; gap: 8px; }
  .avatar { width: 40px; height: 40px; font-size: 16px; }
  .c-fields { font-size: 13px; line-height: 1.35; }
  .c-subj { font-size: 15px; }
  .c-body { padding: 6px 10px; font-size: 16px; line-height: 1.3; }
  .c-badges { padding: 4px 10px 0; }
  .badge { font-size: 12px; }
  .stamp { font-size: 26px; }
  .gotmail { right: 6px; bottom: 6px; font-size: 16px; padding: 3px 10px 3px 4px; }
  .toast { bottom: 6px; left: 6px; right: 6px; padding: 4px 8px; font-size: 14px; }
}
@media (max-height: 330px) and (min-aspect-ratio: 1/1) {
  .how, #best-line, .keys, #r-prec { display: none; }
  .start-art { width: 80px; height: 80px; }
  .e-stats { font-size: 14px; }
  .titles li { padding: 2px 8px; }
  .hm-name span, .hm-folder::before { display: none; }
  .c-badges { display: none; }
  .c-fields > div:last-child { display: none; }
}
