/*
 * Kentō: the shared stylesheet of every screen.
 *
 * One file, three parts: the tokens (fonts, type scale, radii, shadows, spacing), the two themes
 * (Papier and Sumi), then the frame of the app (sidebar, page header, banner, footer, mobile tab
 * bar) and its few base controls. A screen writes a token name, never a colour value.
 *
 * The board design/socle/socle.html reads this file: change it here, and the board follows.
 */

/* ---------------------------------------------------------------- Fonts (served by the app) */

@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('./fonts/archivo-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('./fonts/archivo-latin-ext-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308,
    U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  src: url('./fonts/jetbrains-mono-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  src: url('./fonts/jetbrains-mono-latin-ext-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308,
    U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Zen Kaku Gothic New';
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url('./fonts/zen-kaku-gothic-new-latin-400-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Zen Kaku Gothic New';
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url('./fonts/zen-kaku-gothic-new-latin-ext-400-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF;
}
@font-face {
  font-family: 'Zen Kaku Gothic New';
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url('./fonts/zen-kaku-gothic-new-latin-500-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Zen Kaku Gothic New';
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url('./fonts/zen-kaku-gothic-new-latin-ext-500-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF;
}
@font-face {
  font-family: 'Zen Kaku Gothic New';
  font-style: normal;
  font-display: swap;
  font-weight: 700;
  src: url('./fonts/zen-kaku-gothic-new-latin-700-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Zen Kaku Gothic New';
  font-style: normal;
  font-display: swap;
  font-weight: 700;
  src: url('./fonts/zen-kaku-gothic-new-latin-ext-700-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF;
}
/* The two kanji of the mark, 見当, and nothing else of the Japanese subsets. */
@font-face {
  font-family: 'Zen Kaku Gothic New';
  font-style: normal;
  font-display: swap;
  font-weight: 700;
  src: url('./fonts/zen-kaku-gothic-new-ja115-700-normal.woff2') format('woff2');
  unicode-range: U+5F53;
}
@font-face {
  font-family: 'Zen Kaku Gothic New';
  font-style: normal;
  font-display: swap;
  font-weight: 700;
  src: url('./fonts/zen-kaku-gothic-new-ja117-700-normal.woff2') format('woff2');
  unicode-range: U+898B;
}

/* ---------------------------------------------------------------- Tokens */

:root {
  --font-ui: 'Archivo', 'Zen Kaku Gothic New', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Zen Kaku Gothic New', 'Archivo', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Type scale: size / line height. */
  --text-xs: 12px;
  --leading-xs: 16px;
  --text-sm: 13px;
  --leading-sm: 18px;
  --text-base: 14px;
  --leading-base: 20px;
  --text-md: 16px;
  --leading-md: 24px;
  --text-lg: 20px;
  --leading-lg: 28px;
  --text-xl: 24px;
  --leading-xl: 32px;
  --text-2xl: 32px;
  --leading-2xl: 40px;

  /* Spacing, on a 4 px grid. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Radii: a tag, a control, a card, a panel, a pill. */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-xl: 14px;
  --radius-pill: 999px;

  /* Heights of a control. 44 px on touch screens (WCAG 2.5.5). */
  --control-h: 36px;
  --control-h-touch: 44px;

  --sidebar-w: 240px;
  --content-max: 1200px;
  --tabbar-h: 64px;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --duration: 160ms;
}

/*
 * Papier, the day theme: washi paper, sumi ink, and four pigments of the ukiyo-e printer.
 * shu 朱 vermilion (action, alert), ai 藍 indigo (link, focus, information),
 * matsu 松 pine (success, fixed), kuchiba 朽葉 fallen leaf (warning, read only).
 * Every text pair is 4.5:1 or more, every border of a control 3:1 or more (see design/README.md).
 */
:root,
[data-theme='paper'] {
  color-scheme: light;
  --paper: #f5f0e6;
  --paper-raised: #fffcf5;
  --paper-sunken: #ebe4d6;
  --ink: #1d1b18;
  --ink-soft: #45413a;
  --ink-muted: #625b50;
  --line: #ddd4c3;
  --line-strong: #857c6d;
  --shu: #b3341c;
  --shu-strong: #8f2814;
  --shu-wash: #f7e1d8;
  --ai: #24497a;
  --ai-wash: #dfe7f1;
  --matsu: #2d6a3d;
  --matsu-wash: #dcebdd;
  --kuchiba: #7d520c;
  --kuchiba-wash: #f4e6c6;
  --on-shu: #fffcf5;
  --focus: #24497a;
  --shadow-1: 0 1px 2px rgb(29 27 24 / 0.06), 0 1px 1px rgb(29 27 24 / 0.04);
  --shadow-2: 0 6px 20px rgb(29 27 24 / 0.08), 0 2px 4px rgb(29 27 24 / 0.05);
}

/* Sumi, the night theme: the same pigments, lifted for a dark ground. */
[data-theme='sumi'] {
  color-scheme: dark;
  --paper: #171614;
  --paper-raised: #211f1c;
  --paper-sunken: #110f0e;
  --ink: #ede7da;
  --ink-soft: #d0c9ba;
  --ink-muted: #a69e8f;
  --line: #36332d;
  --line-strong: #7f7769;
  --shu: #f07b60;
  --shu-strong: #f6a08b;
  --shu-wash: #3b2019;
  --ai: #93b6e6;
  --ai-wash: #1d2839;
  --matsu: #8dc79b;
  --matsu-wash: #1b2c20;
  --kuchiba: #e3b660;
  --kuchiba-wash: #33280f;
  --on-shu: #171614;
  --focus: #93b6e6;
  --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-2: 0 8px 24px rgb(0 0 0 / 0.45), 0 2px 4px rgb(0 0 0 / 0.3);
}

/* « Appareil »: the theme of the device. Same values as Sumi. */
@media (prefers-color-scheme: dark) {
  [data-theme='system'] {
    color-scheme: dark;
    --paper: #171614;
    --paper-raised: #211f1c;
    --paper-sunken: #110f0e;
    --ink: #ede7da;
    --ink-soft: #d0c9ba;
    --ink-muted: #a69e8f;
    --line: #36332d;
    --line-strong: #7f7769;
    --shu: #f07b60;
    --shu-strong: #f6a08b;
    --shu-wash: #3b2019;
    --ai: #93b6e6;
    --ai-wash: #1d2839;
    --matsu: #8dc79b;
    --matsu-wash: #1b2c20;
    --kuchiba: #e3b660;
    --kuchiba-wash: #33280f;
    --on-shu: #171614;
    --focus: #93b6e6;
    --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-2: 0 8px 24px rgb(0 0 0 / 0.45), 0 2px 4px rgb(0 0 0 / 0.3);
  }
}

/* ---------------------------------------------------------------- Base */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: var(--leading-base);
  font-feature-settings: 'tnum' 1;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
}

p {
  margin: 0;
}

a {
  color: var(--ai);
  text-underline-offset: 2px;
}

code,
kbd,
.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

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

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -48px;
  z-index: 10;
  padding: var(--space-2) var(--space-4);
  background: var(--paper-raised);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
}
.skip-link:focus {
  top: var(--space-4);
}

/* ---------------------------------------------------------------- Mark */

.mark {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--ink);
  text-decoration: none;
}
.mark-glyph {
  flex: none;
  width: 28px;
  height: 28px;
  color: var(--shu);
}
.mark-notch {
  fill: none;
  stroke: var(--on-shu);
  stroke-width: 2.5;
  stroke-linecap: square;
}
.mark-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-lg);
  letter-spacing: -0.01em;
}
.mark-kanji {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-xs);
  color: var(--ink-muted);
  letter-spacing: 0.1em;
}

/* ---------------------------------------------------------------- Controls */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--control-h);
  padding: 0 var(--space-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--paper-raised);
  color: var(--ink);
  font: 600 var(--text-base) / 1 var(--font-ui);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
