/* Sterling X Web — the desktop app's graphite and silver
   (app/renderer/style.css): the same tokens and controls, light or dark
   as the system says. The only accent is the silver itself (primary
   buttons, the selected tab); other colour carries state. */

:root {
  color-scheme: light;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --text: #17181b;
  --text-2: #5c5f67;
  --text-3: #8b8e96;
  --window: #eceef1;
  --surface: #f8f8fa;
  --surface-edge: rgba(0, 0, 0, 0.085);
  --tile: #ffffff;
  --field: #f2f3f5;
  --field-border: rgba(0, 0, 0, 0.12);
  --track: rgba(0, 0, 0, 0.055);
  --hairline: rgba(0, 0, 0, 0.07);
  --hover: rgba(0, 0, 0, 0.045);
  --press: rgba(0, 0, 0, 0.085);
  --accent: #202226;
  --accent-hover: #383b42;
  --on-accent: #f7f8fa;
  --focus: rgba(32, 34, 38, 0.35);
  --ok: #1e8a4c;
  --warn: #9e5a00;
  --bad: #c62f22;
  --ok-tint: rgba(30, 138, 76, 0.1);
  --warn-tint: rgba(158, 90, 0, 0.1);
  --bad-tint: rgba(198, 47, 34, 0.09);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 8px 28px rgba(0, 0, 0, 0.06);
  --seg-selected: #ffffff;
  --seg-shadow: 0 0.5px 1px rgba(0, 0, 0, 0.14), 0 1px 3px rgba(0, 0, 0, 0.06);
  --radius-surface: 12px;
  --radius-control: 8px;
  --control-h: 30px;
}

/* 外観: the system's, unless the person chose one (設定 → 一般). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --text: #ebecef;
    --text-2: #a2a5ad;
    --text-3: #6f727a;
    --window: #0d0e10;
    --surface: #131417;
    --surface-edge: rgba(255, 255, 255, 0.075);
    --tile: #191a1e;
    --field: #0e0f12;
    --field-border: rgba(255, 255, 255, 0.1);
    --track: rgba(255, 255, 255, 0.06);
    --hairline: rgba(255, 255, 255, 0.06);
    --hover: rgba(255, 255, 255, 0.045);
    --press: rgba(255, 255, 255, 0.085);
    --accent: #dcdfe5;
    --accent-hover: #eef0f3;
    --on-accent: #121316;
    --focus: rgba(220, 223, 229, 0.45);
    --ok: #4cc584;
    --warn: #e7a84f;
    --bad: #f0705f;
    --ok-tint: rgba(76, 197, 132, 0.13);
    --warn-tint: rgba(231, 168, 79, 0.13);
    --bad-tint: rgba(240, 112, 95, 0.13);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 32px rgba(0, 0, 0, 0.32);
    --seg-selected: rgba(255, 255, 255, 0.11);
    --seg-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.14), 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --text: #ebecef;
  --text-2: #a2a5ad;
  --text-3: #6f727a;
  --window: #0d0e10;
  --surface: #131417;
  --surface-edge: rgba(255, 255, 255, 0.075);
  --tile: #191a1e;
  --field: #0e0f12;
  --field-border: rgba(255, 255, 255, 0.1);
  --track: rgba(255, 255, 255, 0.06);
  --hairline: rgba(255, 255, 255, 0.06);
  --hover: rgba(255, 255, 255, 0.045);
  --press: rgba(255, 255, 255, 0.085);
  --accent: #dcdfe5;
  --accent-hover: #eef0f3;
  --on-accent: #121316;
  --focus: rgba(220, 223, 229, 0.45);
  --ok: #4cc584;
  --warn: #e7a84f;
  --bad: #f0705f;
  --ok-tint: rgba(76, 197, 132, 0.13);
  --warn-tint: rgba(231, 168, 79, 0.13);
  --bad-tint: rgba(240, 112, 95, 0.13);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 32px rgba(0, 0, 0, 0.32);
  --seg-selected: rgba(255, 255, 255, 0.11);
  --seg-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.14), 0 1px 2px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font: 13px/1.45 var(--font);
  color: var(--text);
  background: var(--window);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
a { color: inherit; }
h1, h2 { font-size: 13px; font-weight: 600; margin: 0; }

.spacer { flex: 1; }
.muted { color: var(--text-2); }
.num { font-variant-numeric: tabular-nums; }
.error { color: var(--bad); font-size: 12px; margin: 0; }
.error:empty { display: none; }
.hint { font-size: 11.5px; color: var(--text-2); }
.status-line { font-size: 12px; color: var(--text-2); margin: 0; min-height: 17px; }
.status-line.is-error { color: var(--bad); }
.status-line.is-ok { color: var(--ok); }

.badge {
  display: inline-block;
  font-size: 11px;
  line-height: 18px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--track);
  color: var(--text-2);
  white-space: nowrap;
}
.badge.ok { background: var(--ok-tint); color: var(--ok); }
.badge.warn { background: var(--warn-tint); color: var(--warn); }
.badge.bad { background: var(--bad-tint); color: var(--bad); }

/* --- controls (as the desktop app) ------------------------------------------ */

