/* The layout, served at /layout.css (after /style.css): the navigation (a tab bar along the bottom
   on a phone, a side bar on a wide screen), one screen per job, and the parts of each screen
   (the sections of pages drawn from data, People, Log, Settings). Shared by page.html and
   page-shell.html. */

.skip-link { position: absolute; left: -999px; top: var(--space-2); z-index: 50; display: inline-flex; align-items: center; min-height: var(--touch); background: var(--surface); padding: var(--space-2) var(--space-4); border-radius: var(--radius-sm); }
.skip-link:focus { left: var(--space-2); }

/* ---- Navigation ---- */
.tabs {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-around; align-items: stretch;
  height: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--panel); border-top: 1px solid var(--border); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
}
.tabs .brand { display: none; }
.tabs a.tab {
  flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: var(--touch); color: var(--text-muted); text-decoration: none; font-size: 0.75rem; font-weight: 600;
  border-radius: 0;
}
.tabs a.tab svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a.tab:hover { color: var(--text); }
.tabs a.tab[aria-current="page"] { color: var(--accent); }
.tabs a.tab[aria-current="page"] svg { stroke-width: 2.2; }

main {
  max-width: var(--content); margin: 0 auto;
  padding: var(--space-5) var(--space-4) calc(var(--tabbar) + var(--space-7) + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 900px) {
  .tabs {
    top: 0; right: auto; width: var(--sidebar); height: auto; padding: var(--space-5) var(--space-3);
    flex-direction: column; justify-content: flex-start; gap: var(--space-1);
    border-top: 0; border-right: 1px solid var(--border);
  }
  .tabs .brand { display: block; font-weight: 700; font-size: var(--text-lg); color: var(--text); text-decoration: none; padding: 0 var(--space-3) var(--space-5); }
  .tabs a.tab { flex: none; flex-direction: row; justify-content: flex-start; gap: var(--space-3); min-height: var(--touch); padding: 0 var(--space-3); font-size: var(--text-md); border-radius: var(--radius-sm); }
  .tabs a.tab[aria-current="page"] { background: var(--accent-soft); color: var(--accent-soft-text); }
  main { margin-left: calc(var(--sidebar) + max(0px, (100vw - var(--sidebar) - var(--content)) / 2)); padding: var(--space-6) var(--space-5) var(--space-7); }
  .toast { bottom: var(--space-5); left: calc(50% + var(--sidebar) / 2); }
}

/* ---- Which parts show on which screen of the chat's page (nav.js sets body[data-view]) ---- */
body[data-view="today"] [data-show]:not([data-show~="today"]),
body[data-view="people"] [data-show]:not([data-show~="people"]),
body[data-view="log"] [data-show]:not([data-show~="log"]),
body[data-view="settings"] [data-show]:not([data-show~="settings"]) { display: none !important; }
/* The home pages: Today's on the Today screen, the setup page on Settings, none elsewhere. */
body[data-view="people"] #home, body[data-view="log"] #home { display: none; }
body[data-view="today"] #home > [data-page]:has(.sec-setup_form) { display: none; }
body[data-view="settings"] #home > [data-page]:not(:has(.sec-setup_form)) { display: none; }
/* Setup still to finish: a call-out on Today while the form is up and setup isn't done (the form
   has a Cancel only once setup is done). */
.callout { display: none; }
body[data-view="today"]:has(#home .setup-form) .callout { display: flex; }
body[data-view="today"]:has(#home [data-do="setup_cancel"]) .callout { display: none; }

/* ---- A screen ---- */
.view-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--space-2) var(--space-4); margin-bottom: var(--space-4); }
.view-head h1 { margin: 0; }
.lede { color: var(--text-muted); font-size: var(--text-sm); }
.section-title { font-size: var(--text-lg); margin: var(--space-6) 0 var(--space-3); }
.card > h2:first-child, .card > h3:first-child, .card > .section-title:first-child { margin-top: 0; }
.review:empty, .working:empty, .toast:empty, #message:empty { display: none; }
.working { font-size: var(--text-sm); color: var(--text-muted); }
.footnote { font-size: var(--text-xs); color: var(--text-muted); margin-top: var(--space-5); }
.footnote a { display: inline-flex; align-items: center; min-height: var(--touch); }
.crumbs { font-size: var(--text-sm); margin-bottom: var(--space-2); }
.crumbs a { display: inline-flex; align-items: center; min-height: var(--touch); }

.callout {
  align-items: center; gap: var(--space-4); padding: var(--space-4); margin-bottom: var(--space-4);
  border-radius: var(--radius); background: var(--accent-soft); color: var(--accent-soft-text); text-decoration: none;
}
.callout:hover { color: var(--accent-soft-text); }
.callout strong { display: block; font-size: var(--text-lg); }
.callout span { font-size: var(--text-sm); }
.callout::after { content: "\203A"; font-size: 1.75rem; margin-left: auto; }

/* ---- Sections of a page drawn from data (on / and at /p) ---- */
.sec { margin-bottom: var(--space-5); }
.sec > h2:first-child { margin-top: 0; }
/* This week's line: under Today's title, as a quiet summary */
.sec-metric_line { margin-bottom: var(--space-3); }
.sec-metric_line > h2 { font-size: var(--text-2xl); font-weight: 700; margin-bottom: var(--space-1); }
.week { display: inline-flex; padding: 2px 12px; border-radius: var(--radius-pill); background: var(--neutral-soft); color: var(--neutral-soft-text); font-size: var(--text-xs); font-weight: 600; }

/* A list with rows of its own (Today, Drafts): one card per row */
.row { display: grid; gap: var(--space-2); padding: var(--space-4); }
fieldset.row > legend.row-head { font-size: var(--text-lg); font-weight: 650; margin: 0; }
.row > p { margin: 0; }
.row-why { color: var(--accent-soft-text); background: var(--accent-soft); justify-self: start; padding: 2px 10px; border-radius: var(--radius-pill); font-size: var(--text-xs); font-weight: 600; }
.row-line { font-size: var(--text-sm); color: var(--text-muted); overflow-wrap: anywhere; }
.row .actions { margin-top: var(--space-1); }
.row .actions > button, .row .actions > a { flex: 1 1 8em; }
.row .actions > a { flex-basis: 100%; }
.row .actions > [data-do="act"] { order: 1; }
.row .actions > [data-do="copy"] { order: 2; }
.row .actions > [data-do="skip"] { order: 3; flex: 0 0 auto; }
.row .actions > .row-note { order: 4; flex-basis: 100%; font-size: var(--text-xs); color: var(--text-muted); font-style: normal; }
@media (min-width: 600px) {
  .row .actions > button, .row .actions > a { flex: 0 0 auto; }
  .row .actions > [data-do="ask"] { min-width: 8em; }
}
.sec > .lede + .row, .sec > .row + .row { margin-top: var(--space-3); }
/* A plain attention list */
.sec > ol { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-3); }
.sec > ol > li { background: var(--card-paint); border: var(--border-width) solid var(--card-border); border-radius: var(--radius); box-shadow: var(--shadow-1); padding: var(--space-4); }
.sec > ol > li > ul { list-style: none; padding: 0; margin: var(--space-2) 0 0; display: flex; flex-wrap: wrap; gap: var(--space-1); }
.sec > ol > li > ul > li { display: inline-flex; gap: var(--space-1); align-items: center; padding: 2px 10px; border-radius: var(--radius-pill); background: var(--neutral-soft); color: var(--neutral-soft-text); font-size: var(--text-xs); font-weight: 600; }
.sec > ol > li > ul > li small { color: inherit; font-weight: 500; }
.sec > ol > li button { margin: var(--space-2) var(--space-2) 0 0; }
.sec > table { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.sec h3 { margin-top: var(--space-4); }
/* Results: a card per week */
.week-card p { margin-bottom: var(--space-1); }
/* The setup form and the standing instructions */
.setup-form { margin-bottom: var(--space-4); }
.setup-form .field label { display: block; }
.redo a { display: inline-flex; align-items: center; min-height: var(--touch); font-weight: 600; }
.instructions { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-2); }
.instructions li { padding: var(--space-3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: var(--text-sm); }
.sec-setup_form > h2 { font-size: var(--text-lg); }

/* The confirm cards at /p: a sheet over the page, seen wherever the button was pressed */
.sheet:not(:empty) {
  position: fixed; z-index: 25; left: var(--space-2); right: var(--space-2);
  bottom: calc(var(--tabbar) + var(--space-2) + env(safe-area-inset-bottom, 0px));
  max-height: 75vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: var(--radius-lg); padding: var(--space-2); box-shadow: var(--shadow-2);
}
.sheet .confirm { margin: 0; }
@media (min-width: 900px) {
  .sheet:not(:empty) { left: auto; right: var(--space-5); bottom: var(--space-5); width: min(520px, calc(100vw - var(--sidebar) - 48px)); }
}

/* ---- People: search and records ---- */
.search { position: sticky; top: 0; z-index: 5; background: var(--panel); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border-radius: var(--radius-sm); padding: var(--space-2) 0 var(--space-3); }
.record { padding: var(--space-4); }
.record h3 { margin-bottom: var(--space-2); }
.record ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; font-size: var(--text-sm); color: var(--text-muted); overflow-wrap: anywhere; }
.group-title { font-size: var(--text-sm); text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin: var(--space-5) 0 var(--space-2); }