.button:hover {
  background: var(--paper-sunken);
}
.button-primary {
  background: var(--shu);
  border-color: var(--shu);
  color: var(--on-shu);
}
.button-primary:hover {
  background: var(--shu-strong);
  border-color: var(--shu-strong);
}
.button-ghost {
  border-color: transparent;
  background: transparent;
}
.button-large {
  min-height: var(--control-h-touch);
  padding: 0 var(--space-6);
  font-size: var(--text-md);
}
.button svg {
  width: 18px;
  height: 18px;
  flex: none;
}

/* Papier / Sumi / Appareil: three radios that look like one segmented control. */
.theme-switch {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}
.theme-switch legend {
  margin-bottom: var(--space-2);
  padding: 0;
  font-size: var(--text-xs);
  line-height: var(--leading-xs);
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--paper-sunken);
}
.segmented label {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 32px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}
.segmented input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.segmented label:has(input:checked) {
  background: var(--paper-raised);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line-strong), var(--shadow-1);
}
.segmented label:has(input:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
/* The « Appliquer » button of the switch serves a browser without JavaScript. */
.js .theme-switch .button {
  display: none;
}
.theme-switch .button {
  margin-top: var(--space-2);
  width: 100%;
}

/* ---------------------------------------------------------------- Frame of the app */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100dvh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  height: 100dvh;
  padding: var(--space-5) var(--space-4);
  border-right: 1px solid var(--line);
  background: var(--paper-sunken);
  overflow-y: auto;
}