input, select, textarea {
  font: 13px var(--font);
  color: var(--text);
  background: var(--field);
  border: 0.5px solid var(--field-border);
  border-radius: var(--radius-control);
  padding: 5px 10px;
  min-height: var(--control-h);
  min-width: 0;
}
textarea { resize: vertical; line-height: 1.55; padding: 8px 11px; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
/* A search field shows it is one (its name is in aria-label). */
input[type="search"] {
  padding-left: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14' fill='none' stroke='%238b8e96' stroke-width='1.5'%3E%3Ccircle cx='6' cy='6' r='4.5'/%3E%3Cpath d='M9.5 9.5L13 13' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 11px center;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; border-color: transparent; }
input:disabled, select:disabled, textarea:disabled { opacity: 0.5; }
select { padding-right: 26px; }

button {
  font: 500 13px var(--font);
  color: var(--text);
  background: var(--tile);
  border: 0.5px solid var(--field-border);
  border-radius: var(--radius-control);
  padding: 0 13px;
  height: var(--control-h);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button:active:not(:disabled) { filter: brightness(0.96); }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: var(--accent); border-color: transparent; color: var(--on-accent); font-weight: 600; }
button.danger { color: var(--bad); }
button.danger-fill { background: var(--bad); border-color: transparent; color: #fff; font-weight: 600; }
button.link {
  background: none;
  border: none;
  height: 26px;
  padding: 0 8px;
  color: var(--text-2);
  font-size: 12px;
}
/* Hover only where there is a pointer that hovers: on a phone a tapped
   button would keep it. */
@media (hover: hover) {
  button:hover:not(:disabled) { background: var(--press); }
  button.primary:hover:not(:disabled) { background: var(--accent-hover); }
  button.link:hover:not(:disabled) { color: var(--text); background: var(--hover); }
  button.link.danger:hover:not(:disabled) { color: var(--bad); }
  button.chip:hover:not(:disabled) { color: var(--text); background: var(--hover); }
  .seg-radio label:hover { color: var(--text); }
  .segmented [role="tab"]:hover:not([aria-selected="true"]) { color: var(--text); background: var(--hover); }
  .grid tbody tr:hover td { background: var(--hover); }
  a.nav-item:hover:not([aria-current="page"]) { color: var(--text); background: var(--hover); }
  button.nav-add:hover:not(:disabled), button.menu-button:hover:not(:disabled), button.avatar:hover:not(:disabled) { color: var(--text); background: var(--hover); }
  a.plan-chip:hover { background: var(--press); }
  button.group-action:hover:not(:disabled) { background: var(--hover); }
}
@media (hover: none) {
  button:active:not(:disabled) { filter: none; background: var(--press); }
  button.primary:active:not(:disabled) { background: var(--accent-hover); }
  button.danger-fill:active:not(:disabled) { filter: brightness(0.9); }
}

label { display: flex; flex-direction: column; gap: 5px; color: var(--text-2); font-size: 12px; }
label > input, label > select, label > textarea { color: var(--text); font-size: 13px; }
label.compact { flex-direction: row; align-items: center; gap: 8px; }
label.check { flex-direction: row; align-items: center; gap: 7px; color: var(--text); font-size: 13px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); margin: 0; width: 14px; height: 14px; min-height: 0; }
input[type="number"] { width: 84px; }
input[type="file"] { padding: 4px 6px; background: transparent; border-style: dashed; max-width: 100%; }

.field-row { display: flex; align-items: flex-end; gap: 10px 14px; flex-wrap: wrap; }
.field-row.grow > label:not(.check) { flex: 1 1 220px; }
.field-row.grow > label:has(> select, > input[type="number"]) { flex: 0 1 auto; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { color: var(--text-2); font-size: 12px; }
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.field-row > label.grow { flex: 1 1 260px; }
.tab-count { margin-left: 6px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 11px; line-height: 16px; }
.stack.narrow { max-width: 520px; }
.panel.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 22px 28px; align-content: start; }
/* A group of rows (the iPhone's grouped lists): white and rounded, rows
   split by a line that starts where the text does. */
.group { background: var(--tile); border: 0.5px solid var(--surface-edge); border-radius: 12px; overflow: hidden; }
.group-row { position: relative; display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 9px 14px; min-width: 0; }
.group-row + .group-row::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; border-top: 0.5px solid var(--hairline); }
.group-row .value { margin-left: auto; flex: none; color: var(--text-2); text-align: right; }
.group-row .value.bad, .group-row .bad { color: var(--bad); }
.group-row .grow { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.group-row .meta { color: var(--text-2); font-size: 12px; }
.group-row .main { min-width: 0; overflow-wrap: anywhere; }
.group-row .split { display: flex; align-items: baseline; gap: 12px; }
.group-row.two-line { flex-direction: column; align-items: stretch; gap: 3px; }
.group-row.two-line meter { width: 100%; }
.group-row.attention .main { color: var(--bad); }
.group-row.quiet { color: var(--text-2); }
.group-head { display: flex; align-items: baseline; gap: 8px; margin: 0 0 8px; }
.group-head h2 { margin: 0; }
.group-head .more { margin-left: auto; color: var(--text-2); text-decoration: none; font-size: 12.5px; }
.group-foot { margin: 7px 2px 0; color: var(--text-2); font-size: 12px; }
.group-foot .bad { color: var(--bad); }
.group-foot .warn { color: var(--warn); }
.home-block { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.mini-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.mini-list li { display: flex; gap: 10px; align-items: baseline; min-width: 0; }
.mini-list .when { flex: none; color: var(--text-2); }
.mini-list .who { flex: none; max-width: 12em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-list .what { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-list .bad { color: var(--bad); }
.mini-list meter { flex: 1; min-width: 60px; }
pre.code { margin: 0; padding: 12px 14px; border-radius: var(--radius-control); background: var(--field); font-family: var(--mono); font-size: 12px; overflow-x: auto; }
code.secret { font-family: var(--mono); font-size: 12.5px; word-break: break-all; user-select: all; }
.notes { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.notes li.unread { font-weight: 600; }
.facts-table th { width: 12em; text-align: left; font-weight: 400; color: var(--text-2); }
tr.is-selected td { background: var(--hover); }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
fieldset.checks { border: none; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
fieldset.checks legend { padding: 0; margin-bottom: 6px; color: var(--text-2); font-size: 12px; }
.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px 14px; width: 100%; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
button.chip {
  height: 26px;
  padding: 0 11px;
  border-radius: 999px;
  border: 0.5px solid var(--field-border);
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
}
button.chip[aria-pressed="true"] { background: var(--seg-selected); color: var(--text); border-color: var(--field-border); box-shadow: var(--seg-shadow); }
button.chip .n { color: var(--text-3); font-variant-numeric: tabular-nums; }

/* Radio choices drawn as a segmented control. */
.seg-radio { display: inline-flex; gap: 2px; padding: 3px; background: var(--track); border-radius: 999px; align-self: flex-start; }
.seg-radio label { position: relative; flex-direction: row; align-items: center; height: 26px; padding: 0 14px; border-radius: 999px; color: var(--text-2); font-size: 12.5px; font-weight: 500; white-space: nowrap; cursor: pointer; }
.seg-radio input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.seg-radio label:has(input:checked) { background: var(--seg-selected); color: var(--text); box-shadow: var(--seg-shadow); }
.seg-radio label:has(input:focus-visible) { outline: 3px solid var(--focus); }

.stack { display: flex; flex-direction: column; gap: 12px; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--track);
  border-radius: 999px;
}
.segmented [role="tab"] {
  border: none;
  background: transparent;
  color: var(--text-2);
  font: 500 13px var(--font);
  height: 26px;
  padding: 0 13px;
  border-radius: 999px;
}
.segmented [role="tab"][aria-selected="true"] { background: var(--seg-selected); color: var(--text); box-shadow: var(--seg-shadow); }

/* --- brand and the bar ---------------------------------------------------------- */

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
/* The X in a small outlined square, as on the desktop. */
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border: 1.5px solid currentColor;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

/* Wide screens: every screen in a sidebar on the left, the page on the right. */
.shell { display: grid; grid-template-columns: 208px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 10px 16px max(10px, env(safe-area-inset-left));
}
.sidebar > .brand { min-height: 24px; padding: 0 10px; }
.nav-groups { display: flex; flex-direction: column; }
.nav-group { display: flex; flex-direction: column; gap: 1px; padding: 8px 0; }
.nav-group + .nav-group { border-top: 0.5px solid var(--hairline); }
a.nav-item {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-control);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
a.nav-item[aria-current="page"] { background: var(--track); color: var(--text); font-weight: 650; }
a.nav-item .tab-count { margin-left: auto; }
.nav-row { display: flex; align-items: center; gap: 2px; }
.nav-row > a.nav-item { flex: 1; min-width: 0; }
button.nav-add { flex: none; width: 32px; height: 32px; min-height: 0; padding: 0; border: none; background: none; color: var(--text-2); }
.page { min-width: 0; }

.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 max(16px, env(safe-area-inset-right)) 0 18px;
}
.bar-title { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 650; }
button.menu-button { display: none; }
/* The contract: its plan (and how it stands when not as usual); a way to 契約. */
a.plan-chip {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--track);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 28px;
  text-decoration: none;
}
a.plan-chip.is-warn { background: var(--warn-tint); color: var(--warn); }
/* The person signed in: the first letter of the address in a circle. */
button.avatar { flex: none; width: 36px; height: 36px; min-height: 0; padding: 0; border: none; border-radius: 50%; background: none; }
.avatar-mark {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 13.5px;
  font-weight: 650;
  line-height: 1;
}

main.surface {
  margin: 0 max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) 0;
  min-height: calc(100vh - 68px);
  background: var(--surface);
  border: 0.5px solid var(--surface-edge);
  border-radius: var(--radius-surface);
  box-shadow: var(--shadow);
  padding: 16px 18px 28px;
}
.panel { display: flex; flex-direction: column; gap: 14px; max-width: 980px; }
.panel h2 { margin-top: 10px; }

.notice {
  border-radius: var(--radius-control);
  padding: 9px 12px;
  font-size: 12.5px;
  background: var(--warn-tint);
  color: var(--warn);
  max-width: 980px;
  margin-bottom: 14px;
}

/* --- tables ----------------------------------------------------------------------- */

/* A wide table scrolls inside its box; a hidden column name stays in it too. */
.table-scroll { position: relative; overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; }
.grid th {
  text-align: left;
  font-weight: 500;
  color: var(--text-3);
  font-size: 11.5px;
  border-bottom: 0.5px solid var(--hairline);
  padding: 6px 10px;
  white-space: nowrap;
}
.grid td { border-bottom: 0.5px solid var(--hairline); padding: 8px 10px; vertical-align: top; white-space: nowrap; }
.grid tbody tr:last-child td { border-bottom: none; }
.grid td.text { white-space: normal; min-width: 180px; max-width: 460px; overflow-wrap: anywhere; }
.grid td.ops { text-align: right; width: 1%; }
.grid td.ops .actions { flex-wrap: nowrap; justify-content: flex-end; gap: 2px; }
.grid tr.empty td { color: var(--text-2); }
.grid th.r, .grid td.r { text-align: right; }
.grid .sub { font-size: 11.5px; margin-top: 3px; white-space: normal; min-width: 160px; }
.grid .sub.bad { color: var(--bad); }
.grid td.num.bad { color: var(--bad); font-weight: 600; }
.grid .sub.warn { color: var(--warn); }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* --- posting ---------------------------------------------------------------------- */

.compose { display: flex; flex-direction: column; gap: 12px; }
.compose select { max-width: 320px; }
.compose textarea { width: 100%; min-height: 120px; }
.compose-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.counter { font-size: 12px; color: var(--text-2); }
.counter.over { color: var(--bad); font-weight: 600; }

.option-box { border-left: 2px solid var(--track); padding: 4px 0 4px 12px; }
.option-box input[type="text"] { width: min(460px, 100%); }

/* --- images ------------------------------------------------------------------------ */

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.thumbs.small { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; max-width: 640px; }
.thumb {
  position: relative;
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  padding: 0;
  border-radius: 8px;
  overflow: hidden;
  background: var(--track);
  border: 0.5px solid var(--hairline);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
button.thumb[aria-pressed="true"] { outline: 2.5px solid var(--accent); outline-offset: 1px; }
.thumb-tag { position: absolute; left: 5px; bottom: 5px; font-size: 10px; font-weight: 600; padding: 1px 5px; border-radius: 4px; background: rgba(0, 0, 0, 0.6); color: #fff; }
.media-item { margin: 0; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.media-item figcaption { font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-item .actions { gap: 0; margin-left: -8px; }
.media-preview { display: block; align-self: center; max-width: 100%; max-height: 45vh; border-radius: 8px; background: var(--track); }

/* --- automation -------------------------------------------------------------------- */

/* A screen's sub screens: their names in a row, the one shown underlined;
   a row too long for the screen scrolls sideways. */
.segmented.subtabs {
  align-self: stretch;
  display: flex;
  flex-wrap: nowrap;
  gap: 2px;
  padding: 0;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  background: none;
  border-radius: 0;
  border-bottom: 0.5px solid var(--hairline);
}
.segmented.subtabs::-webkit-scrollbar { display: none; }
.segmented.subtabs [role="tab"] {
  flex: none;
  height: 38px;
  padding: 0 10px;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  background: none;
  box-shadow: none;
  white-space: nowrap;
}
.segmented.subtabs [role="tab"][aria-selected="true"] { color: var(--text); font-weight: 600; border-bottom-color: var(--text); background: none; box-shadow: none; }
/* Where the next group of sub screens starts (自動化: the rules, then the rest). */
.segmented.subtabs .tab-group { position: relative; margin-left: 13px; }
.segmented.subtabs .tab-group::before { content: ""; position: absolute; left: -8px; top: 30%; bottom: 30%; width: 1px; background: var(--field-border); }
.rule-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 16px 16px;
  border: 0.5px solid var(--field-border);
  border-radius: var(--radius-surface);
  background: var(--tile);
  max-width: 760px;
}
.rule-form textarea { width: 100%; }

/* --- accounts --------------------------------------------------------------------- */

.add-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.add-form label:first-child input { width: 180px; }
.add-form label:nth-child(2) { flex: 1; min-width: 240px; max-width: 420px; }
.add-form .usage { margin-left: auto; align-self: center; }

/* --- the contract ------------------------------------------------------------------ */

.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 9px 24px; margin: 0; font-size: 13px; max-width: 520px; }
.facts dt { color: var(--text-2); }
.facts dd { margin: 0; }

/* --- signing in --------------------------------------------------------------------- */

.auth { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.auth-box { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 16px; }
.auth-box > .brand { justify-content: center; margin-bottom: 4px; }
.auth-box .segmented { align-self: center; }
.auth-box form button.primary { height: 34px; }
.auth-box p { margin: 0; }
.qr { align-self: center; background: #fff; border-radius: 10px; padding: 8px; width: 196px; height: 196px; }
.qr img { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.secret { font-family: var(--mono); font-size: 13px; letter-spacing: 0.04em; overflow-wrap: anywhere; margin: 6px 0 0; }
details summary { cursor: pointer; color: var(--text-2); font-size: 12px; }
.code-input { font-family: var(--mono); font-size: 18px; letter-spacing: 0.3em; text-align: center; }

/* --- dialogs ------------------------------------------------------------------------- */

dialog {
  border: 0.5px solid var(--surface-edge);
  border-radius: var(--radius-surface);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  padding: 18px;
  width: min(400px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
dialog h2 { margin-bottom: 10px; }
dialog p { margin: 0 0 12px; }
dialog .actions { justify-content: flex-end; margin-top: 16px; }

details.bulk > summary { font-size: 12.5px; color: var(--text-2); margin: 2px 0; }
details.bulk[open] > summary { margin-bottom: 10px; }
details.bulk textarea { width: 100%; font-family: var(--mono); font-size: 12px; }
dialog { max-height: calc(100vh - 32px); overflow-y: auto; }
dialog .field-row input { width: 100%; }
.toolbar input[type="search"] { width: min(240px, 100%); }
.fp-preview { font-size: 12px; margin: 0; }

/* --- 一括操作 ------------------------------------------------------------------------ */

.op-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; max-width: 980px; }
.op-tile { justify-content: flex-start; height: 34px; background: var(--tile); }
.op-tile[aria-checked="true"] { border-color: transparent; box-shadow: 0 0 0 1.5px var(--accent); font-weight: 600; }
.op-tile.destructive { color: var(--bad); }
label.check.danger-zone { color: var(--warn); }
details.login-details > summary { font-size: 12.5px; color: var(--text-2); }
details.login-details[open] > summary { margin-bottom: 10px; }

/* --- the bar at the bottom (phones) ------------------------------------------------ */

.tabbar { display: none; }

/* Sheets: rows from edge to edge. */
dialog.sheet { padding: 0; }
.sheet-body { padding: 6px 0 10px; }
.sheet-list { display: flex; flex-direction: column; }
button.sheet-row {
  justify-content: flex-start;
  width: 100%;
  min-height: 52px;
  height: auto;
  padding: 0 20px;
  border: none;
  border-bottom: 0.5px solid var(--hairline);
  border-radius: 0;
  background: none;
  font-size: 16px;
  font-weight: 500;
  text-align: left;
}
.sheet-list button.sheet-row:last-child { border-bottom: none; }
button.sheet-row[aria-current="page"] { font-weight: 650; }
button.sheet-row .sheet-value { margin-left: auto; padding-left: 12px; color: var(--text-2); font-weight: 500; text-align: right; }

/* The person's menu: under the circle on a wide screen, a sheet on a phone. */
.account-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px 10px; }
.account-head .avatar-mark { flex: none; width: 40px; height: 40px; font-size: 17px; }
.account-email { min-width: 0; overflow-wrap: anywhere; color: var(--text-2); }
@media (min-width: 721px) {
  dialog.account-menu { inset: 60px max(16px, env(safe-area-inset-right)) auto auto; margin: 0; width: 300px; }
  dialog.account-menu button.sheet-row { min-height: 44px; padding: 0 20px; font-size: 13.5px; }
  dialog.account-menu .sheet-close { display: none; }
}

/* ホーム: adding an account, the last row of its group. */
button.group-row.group-action {
  width: 100%;
  height: auto;
  border: none;
  border-radius: 0;
  background: none;
  justify-content: flex-start;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-align: left;
}

/* --- touch: everything big enough for a finger --------------------------------------- */

@media (pointer: coarse), (max-width: 720px) {
  :root { --control-h: 44px; }
  body { font-size: 15px; }
  h1, h2 { font-size: 16px; }
  label, .field-label, fieldset.checks legend { font-size: 13px; }
  .hint { font-size: 13px; }
  .status-line { font-size: 13.5px; min-height: 19px; }
  .error { font-size: 13.5px; }
  .badge { font-size: 12px; line-height: 20px; padding: 0 8px; }

  /* 16px or more: Safari zooms into a smaller field when it is touched. */
  input, select, textarea, label > input, label > select, label > textarea { font-size: 16px; }
  input, select { min-height: 44px; padding: 8px 12px; }
  textarea { padding: 10px 12px; }
  select { padding-right: 30px; }
  input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; min-height: 0; padding: 0; }
  input[type="number"] { width: 96px; }
  input[type="file"] { min-height: 44px; }
  label.check { min-height: 44px; font-size: 15px; gap: 10px; }

  /* A button keeps its width, up to the width of where it sits; a label
     longer than that goes onto a second line, never cut off. */
  button {
    height: auto;
    min-height: var(--control-h);
    max-width: 100%;
    flex-shrink: 0;
    padding: 8px 16px;
    font-size: 15px;
    line-height: 1.3;
    white-space: normal;
    text-align: center;
    overflow-wrap: anywhere;
  }
  button.link { min-height: 44px; padding: 0 12px; font-size: 14px; }
  button.chip { min-height: 40px; height: auto; padding: 6px 14px; font-size: 14px; }
  /* Choices that do not fit on one line go onto a second one. */
  .segmented, .seg-radio { flex-wrap: wrap; max-width: 100%; border-radius: 20px; }
  .segmented [role="tab"] { height: auto; min-height: 40px; padding: 6px 16px; font-size: 14px; white-space: nowrap; }
  .segmented.subtabs { flex-wrap: nowrap; border-radius: 0; }
  .segmented.subtabs [role="tab"] { height: 44px; min-height: 0; padding: 0 12px; font-size: 15px; }
  .seg-radio label { height: auto; min-height: 40px; padding: 6px 16px; font-size: 14px; }
  .op-tile { height: auto; min-height: 48px; text-align: left; }
  /* In a table the column fits its buttons: their labels stay on one line. */
  .grid button { white-space: nowrap; max-width: none; }
  .auth-box form button.primary { min-height: 48px; height: auto; }
  details > summary, details.bulk > summary, details.login-details > summary { padding: 11px 0; font-size: 14px; }
  .tab-count { font-size: 12px; line-height: 18px; }
  .grid th { font-size: 12.5px; }
  .grid .sub { font-size: 13px; }
  .mini-list, .notes, .facts { font-size: 15px; }
  .counter { font-size: 13px; }
  details.bulk textarea { font-size: 16px; }
  /* Links keep their place in the text; the area a finger can hit grows. */
  a.link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px; margin: -12px -10px; }
  .grid a { display: inline-block; padding: 12px 0; margin: -12px 0; }
}

/* --- phones: the page fills the screen to its edges ----------------------------------- */

@media (max-width: 720px) {
  /* A gray page with white groups on it (the iPhone's grouped look). */
  body { background: var(--window); }
  main.surface { background: transparent; }
  main input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), main select, main textarea,
  .auth input:not([type="checkbox"]):not([type="radio"]) { background-color: var(--tile); }
  main .rule-form input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), main .rule-form select, main .rule-form textarea { background-color: var(--field); }
  main button.chip { background-color: var(--tile); }
  .panel h2 { font-size: 17px; font-weight: 650; }
  .home-grid { gap: 30px; }
  .group-row { min-height: 48px; padding: 11px 16px; font-size: 15px; }
  .group-row + .group-row::before { left: 16px; }
  .group-row .meta { font-size: 13px; }
  .group-head .more { font-size: 15px; }
  .group-foot { margin: 8px 16px 0; font-size: 13px; }

  /* The screen's name at the top, under the status bar. */
  .bar {
    position: sticky;
    top: 0;
    z-index: 10;
    height: auto;
    min-height: calc(52px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
    gap: 8px;
    background: var(--window);
    border-bottom: 0.5px solid var(--hairline);
  }
  .shell { display: block; }
  .sidebar { display: none; }
  .bar-title { flex: none; font-size: 17px; }
  button.menu-button { display: inline-grid; place-items: center; width: 44px; height: 44px; min-height: 0; margin-left: -10px; padding: 0; border: none; background: none; color: var(--text); }
  button.menu-button .icon { width: 22px; height: 22px; }
  a.plan-chip { height: 30px; padding: 0 10px; line-height: 30px; font-size: 13px; }
  button.avatar { width: 44px; height: 44px; margin-right: -6px; }
  .avatar-mark { width: 32px; height: 32px; font-size: 15px; }

  /* The sidebar on a phone: in from the left, the page dimmed behind it. */
  dialog.drawer {
    width: min(300px, 86vw);
    height: 100dvh;
    max-height: none;
    margin: 0 auto 0 0;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom) env(safe-area-inset-left);
    border-width: 0 0.5px 0 0;
    border-radius: 0 14px 14px 0;
    background: var(--window);
    animation: drawer-in 0.2s ease-out;
  }
  .drawer-body { display: flex; flex-direction: column; gap: 6px; padding: 18px 12px 12px; }
  .drawer-body:focus, .drawer-body:focus-visible { outline: none; }
  .drawer-body > .brand { min-height: 32px; padding: 0 14px; }
  dialog.drawer a.nav-item { min-height: 48px; padding: 0 14px; border-radius: 10px; font-size: 16px; }
  dialog.drawer button.nav-add { width: 48px; height: 48px; }
  dialog.drawer .nav-add .icon { width: 22px; height: 22px; }

  main.surface {
    margin: 0;
    min-height: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 16px max(16px, env(safe-area-inset-right)) calc(76px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }
  .panel { gap: 16px; }
  /* Sub screens: a strip right under the bar, from edge to edge, kept in view. */
  .segmented.subtabs {
    position: sticky;
    top: calc(52px + env(safe-area-inset-top));
    z-index: 5;
    max-width: none;
    margin: -16px calc(-1 * max(16px, env(safe-area-inset-right))) 0 calc(-1 * max(16px, env(safe-area-inset-left)));
    padding: 0 max(6px, env(safe-area-inset-right)) 0 max(6px, env(safe-area-inset-left));
    background: var(--window);
  }
  .panel h2 { margin-top: 12px; }
  .notice { font-size: 14px; }

  /* The screens at the bottom, within reach of the thumb. */
  .tabbar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: var(--window);
    border-top: 0.5px solid var(--hairline);
  }
  .tabbar a {
    flex: 1 1 0;
    min-width: 0;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 2px;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }
  .tabbar a > span { display: inline-flex; align-items: center; gap: 4px; padding: 7px 10px; border-radius: 999px; }
  .tabbar a[aria-current="page"] { color: var(--text); font-weight: 650; }
  .tabbar a[aria-current="page"] > span { background: var(--track); }
  .tabbar .tab-count { margin-left: 0; }

  .mini-list .what { white-space: normal; }
  /* Nothing in a row of fields is wider than the screen. */
  .field-row > *, .add-form > *, .toolbar > * { min-width: 0; max-width: 100%; }
  input[type="file"] { width: 100%; }
  .add-form label:first-child input { width: 100%; }
  .add-form label { flex: 1 1 100%; max-width: none !important; }
  .add-form .usage { margin-left: 0; }
  .compose select { max-width: none; }
  .compose-foot button.primary { flex: 1 1 100%; min-height: 48px; }
  .toolbar input[type="search"] { flex: 1 1 160px; width: auto; }
  .rule-form { padding: 14px; }
  .option-box { padding-left: 12px; }

  /* Tables become one block per row: the short cells on a line, the
     text and the buttons under them. */
  .table-scroll { overflow-x: visible; }
  table.grid, .grid tbody { display: block; }
  table.grid { background: var(--tile); border: 0.5px solid var(--surface-edge); border-radius: 12px; overflow: hidden; }
  .grid thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .grid tr { position: relative; display: block; padding: 12px 16px; border-bottom: none; }
  .grid tbody tr + tr::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 0.5px solid var(--hairline); }
  .grid td.num:first-child { color: var(--text-2); font-size: 13.5px; }
  .grid td { display: inline-block; border: none; padding: 0 12px 0 0; vertical-align: middle; font-size: 15px; white-space: normal; }
  .grid td.text { display: block; min-width: 0; max-width: none; padding: 6px 0 0; }
  .grid td.ops { display: block; width: auto; text-align: left; padding: 4px 0 0; }
  .grid td.ops .actions { justify-content: flex-start; flex-wrap: wrap; gap: 0; margin-left: -12px; }
  .grid td.ops:empty, .grid td.text:empty { display: none; }
  .grid .sub { min-width: 0; }
  /* A fact that needs its name says it (a number alone means nothing). */
  .grid td[data-label]::before { content: attr(data-label); color: var(--text-3); font-size: 13px; margin-right: 6px; }
  .grid td.title { display: block; font-weight: 600; padding: 0 0 4px; }
  /* Things with several facts each: the name, then one fact a line. */
  .grid.stacked tr { padding: 14px 16px; }
  .grid.stacked td { display: block; padding: 0; }
  .grid.stacked td.title { font-size: 16px; padding-bottom: 6px; }
  .grid.stacked td[data-label] { display: grid; grid-template-columns: 6.5em minmax(0, 1fr); justify-items: start; column-gap: 10px; padding: 3px 0; text-align: left; }
  /* A fact with nothing to say is left out (its name alone means nothing). */
  .grid td[data-label]:empty { display: none; }
  /* Facts on the page sit in a group too. */
  main dl.facts { background: var(--tile); border: 0.5px solid var(--surface-edge); border-radius: 12px; padding: 12px 16px; max-width: none; }
  .grid.stacked td[data-label]::before { margin: 0; line-height: 1.55; }
  .grid.stacked td.ops { padding-top: 6px; }

  /* Dialogs come up from the bottom, as wide as the screen. */
  dialog {
    width: 100%;
    max-width: 100%;
    max-height: calc(100dvh - env(safe-area-inset-top) - 24px);
    margin: auto 0 0;
    border-width: 0.5px 0 0;
    border-radius: 14px 14px 0 0;
    padding: 20px max(16px, env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }
  dialog.sheet { padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
  dialog .actions { flex-wrap: wrap; }
  dialog .actions > button { flex: 1 1 140px; min-height: 48px; }

  .auth { min-height: 100dvh; padding: calc(24px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
}

/* A file field opened by a button of its own stays out of sight (and out of the layout). */
input[type="file"].visually-hidden { width: 1px; min-height: 0; padding: 0; }

/* A list's tools: searching and adding on one line, the count and the rest under it. */
.toolbar.list-tools input[type="search"] { flex: 1 1 200px; width: auto; max-width: 420px; }
.toolbar.list-meta { margin-top: -6px; min-height: 34px; font-size: 13px; }
/* アカウント: rows that can be ticked. The whole first cell ticks the row;
   with rows ticked, the line under the search box is what can be done
   with them. */
.grid.pickable th.pick, .grid.pickable td.pick { width: 1%; padding: 0; }
.grid.pickable th.pick { vertical-align: middle; }
.grid.pickable th.pick { padding-left: 10px; padding-right: 2px; }
.grid.pickable td.pick label { flex-direction: row; align-items: center; min-height: 36px; padding: 0 2px 0 10px; }
.grid.pickable tr.is-picked td { background: var(--press); }
/* It takes exactly the room of the line it replaces: the table stays put. */
.toolbar.picked-bar { padding: 0 6px; border-radius: 9px; background: var(--press); }
.toolbar.picked-bar b { font-weight: 600; white-space: nowrap; }
.toolbar.picked-bar button.danger { color: var(--bad); }
.toolbar.picked-bar .link .icon { width: 16px; height: 16px; }
.pick-shown { display: none; }
/* What else a question's action does, one line each. */
dialog .side-effects { list-style: none; display: grid; gap: 4px; margin: 0 0 12px; padding: 0; font-size: 13px; }
/* A question about several things names them. */
dialog .name-list { display: flex; flex-direction: column; gap: 6px; max-height: 196px; overflow-y: auto; margin: 0 0 12px; padding: 9px 11px; list-style: none; border-radius: 9px; background: var(--field); border: 0.5px solid var(--hairline); font-size: 13px; }
@media (max-width: 720px) {
  /* A row is a card here: its tick sits at the card's top right, a finger wide. */
  .grid.pickable td.pick { position: absolute; top: 2px; right: 4px; z-index: 1; width: auto; padding: 0; }
  .grid.pickable td.pick label { justify-content: center; width: 44px; min-height: 44px; padding: 0; }
  .grid.pickable tr.is-picked { background: var(--press); }
  .grid.pickable tr.is-picked td { background: none; }
  .grid.pickable td.title { padding-right: 44px; }
  .pick-shown:not([hidden]) { display: inline-flex; }
  /* One line, like the line it replaces. */
  .toolbar.picked-bar { flex-wrap: nowrap; gap: 0; padding: 0 2px; }
  .toolbar.picked-bar .link { flex: none; padding: 0 8px; }
  .toolbar.picked-bar .link:first-child { min-width: 44px; }
  .toolbar.picked-bar b { margin-right: 4px; }
  dialog .name-list, dialog .side-effects { font-size: 15px; }
}
/* その他: the sheet itself takes the focus when it opens (no ring on its first row). */
.sheet-body:focus, .sheet-body:focus-visible { outline: none; }
/* An empty status line takes no room (it stays in place for what it will say). */
.panel > .status-line:empty { min-height: 0; margin-top: -14px; }
@media (max-width: 720px) {
  .panel > .status-line:empty { margin-top: -16px; }
}

/* The sidebar slides in on a phone, unless motion is turned down. */
@keyframes drawer-in { from { transform: translateX(-100%); } }
@media (prefers-reduced-motion: reduce) {
  dialog.drawer { animation: none; }
}
/* A narrow phone: the bottom bar's labels still fit on one line. */
@media (max-width: 360px) {
  .tabbar a { font-size: 12px; }
  .tabbar a > span { padding: 6px 6px; }
}
/* Narrower still: the plan stays in the person's menu, the screen's name in full. */
@media (max-width: 359px) {
  a.plan-chip { display: none; }
}
.sheet-list.sheet-close { border-top: 0.5px solid var(--hairline); }

/* Desktop parity: icon rail, full-width workspaces and grouped forms. */
.panel { max-width: none; min-width: 0; }
.tile { min-width: 0; padding: 18px; border: 0.5px solid var(--surface-edge); border-radius: 12px; background: var(--tile); }
.tile-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin: 0 0 14px; min-width: 0; }
.tile-head h2, .tile h2 { margin-top: 0; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(270px, 340px); gap: 16px; align-items: start; min-width: 0; }
.split-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.split-side { position: sticky; top: 72px; min-width: 0; }
.duo { display: grid; grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.1fr); gap: 16px; align-items: start; min-width: 0; }
.wide { width: 100%; }
.cell-acct { display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }
.cell-acct > .avatar-mark { width: 30px; height: 30px; flex: none; overflow: hidden; background: var(--track); color: var(--text-2); }
.avatar-mark img { width: 100%; height: 100%; object-fit: cover; }
.cell-acct .ellipsis { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.account-folder-list { display: flex; align-items: stretch; gap: 8px; overflow-x: auto; padding: 2px 0 10px; max-width: 100%; }
button.account-folder { flex: 0 0 124px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; height: auto; min-height: 105px; padding: 12px 9px; border: 1px solid transparent; background: transparent; color: var(--text-2); }
button.account-folder[aria-pressed="true"] { background: var(--press); border-color: var(--surface-edge); color: var(--text); }
.account-folder-icon { width: 38px; height: 34px; stroke: currentColor; stroke-width: 1.5; fill: none; stroke-linejoin: round; }
.account-folder-name { width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 600; }
.account-folder-count { color: var(--text-3); font-size: 11px; }
.account-folder-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.compose-folder-list { margin: 4px 0 10px; border-bottom: 0.5px solid var(--hairline); }
.acct-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(215px, 100%), 1fr)); gap: 6px; max-height: 260px; overflow-y: auto; }
.acct-pick { display: flex; flex-direction: row; align-items: center; gap: 8px; padding: 8px; min-width: 0; border-radius: 8px; background: var(--field); }
.acct-pick:has(input:checked) { background: var(--press); box-shadow: inset 0 0 0 0.5px var(--surface-edge); }
.acct-pick input { flex: none; }
.sf-ai-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.sf-ai-drafts { display: flex; flex-direction: column; max-height: 580px; overflow-y: auto; gap: 12px; }
.sf-ai-draft { padding: 12px 0; border-top: 0.5px solid var(--hairline); min-width: 0; }
.sf-draft-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; margin-bottom: 8px; }
.sf-draft-person { display: flex; align-items: center; flex: 1 1 190px; min-width: 0; }
.sf-ai-draft textarea { width: 100%; min-height: 84px; }
.sf-ai-draft .status-line { margin-top: 6px; }
.post-preview { display: flex; flex-direction: column; align-items: stretch; gap: 9px; padding: 14px; border-radius: 10px; background: var(--field); min-width: 0; }
.post-preview > .avatar-mark { flex: none; }
.post-preview > div { min-width: 0; }
.pp-who { display: flex; gap: 6px; flex-wrap: wrap; align-items: baseline; margin-bottom: 6px; }
.pp-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }
.pp-text.empty, .pp-note { color: var(--text-2); }
.pp-note { font-size: 12px; line-height: 1.5; margin-top: 10px; }
.pp-media { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 3px; margin-top: 12px; border-radius: 9px; overflow: hidden; }
.pp-media img { width: 100%; max-height: 180px; object-fit: cover; }
.pp-media.one { grid-template-columns: 1fr; }
.plan-line { color: var(--text-2); line-height: 1.55; overflow-wrap: anywhere; }
.sf-body-modes { margin-bottom: 12px; }
.autopost-groups { display: flex; flex-direction: column; min-width: 0; }
.autopost-group { padding: 14px 0; border-bottom: 0.5px solid var(--hairline); }
.autopost-group:last-child { border-bottom: 0; }
.ap-group-head { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.ap-group-head > input { margin-top: 6px; flex: none; }
.ap-group-head details { min-width: 0; flex: 1; }
.ap-group-head summary { cursor: pointer; padding: 2px 0; }
.ap-group-count { color: var(--text-2); font-size: 12px; margin-left: 12px; }
.ap-group-summary { color: var(--text-2); margin: 6px 0 6px 25px; line-height: 1.6; overflow-wrap: anywhere; }
.ap-group-summary .clamp { display: inline; }
.ap-group-actions { margin-left: 20px; flex-wrap: wrap; }
.ap-group-members { margin-top: 12px; }
.ap-rule-detail { padding: 10px 0; border-top: 0.5px solid var(--hairline); }
.ap-group-accounts { display: flex; align-items: center; gap: 8px 18px; flex-wrap: wrap; margin: 8px 0; }
.rule-batch-tools { padding-bottom: 10px; border-bottom: 0.5px solid var(--hairline); flex-wrap: wrap; }
.rule-form { max-width: none; }
.rule-form > .tile-head { margin-bottom: 0; }
.dm-queue .table-scroll { max-height: 560px; overflow: auto; }
.dm-queue .grid td.text { min-width: 120px; }
.dm-workspace > .compose { max-width: none; }
.home-dashboard { gap: 18px; }
.stat-strip { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; }
.stat { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; padding: 16px; background: var(--tile); border: 0.5px solid var(--surface-edge); border-radius: 12px; color: var(--text); text-decoration: none; min-width: 0; height: auto; }
.stat-label { color: var(--text-2); font-size: 12px; }
.stat-value { font-size: 26px; line-height: 1.1; font-weight: 650; }
.stat-sub { color: var(--text-2); font-size: 11px; }
.stat-sub.bad, .bad { color: var(--bad); }
.home-cols { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 16px; align-items: start; }
.todo-list, .acct-rows, .mini-list { display: flex; flex-direction: column; gap: 0; margin: 0; padding: 0; list-style: none; }
.todo-list > *, .acct-rows > *, .mini-list > * { padding: 9px 0; border-bottom: 0.5px solid var(--hairline); min-width: 0; }
.todo-list > *:last-child, .acct-rows > *:last-child, .mini-list > *:last-child { border-bottom: 0; }
.todo-list > *, .acct-rows > * { display: flex; align-items: center; gap: 8px; }
.todo-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.acct-rows .cell-acct { flex: 1; }
.home-feature-summary { display: flex; flex-direction: column; gap: 16px; }
.home-feature + .home-feature { border-top: 0.5px solid var(--hairline); padding-top: 14px; }
.mini-stats { display: flex; gap: 8px 16px; flex-wrap: wrap; color: var(--text-2); }
@media (min-width: 721px) {
  .shell { grid-template-columns: 84px minmax(0,1fr); }
  .sidebar { padding: 18px 5px 12px; align-items: stretch; gap: 16px; }
  .sidebar > .brand { padding: 0; justify-content: center; }
  .sidebar > .brand .brand-name { display: none; }
  .sidebar a.nav-item { position: relative; flex-direction: column; justify-content: center; min-height: 66px; padding: 8px 2px; font-size: 10px; gap: 5px; text-align: center; }
  .sidebar a.nav-item .icon { width: 21px; height: 21px; }
  .sidebar .nav-label { white-space: nowrap; }
  .sidebar .nav-add { display: none; }
  .sidebar a.nav-item .tab-count { position: absolute; top: 3px; right: 4px; font-size: 9px; }
  .page > .bar { position: sticky; top: 0; z-index: 20; background: var(--window); }
  .bar-title { font-size: 18px; }
}
@media (max-width: 1040px) {
  .split { grid-template-columns: minmax(0,1fr) minmax(240px,290px); gap: 12px; }
  .duo { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 860px) {
  .split { grid-template-columns: minmax(0,1fr); }
  .split-side { position: static; }
  .home-cols { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 720px) {
  .tile { padding: 16px; }
  .stat-strip { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 25px; }
  button.account-folder { flex-basis: 110px; min-height: 104px; }
  .account-folder-count { font-size: 12px; }
  .ap-group-count { display: block; margin: 5px 0 0; }
  .ap-group-actions, .ap-group-summary { margin-left: 0; }
  .sf-ai-drafts { max-height: none; overflow: visible; }
  .sf-ai-draft textarea { min-height: 100px; }
  .post-preview { padding: 14px; }
  .dm-queue .table-scroll { max-height: none; }
  dialog.drawer .nav-item { flex-direction: row; gap: 10px; }
}

.relay-code { overflow-wrap: anywhere; user-select: all; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }

.rule-form-host:empty { display: none; }
