:root {
  --ink: #14213d;
  --paper: #fffdf6;
  --desk: #e7e2d6;
  --line: #7d786b;
  --go: #17783a;
  --go-d: #0d5326;
  --stop: #b3261e;
  --stop-d: #7f1711;
  --wait: #8a5a00;
  --wait-d: #5e3d00;
  --key: #ffffff;
  --key-b: #36425c;
  --mark: #ffe98a;
  --size: 24px;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 20px;
  line-height: 1.35;
  color: var(--ink);
  background: var(--desk);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
  overflow-y: auto;            /* only scrolls on a very short screen, so no button is ever cut off */
}

.hide { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------ main screen */

#app {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 62rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
}

.top { display: flex; align-items: stretch; gap: 10px; flex: none; }
.top .btn { flex: none; min-height: 62px; min-width: 6.2rem; }

.banner {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-size: 1.05rem;
  font-weight: 600;
}
.banner.on { background: var(--stop); border-color: var(--stop-d); color: #fff; font-size: 1.2rem; letter-spacing: 0.02em; }
.banner.on::before {
  content: "";
  flex: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  animation: pulse 1.2s ease-in-out infinite;
}
.banner.wait { background: #fff4d6; border-color: var(--wait); }
.banner.note { background: #e3f3e7; border-color: var(--go); }
.banner.warn { background: #fde7e5; border-color: var(--stop); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .banner.on::before { animation: none; } }

.paperwrap { flex: 1 1 auto; min-height: 9rem; display: flex; }

#page, .paper {
  font-family: Georgia, "Times New Roman", serif;
  font-size: var(--size);
  line-height: 1.5;
  color: #111;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}
#page {
  flex: 1 1 auto;
  width: 100%;
  resize: none;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.08);
  -webkit-appearance: none;
  appearance: none;
}
#page::placeholder { color: #6b6658; opacity: 1; }
#page:focus { outline: 4px solid #2b5fa8; outline-offset: 0; }
#page.on { border-color: var(--stop); box-shadow: 0 0 0 3px var(--stop), inset 0 2px 6px rgba(0, 0, 0, 0.08); }

.controls { flex: none; display: flex; flex-direction: column; gap: 10px; }

.row { display: flex; flex-wrap: wrap; gap: 10px; }
.row > .btn { flex: 1 1 9.4rem; }

/* ---------------------------------------------------------------- buttons */

.btn {
  font: inherit;
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1.2;
  min-height: 62px;
  padding: 8px 14px;
  color: var(--ink);
  background: var(--key);
  border: 3px solid var(--key-b);
  border-bottom-width: 6px;
  border-radius: 14px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
.btn:active { transform: translateY(2px); border-bottom-width: 4px; margin-bottom: 2px; }
.btn:focus-visible { outline: 4px solid #2b5fa8; outline-offset: 2px; }
.btn[disabled] { opacity: 0.45; cursor: default; }

.btn.go { color: #fff; background: var(--go); border-color: var(--go-d); }
.btn.stop { color: #fff; background: var(--stop); border-color: var(--stop-d); }
.btn.wide { width: 100%; }

.mic {
  width: 100%;
  min-height: 86px;
  font-size: 1.55rem;
  letter-spacing: 0.03em;
  color: #fff;
  background: var(--go);
  border-color: var(--go-d);
}
.mic.on { background: var(--stop); border-color: var(--stop-d); }
.mic.wait { background: var(--wait); border-color: var(--wait-d); }

/* ----------------------------------------------------------------- panels */

.panel {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: var(--desk);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.panel[hidden] { display: none; }

.phead {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  max-width: 62rem;
  margin: 0 auto;
  padding: 12px;
  background: var(--desk);
  border-bottom: 3px solid var(--key-b);
}
.phead h2 { margin: 0; font-size: 1.6rem; flex: 1 1 10rem; }
.phead .back { flex: none; min-width: 7.5rem; }
.phead .back::before { content: "\2190\00a0"; }

.pbody { max-width: 62rem; margin: 0 auto; padding: 16px 12px 40px; display: flex; flex-direction: column; gap: 14px; }

.lead { margin: 0; font-size: 1.25rem; font-weight: 600; }
.note { margin: 0; font-size: 1.1rem; }

.choice {
  width: 100%;
  min-height: 84px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  text-align: left;
  padding: 12px 18px;
}
.choice b { font-size: 1.35rem; }
.choice span { font-size: 1.02rem; font-weight: 500; color: #3c4257; }

.sizer { display: flex; flex-direction: column; gap: 10px; padding: 14px; background: #f4f0e6; border: 2px solid var(--line); border-radius: 14px; }
.sample { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: var(--size); line-height: 1.4; overflow-wrap: anywhere; }

.step { display: flex; flex-direction: column; gap: 10px; padding: 14px; background: #f4f0e6; border: 2px solid var(--line); border-radius: 14px; }
.num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.1rem; height: 2.1rem; margin-right: 6px;
  border-radius: 50%;
  background: var(--ink); color: #fff; font-weight: 700;
}
.heard { margin: 0; font-size: 1.25rem; overflow-wrap: anywhere; }
.heard b { font-family: Georgia, "Times New Roman", serif; }

.field {
  width: 100%;
  min-height: 64px;
  font: inherit;
  font-size: 1.5rem;
  padding: 10px 14px;
  color: #111;
  background: #fff;
  border: 3px solid var(--key-b);
  border-radius: 12px;
}
.field:focus { outline: 4px solid #2b5fa8; outline-offset: 0; }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.list li {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  padding: 12px 14px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 14px;
}
.list .what { flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; }
.list .what b { display: block; font-size: 1.3rem; font-family: Georgia, "Times New Roman", serif; }
.list .what span { display: block; font-size: 1.02rem; color: #3c4257; }
.list .btn { flex: 0 1 auto; min-width: 6.5rem; }
.list.plain li { flex-wrap: nowrap; align-items: flex-start; font-size: 1.15rem; font-weight: 600; }
.list.plain li .dot { margin-top: 5px; }
.list.plain li span:last-child { flex: 1 1 auto; min-width: 0; }
.list .empty { justify-content: center; font-size: 1.15rem; background: transparent; border-style: dashed; }

.dot { flex: none; width: 18px; height: 18px; border-radius: 50%; background: #9a9a9a; }
.dot.yes { background: var(--go); }

.preview { white-space: pre-wrap; overflow-wrap: anywhere; }
.preview mark { background: var(--mark); color: inherit; padding: 0 2px; border-radius: 3px; }

/* The voice command card */
.card h3 { margin: 18px 0 8px; font-size: 1.35rem; }
.card table { width: 100%; border-collapse: collapse; background: #fff; border: 2px solid var(--line); }
.card th, .card td { text-align: left; vertical-align: top; padding: 10px 12px; border-bottom: 1px solid #c9c4b6; font-size: 1.12rem; }
.card th { width: 52%; font-weight: 700; }
.card td { font-family: Georgia, "Times New Roman", serif; overflow-wrap: anywhere; }
.card tr:last-child th, .card tr:last-child td { border-bottom: 0; }
.card .tip { margin: 8px 0 0; font-size: 1.05rem; }

/* ------------------------------------------------------------------ print */

#printArea { display: none; }

@media print {
  body { background: #fff; overflow: visible; font-size: 12pt; }
  #app, .panel { display: none !important; }
  #printArea { display: block; color: #000; }
  #printArea .text { white-space: pre-wrap; overflow-wrap: anywhere; font-family: Georgia, "Times New Roman", serif; font-size: 13pt; line-height: 1.5; }
  #printArea h1 { font-size: 20pt; margin: 0 0 6pt; }
  #printArea .card h3 { font-size: 14pt; margin: 12pt 0 4pt; break-after: avoid; }
  #printArea .card table { border: 1pt solid #000; break-inside: avoid; }
  #printArea .card th, #printArea .card td { font-size: 12pt; padding: 4pt 6pt; border-bottom: 0.5pt solid #777; }
  @page { margin: 20mm; }
}