/* ---- Settings ---- */
.settings-group { margin-bottom: var(--space-4); }
fieldset.plain { border: 0; padding: 0; margin: 0 0 var(--space-4); background: none; box-shadow: none; }
fieldset.plain > legend { font-weight: 500; }
fieldset.plain.choices > label { display: flex; }

/* ---- Every link and box is at least 44 by 44 (a thumb); look-browser.test.ts measures it in a browser ---- */
main a[href], .sheet a[href], .empty a[href] { display: inline-flex; align-items: center; min-height: var(--touch); min-width: var(--touch); }
.tabs a.brand { display: none; }
@media (min-width: 900px) { .tabs a.brand { display: flex; align-items: center; min-height: var(--touch); } }
.tabs a.tab { min-width: 0; }
.tabs a.tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
input[type="file"] { min-height: var(--touch); padding: var(--space-2) 0; }
.empty a[href] { justify-content: center; margin: 0 var(--space-1); font-weight: 600; }
.account-line { display: flex; justify-content: flex-end; margin: 0; }
.account-line:has(button[hidden]) { display: none; }

/* ---- The sign-in pages (/login, /signup, /password; chat/auth/pages.ts) ---- */
body.auth main.auth-main { max-width: 440px; margin: 0 auto; padding: var(--space-6) var(--space-4) var(--space-7); }
.auth-brand { font-weight: 700; font-size: var(--text-lg); margin-bottom: var(--space-4); }
.auth-card h1 { font-size: var(--text-xl); }
.auth .actions > button { flex: 1 1 auto; }
.auth-after { margin-top: var(--space-4); text-align: center; color: var(--text-muted); }
.auth-message:empty, #authMessage:empty { display: none; }
.auth-message { margin: var(--space-3) 0 0; padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); border-left: 4px solid var(--danger); background: var(--danger-soft); color: var(--danger-soft-text); font-size: var(--text-sm); }
.auth-message[data-tone="note"] { border-left-color: var(--accent); background: var(--ok-soft); color: var(--ok-soft-text); } /* a line that isn't a refusal: "check your email" (supabase-page.js) */