.org {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--paper-raised);
}
.org-label {
  font-size: var(--text-xs);
  line-height: var(--leading-xs);
  color: var(--ink-muted);
}
.org-select {
  width: 100%;
  min-height: var(--control-h);
  margin: var(--space-1) 0 var(--space-2);
  padding: 0 var(--space-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--paper-raised);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
}
.who form {
  margin-left: auto;
}
.who .button-ghost {
  min-height: var(--control-h);
  padding: 0 var(--space-2);
  color: var(--ink-soft);
}
.org-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.nav ul {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.nav a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--control-h);
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  color: var(--ink-soft);
  font-weight: 500;
  text-decoration: none;
}
.nav a:hover {
  background: var(--paper);
  color: var(--ink);
}
.nav a[aria-current='page'] {
  background: var(--paper-raised);
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--shu), var(--shadow-1);
}
.nav svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: auto;
}

.who {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.avatar {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--line);
  object-fit: cover;
}
.who-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.who-login {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.who-role {
  font-size: var(--text-xs);
  line-height: var(--leading-xs);
  color: var(--ink-muted);
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: none;
}

.content {
  width: 100%;
  max-width: var(--content-max);
  padding: var(--space-8) var(--space-10) var(--space-10);
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.page-title {
  font-size: var(--text-2xl);
  line-height: var(--leading-2xl);
}
.page-lead {
  margin-top: var(--space-1);
  color: var(--ink-soft);
  font-size: var(--text-md);
  line-height: var(--leading-md);
}
.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* « Lecture seule »: a member reads, an admin of the org edits. */
.banner {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-left: 4px solid var(--kuchiba);
  border-radius: var(--radius-md);
  background: var(--kuchiba-wash);
  color: var(--ink);
}
.banner svg {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  color: var(--kuchiba);
}
.banner strong {
  font-weight: 700;
}
.banner-alert {
  border-left-color: var(--shu);
  background: var(--shu-wash);
}
.banner-alert svg {
  color: var(--shu);
}
.banner-info {
  border-left-color: var(--ai);
  background: var(--ai-wash);
}
.banner-info svg {
  color: var(--ai);
}

.card {
  padding: var(--space-6);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--paper-raised);
  box-shadow: var(--shadow-1);
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-8);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-xl);
  background: var(--paper-raised);
}
.empty h2 {
  font-size: var(--text-lg);
  line-height: var(--leading-lg);
}
.empty p {
  max-width: 60ch;
  color: var(--ink-soft);
}

