/* Pitch Machine. One stylesheet, no build step, phone first.
   Colours are variables so dark mode is a single block at the bottom. */

:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --text: #1c1c1a;
  --muted: #676660;
  --line: #e2dfd7;
  --accent: #1d5c86;
  --accent-hover: #174b6e;
  --accent-ink: #ffffff;
  --ok: #1b7343;
  --ok-bg: #e5f3ea;
  --warn: #8a5700;
  --warn-bg: #fdf1dc;
  --bad: #b0261c;
  --bad-bg: #fbe8e5;
  --info-bg: #e7f0f7;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 1px 1px rgba(0, 0, 0, .03);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
}
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: .2rem 0 1rem; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
p { margin: .4rem 0 .8rem; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2);
       border: 1px solid var(--line); border-radius: 4px; padding: 0 .3em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }

/* ---------- Top bar and navigation ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line);
          position: sticky; top: 0; z-index: 20; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between;
                max-width: 1180px; margin: 0 auto; padding: .55rem 16px 0; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; font-size: 1.05rem; }
.signout { margin: 0; }
.nav { display: flex; gap: .25rem; overflow-x: auto; max-width: 1180px; margin: 0 auto;
       padding: .35rem 12px .45rem; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { flex: 0 0 auto; color: var(--muted); text-decoration: none; padding: .4rem .7rem;
         border-radius: 999px; font-size: .95rem; }
.nav a.active { background: var(--info-bg); color: var(--accent); font-weight: 600; }
.nav .count { display: inline-block; min-width: 1.35rem; margin-left: .35rem; padding: 0 .35rem;
              border-radius: 999px; background: var(--accent); color: var(--accent-ink);
              font-size: .75rem; text-align: center; line-height: 1.35rem; font-weight: 600; }

.page { max-width: 1180px; margin: 0 auto; padding: 16px 16px 96px; }

/* ---------- Cards, boxes, messages ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
        box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card > :last-child { margin-bottom: 0; }
.flash { background: var(--ok-bg); color: var(--ok); border-radius: var(--radius);
         padding: .7rem 1rem; margin-bottom: 16px; font-weight: 500; }
.error-box { background: var(--bad-bg); color: var(--bad); border-radius: var(--radius);
             padding: .7rem 1rem; margin-bottom: 16px; }
.warn-box { background: var(--warn-bg); color: var(--warn); border-radius: var(--radius);
            padding: .7rem 1rem; margin-bottom: 16px; }
.info-box { background: var(--info-bg); border-radius: var(--radius); padding: .7rem 1rem;
            margin-bottom: 16px; }
.error-box ul, .warn-box ul { margin: .3rem 0 0; padding-left: 1.2rem; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
       min-height: 44px; padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--line);
       background: var(--surface); color: var(--text); font: inherit; font-weight: 600;
       cursor: pointer; text-decoration: none; touch-action: manipulation; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.go { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.armed { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn.small { min-height: 34px; padding: .3rem .7rem; font-size: .875rem; }
.btn.block { width: 100%; }
.mt { margin-top: 1rem; }
.linkish { background: none; border: 0; padding: .3rem; color: var(--muted); font: inherit;
           cursor: pointer; text-decoration: underline; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; margin: .8rem 0 .3rem; }
label .hint { font-weight: 400; color: var(--muted); font-size: .875rem; }
input[type=text], input[type=email], input[type=password], input[type=url],
input[type=search], input[type=number], select, textarea {
  width: 100%; font: inherit; font-size: 16px; /* 16px stops iPhone zooming in */
  color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: .6rem .7rem; }