.footer {
  margin-top: auto;
  padding: var(--space-6) var(--space-10);
  border-top: 1px solid var(--line);
  color: var(--ink-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
}

.tabbar {
  display: none;
}

/* ---------------------------------------------------------------- Tables, and the Repos screen (REV-9) */
/* `.tag` and `.hint` come from « Shared parts » (REV-10) below; the variants here only add a colour. */

.banner-ok {
  border-left-color: var(--matsu);
  background: var(--matsu-wash);
}
.banner-ok svg {
  color: var(--matsu);
}
.banner p {
  margin: 0;
}

.banner-confirm-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.banner-confirm-title {
  font-size: var(--text-md);
  line-height: var(--leading-md);
}
.banner-confirm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-1);
}

.button-small {
  min-height: 28px;
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
  white-space: nowrap;
}

.tag.tag-ok {
  background: var(--matsu-wash);
  color: var(--matsu);
}
.tag.tag-info {
  background: var(--ai-wash);
  color: var(--ai);
}
.tag.tag-quiet {
  background: var(--paper-sunken);
  color: var(--ink-muted);
}

.stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
}
.hint.hint-alert {
  color: var(--shu);
}
.hint.hint-ok {
  color: var(--matsu);
  font-weight: 600;
}

.repos-summary {
  margin-bottom: var(--space-3);
  color: var(--ink-soft);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--paper-raised);
  box-shadow: var(--shadow-1);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
  line-height: var(--leading-base);
}
.table th,
.table td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.table thead th {
  color: var(--ink-muted);
  font-size: var(--text-xs);
  line-height: var(--leading-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.table th:first-child,
.table td:first-child {
  padding-left: var(--space-4);
}
.table th:last-child,
.table td:last-child {
  padding-right: var(--space-4);
}
.table tbody tr:last-child > * {
  border-bottom: 0;
}
.table tbody tr:target {
  background: var(--ai-wash);
}
.table tbody th {
  font-weight: 600;
}
.repo-name {
  display: block;
  margin-bottom: var(--space-1);
  color: var(--ink);
  font-weight: 700;
  white-space: nowrap;
}
.row-action {
  text-align: right;
  white-space: nowrap;
}

.switch {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.switch-count {
  min-width: 4ch;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}
.switch-bar {
  appearance: none;
  width: 72px;
  height: 6px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--paper-sunken);
  overflow: hidden;
}
.switch-bar::-webkit-progress-bar {
  background: var(--paper-sunken);
  border-radius: var(--radius-pill);
}
.switch-bar::-webkit-progress-value {
  background: var(--ai);
  border-radius: var(--radius-pill);
}
.switch-bar::-moz-progress-bar {
  background: var(--ai);
  border-radius: var(--radius-pill);
}
.switch-done::-webkit-progress-value {
  background: var(--matsu);
}
.switch-done::-moz-progress-bar {
  background: var(--matsu);
}

.repos-notes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-6);
}
.note h2 {
  margin-bottom: var(--space-3);
  font-size: var(--text-md);
  line-height: var(--leading-md);
}
.note ul {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding-left: var(--space-5);
  color: var(--ink-soft);
}
.note code {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

/* Under 760 px a row of the table becomes a card: each cell under its column name. */
@media (max-width: 760px) {
  .table-wrap {
    overflow: visible;
    border: 0;
    background: none;
    box-shadow: none;
  }
  .table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .table,
  .table tbody {
    display: block;
  }
  /* A card: the name on top, the cells two by two, the action at the bottom. */
  .table tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3) var(--space-4);
    margin-bottom: var(--space-3);
    padding: var(--space-4);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--paper-raised);
  }
  .table th,
  .table td {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-1);
    min-width: 0;
    padding: 0;
    border: 0;
  }
  .table td::before {
    content: attr(data-label);
    color: var(--ink-muted);
    font-size: var(--text-xs);
    line-height: var(--leading-xs);
    font-weight: 600;
  }
  .table tbody th,
  .table .row-action {
    grid-column: 1 / -1;
  }
  .table tbody th {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-2);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--line);
  }
  .table .row-action::before {
    content: none;
  }
  .table tr > :first-child,
  .table tr > :last-child {
    padding-inline: 0;
  }
  .repo-name {
    margin: 0;
    font-size: var(--text-md);
  }
  .row-action {
    text-align: left;
  }
  .row-action .button {
    min-height: var(--control-h-touch);
  }
}