textarea { min-height: 6rem; resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.stack > * + * { margin-top: .6rem; }
.field-note { color: var(--muted); font-size: .85rem; margin-top: .25rem; }
.checkbox { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
.checkbox input { width: 1.2rem; height: 1.2rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.data th, table.data td { text-align: left; padding: .55rem .5rem;
                               border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em;
                color: var(--muted); font-weight: 600; }
table.data td.num, table.data th.num { text-align: right; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: .08rem .5rem; border-radius: 999px; font-size: .78rem;
         font-weight: 600; background: var(--surface-2); border: 1px solid var(--line);
         color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.badge.info { background: var(--info-bg); color: var(--accent); border-color: transparent; }

/* ---------- Home ---------- */
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { padding: .5rem 0; border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 0; }
.checklist .tick { display: inline-block; width: 1.4rem; font-weight: 700; }
.checklist .done .tick { color: var(--ok); }
.checklist .todo .tick { color: var(--warn); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px;
         margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
        padding: 12px 14px; text-decoration: none; color: var(--text); box-shadow: var(--shadow); }
.tile .n { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.tile .t { color: var(--muted); font-size: .9rem; }
.tile.hot { border-color: var(--accent); }
.limits-bar { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; align-items: center;
              background: var(--surface); border: 1px solid var(--line);
              border-radius: var(--radius); padding: .6rem .9rem; margin-bottom: 16px;
              font-size: .95rem; }
.limits-bar strong { font-variant-numeric: tabular-nums; }

/* ---------- Progress ---------- */
.progress { height: 10px; background: var(--surface-2); border: 1px solid var(--line);
            border-radius: 999px; overflow: hidden; margin: .4rem 0; }
.progress > span { display: block; height: 100%; background: var(--accent); width: 0;
                   transition: width .4s ease; }
.progress > span.indeterminate { width: 35%; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }
.result ul { margin: .3rem 0 0; padding-left: 1.2rem; }

/* ---------- Discover ---------- */
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .8rem;
        border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
        font-weight: 500; cursor: pointer; user-select: none; }
.chip input { width: 1.05rem; height: 1.05rem; margin: 0; }

/* ---------- Shows list ---------- */
.filters { display: flex; gap: .35rem; overflow-x: auto; padding-bottom: .35rem;
           margin-bottom: .6rem; scrollbar-width: thin; }
.filters a { flex: 0 0 auto; padding: .35rem .75rem; border-radius: 999px; text-decoration: none;
             color: var(--muted); border: 1px solid var(--line); background: var(--surface);
             font-size: .9rem; }
.filters a.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.show-list { list-style: none; margin: 0; padding: 0; }
.show-row { display: flex; gap: .75rem; padding: .75rem .25rem; border-bottom: 1px solid var(--line); }
.show-row:last-child { border-bottom: 0; }
.show-row .pick { padding-top: .2rem; }
.show-row .pick input { width: 1.25rem; height: 1.25rem; }
.show-row .main { flex: 1; min-width: 0; }
.show-row .title { font-weight: 600; color: var(--text); text-decoration: none; }
.show-row .meta { color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.bulkbar { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line);
           padding: .6rem 0; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; z-index: 10; }

/* ---------- Show detail and review ---------- */
.two-col { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) {
  .two-col { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: start; }
  .two-col .sticky-col { position: sticky; top: 110px; }
  .phone-only { display: none; }
}
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .9rem; margin: 0; }
dl.facts dt { color: var(--muted); font-size: .9rem; }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
.episode { padding: .6rem 0; border-top: 1px solid var(--line); }
.episode .ep-title { font-weight: 600; }
.episode .ep-desc { color: var(--muted); font-size: .9rem; }
details > summary { cursor: pointer; font-weight: 600; padding: .3rem 0; }
.timeline { list-style: none; padding: 0; margin: 0; font-size: .9rem; }
.timeline li { padding: .35rem 0; border-bottom: 1px dashed var(--line); }

.draft-subject { font-weight: 600; }
.draft-body { min-height: 16rem; }
.checks { list-style: none; padding: 0; margin: .5rem 0 0; font-size: .9rem; }
.checks li { padding: .15rem 0; }
.checks .pass::before { content: "\2713  "; color: var(--ok); font-weight: 700; }
.checks .warn::before { content: "!  "; color: var(--warn); font-weight: 700; }
.checks .block::before { content: "\2715  "; color: var(--bad); font-weight: 700; }
.checks .block { color: var(--bad); }
.counter { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.counter.over { color: var(--bad); font-weight: 600; }
.signature-preview { white-space: pre-wrap; color: var(--muted); font-size: .9rem;
                     border-left: 3px solid var(--line); padding-left: .7rem; margin-top: .6rem; }
.actionbar { position: sticky; bottom: 0; z-index: 15; background: var(--surface);
             border-top: 1px solid var(--line); margin: 16px -16px 0; padding: .7rem 16px
             calc(.7rem + env(safe-area-inset-bottom)); display: flex; flex-wrap: wrap; gap: .5rem; }
.actionbar .btn { flex: 1 1 auto; }
.actionbar .send-btn { flex: 2 1 12rem; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-bottom: .8rem;
         gap: .5rem; flex-wrap: wrap; }
.result { margin-top: .6rem; }
.quote { white-space: pre-wrap; background: var(--surface-2); border-radius: 8px;
         padding: .6rem .8rem; font-size: .92rem; }

/* ---------- Login ---------- */
.login-wrap { max-width: 400px; margin: 12vh auto 0; }
.login-title { font-size: 1.8rem; margin-bottom: .2rem; }

@media (min-width: 700px) {
  .page { padding: 24px 24px 96px; }
  .actionbar { margin: 16px 0 0; border: 1px solid var(--line); border-radius: var(--radius); }
}

/* ---------- Dark mode, following the phone or computer setting ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151514;
    --surface: #1e1e1c;
    --surface-2: #252523;
    --text: #ecebe6;
    --muted: #a3a29b;
    --line: #34332f;
    --accent: #6db3e3;
    --accent-hover: #8cc5ec;
    --accent-ink: #0d2233;
    --ok: #6fd39a;
    --ok-bg: #173323;
    --warn: #f0b95b;
    --warn-bg: #3a2c12;
    --bad: #ff8a80;
    --bad-bg: #3d1a17;
    --info-bg: #1b2d3b;
    --shadow: none;
  }
  .btn.go { color: #0f2a1b; }
  .btn.armed { color: #2b0d0a; }
}