/* ---------------------------------------------------------------- Mobile (390 px and up to 760 px) */

@media (max-width: 760px) {
  .shell {
    display: block;
  }
  .sidebar {
    display: none;
  }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    min-height: 56px;
    padding: var(--space-2) var(--space-4);
    border-bottom: 1px solid var(--line);
    background: var(--paper-sunken);
  }
  .topbar .org-select {
  width: 100%;
  min-height: var(--control-h);
  margin: var(--space-1) 0 var(--space-2);
  padding: 0 var(--space-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--paper-raised);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
}
.who form {
  margin-left: auto;
}
.who .button-ghost {
  min-height: var(--control-h);
  padding: 0 var(--space-2);
  color: var(--ink-soft);
}
.org-name {
    font-size: var(--text-sm);
    color: var(--ink-soft);
  }
  .content {
    padding: var(--space-5) var(--space-4) var(--space-8);
  }
  .page-title {
    font-size: var(--text-xl);
    line-height: var(--leading-xl);
  }
  .page-lead {
    font-size: var(--text-base);
    line-height: var(--leading-base);
  }
  .footer {
    padding: var(--space-5) var(--space-4) calc(var(--tabbar-h) + var(--space-5));
  }
  .footer-settings {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
  }
  .tabbar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 5;
    display: block;
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--line);
    background: var(--paper-sunken);
  }
  .tabbar ul {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    margin: 0;
    padding: 0;
    list-style: none;
  }
  .tabbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: var(--tabbar-h);
    color: var(--ink-muted);
    font-size: 11px;
    line-height: 14px;
    font-weight: 600;
    text-decoration: none;
  }
  .tabbar a[aria-current='page'] {
    color: var(--shu);
  }
  .tabbar svg {
    width: 22px;
    height: 22px;
  }
}

@media (min-width: 761px) {
  .footer-settings {
    display: none;
  }
}

/* ---------------------------------------------------------------- Sign in */

.signin {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: var(--space-6) var(--space-4);
}
.signin-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  width: 100%;
  max-width: 420px;
  padding: var(--space-8);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--paper-raised);
  box-shadow: var(--shadow-2);
}
.signin-card h1 {
  font-size: var(--text-xl);
  line-height: var(--leading-xl);
}
.signin-card p {
  color: var(--ink-soft);
}
.signin-card .button {
  width: 100%;
}
.signin-note {
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
  color: var(--ink-muted);
}
.signin-foot {
  margin-top: var(--space-4);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
  color: var(--ink-muted);
  text-align: center;
}
@media (max-width: 480px) {
  .signin-card {
    padding: var(--space-6);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* ---------------------------------------------------------------- Shared parts: sections, tags, states, fields (REV-10) */

.section-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  font-size: var(--text-lg);
  line-height: var(--leading-lg);
}
.count {
  min-width: 24px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--paper-sunken);
  color: var(--ink-soft);
  font: 600 var(--text-sm) / 24px var(--font-ui);
  text-align: center;
}
.hint {
  color: var(--ink-soft);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
}
.tag {
  display: inline-flex;
  align-items: center;
  padding: 0 var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper-sunken);
  color: var(--ink-soft);
  font-size: var(--text-xs);
  line-height: 22px;
}

/* A state: a dot and a word. The word carries the meaning; the colour only repeats it. */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-pill);
  font: 600 var(--text-xs) / 22px var(--font-ui);
  white-space: nowrap;
}
.status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.status-online {
  background: var(--matsu-wash);
  color: var(--matsu);
}
.status-idle,
.status-wait {
  background: var(--kuchiba-wash);
  color: var(--kuchiba);
}
.status-stale,
.status-revoked {
  background: var(--paper-sunken);
  color: var(--ink-muted);
}
.status-alert {
  background: var(--shu-wash);
  color: var(--shu);
}

.button-danger {
  border-color: var(--shu);
  color: var(--shu);
}
.button-danger-solid {
  background: var(--shu);
  border-color: var(--shu);
  color: var(--on-shu);
}
.button-danger-solid:hover {
  background: var(--shu-strong);
  border-color: var(--shu-strong);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin: 0 0 var(--space-4);
  padding: 0;
  border: 0;
}
.field-label {
  font-weight: 600;
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
}
.field-hint {
  color: var(--ink-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
}
.field-error {
  color: var(--shu);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
}
.input {
  width: 100%;
  max-width: 420px;
  min-height: var(--control-h-touch);
  padding: 0 var(--space-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--paper-raised);
  color: var(--ink);
  font-size: var(--text-base);
}
.input[aria-invalid='true'] {
  border-color: var(--shu);
}
.choice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  max-width: 640px;
  padding: var(--space-2) 0;
  line-height: var(--leading-base);
}
.choice input {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 3px;
  accent-color: var(--shu);
}

/* ---------------------------------------------------------------- Runners (REV-10) */

.runner-section {
  margin-bottom: var(--space-8);
}
.runner-list {
  display: grid;
  gap: var(--space-3);
  list-style: none;
  margin: 0;
  padding: 0;
}
.runner {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--paper-raised);
  box-shadow: var(--shadow-1);
}
.runner-revoked {
  box-shadow: none;
  background: transparent;
}
.runner-expired {
  border-color: var(--shu);
}
.runner-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}
.runner-name {
  font-size: var(--text-md);
  line-height: var(--leading-md);
  overflow-wrap: anywhere;
}
.labels {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  list-style: none;
  margin: 0;
  padding: 0;
}
.labels-none {
  color: var(--ink-muted);
  font-size: var(--text-sm);
}
.runner-facts-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-3) var(--space-6);
  margin: 0;
}
.runner-facts-list dt,
.facts dt {
  color: var(--ink-muted);
  font-size: var(--text-xs);
  line-height: var(--leading-xs);
  letter-spacing: 0.02em;
}
.runner-facts-list dd,
.facts dd {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  overflow-wrap: anywhere;
}
.runner-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-2);
}
.confirm summary {
  list-style: none;
}
.confirm summary::-webkit-details-marker {
  display: none;
}
.confirm[open] summary {
  background: var(--shu-wash);
}
.confirm-body {
  display: grid;
  gap: var(--space-3);
  max-width: 560px;
  margin-top: var(--space-2);
  padding: var(--space-4);
  border: 1px solid var(--shu);
  border-radius: var(--radius-md);
  background: var(--paper);
}
.runner-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}
.facts dl {
  display: grid;
  gap: var(--space-3);
  margin: 0;
}
.token-card,
.new-runner {
  margin-bottom: var(--space-8);
}
.new-runner > .hint {
  margin-bottom: var(--space-4);
}
.token-card {
  display: grid;
  gap: var(--space-3);
  border-color: var(--shu);
}
.token-card .banner {
  margin-bottom: 0;
}
.copy-block {
  display: grid;
  gap: var(--space-2);
  justify-items: start;
}
.command {
  width: 100%;
  padding: var(--space-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--paper-sunken);
  color: var(--ink);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
  white-space: pre;
  overflow-x: auto;
  resize: vertical;
}
.copy-status {
  color: var(--ink-soft);
  font-size: var(--text-sm);
}

@media (max-width: 760px) {
  .runner {
    padding: var(--space-4);
  }
  .runner-facts {
    grid-template-columns: 1fr;
  }
  .runner-facts-list {
    grid-template-columns: 1fr 1fr;
  }
  .runner-actions .button,
  .confirm summary {
    min-height: var(--control-h-touch);
  }
}
