/* Subtwine styles — foundations: reset, typography and the shared controls
   (buttons, icon buttons, segmented controls, switches, popovers, menus, the
   toast). Colours come only from tokens-indigo.css; this file declares none
   of its own except pure black and white on video.
   Loaded from index.html in the order web_manifest.py declares; that order is
   the cascade order. */
:root {
  --radius:12px;
  --appbar-h:56px;
  --font:-apple-system,BlinkMacSystemFont,"SF Pro Text",Inter,"Segoe UI","PingFang SC","Hiragino Sans","Microsoft YaHei",sans-serif;
  font-family:var(--font);
  color:var(--ink);
  background:var(--bg);
  font-size:14px;
}
* {
  box-sizing:border-box;
}
html,
body {
  margin:0;
  background:var(--bg);
  color:var(--ink);
}
body {
  font:14px/1.5 var(--font);
  -webkit-font-smoothing:antialiased;
  min-height:100vh;
  /* The page never scrolls sideways, at any width (R6). */
  overflow-x:hidden;
}
button,
input,
textarea,
select {
  font:inherit;
  color:inherit;
}
button {
  cursor:pointer;
  border:0;
  background:none;
  padding:0;
  border-radius:8px;
}
button:disabled {
  cursor:not-allowed;
  opacity:.45;
}
a {
  color:inherit;
  text-decoration:none;
}
:focus-visible {
  outline:2px solid var(--accent);
  outline-offset:2px;
}
[hidden] {
  display:none!important;
}
h1,
h2,
h3 {
  margin:0;
  letter-spacing:-.01em;
}
p {
  line-height:1.6;
}
small {
  color:var(--muted);
}
input,
textarea,
select {
  accent-color:var(--accent);
}
textarea,
input:not([type=checkbox]):not([type=range]):not([type=radio]),
select {
  border:1px solid var(--line-strong);
  padding:8px 10px;
  background:var(--surface);
  color:var(--ink);
  outline:none;
  border-radius:8px;
  min-width:0;
  max-width:100%;
}
textarea:focus,
input:not([type=checkbox]):not([type=range]):focus,
select:focus {
  border-color:var(--accent);
}
textarea {
  resize:vertical;
}
input[type=checkbox] {
  margin:0;
  vertical-align:middle;
}
input[type=range] {
  cursor:pointer;
  accent-color:var(--accent);
}
/* Every icon is inline SVG painted by icons.js from a data-icon placeholder.
   It inherits the text colour and adds no line box of its own. */
svg {
  display:block;
  flex:none;
}
[data-icon],
.i {
  display:inline-flex;
  flex:none;
  align-items:center;
}
.muted {
  color:var(--muted);
  font-style:normal;
  font-weight:400;
}

/* ---- buttons ---- */
.btn {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  min-height:34px;
  padding:0 14px;
  border-radius:8px;
  border:1px solid var(--line);
  background:var(--surface);
  font-size:13.5px;
  font-weight:550;
  white-space:nowrap;
  transition:background .12s,border-color .12s;
}
.btn:hover {
  background:var(--hover);
}
.btn.primary {
  background:var(--accent);
  border-color:var(--accent);
  color:var(--on-accent);
}
.btn.primary:hover {
  background:var(--accent-hover);
  border-color:var(--accent-hover);
}
.btn.ghost {
  border-color:transparent;
  background:none;
  color:var(--ink-2);
}
.btn.ghost:hover {
  background:var(--hover);
  color:var(--ink);
}
.btn.soft {
  background:var(--accent-soft);
  border-color:transparent;
  color:var(--accent-ink);
}
.btn.danger {
  background:var(--fail);
  border-color:var(--fail);
  color:#fff;
}
.btn.sm {
  min-height:28px;
  padding:0 10px;
  font-size:12.5px;
}
.btn.lg {
  min-height:42px;
  padding:0 18px;
  font-size:14.5px;
  border-radius:10px;
}
.btn.full {
  width:100%;
}
.icon-btn {
  width:32px;
  height:32px;
  display:inline-grid;
  place-items:center;
  border-radius:8px;
  border:1px solid var(--line);
  background:var(--surface);
  color:var(--ink-2);
  flex:none;
}
.icon-btn:hover {
  background:var(--hover);
  color:var(--ink);
}
.icon-btn.plain {
  border-color:transparent;
  background:none;
}
.icon-btn.plain:hover {
  background:var(--hover);
}
.icon-btn.sm {
  width:28px;
  height:28px;
}
.icon-btn[aria-expanded=true],
.icon-btn[aria-pressed=true] {
  color:var(--accent-ink);
  background:var(--accent-soft);
}
.link {
  color:var(--accent);
  font-size:13px;
  font-weight:550;
  padding:0;
}
.link:hover {
  text-decoration:underline;
}

/* ---- segmented control ---- */
.seg {
  display:inline-flex;
  padding:2px;
  border-radius:9px;
  background:var(--surface-2);
  gap:2px;
  max-width:100%;
}
.seg button {
  min-height:28px;
  padding:0 12px;
  border-radius:7px;
  font-size:13px;
  color:var(--ink-2);
  white-space:nowrap;
  flex:1 1 auto;
}
.seg button:hover {
  color:var(--ink);
}
.seg button[aria-pressed=true] {
  background:var(--seg-on);
  color:var(--ink);
  box-shadow:var(--seg-shadow);
  font-weight:550;
}
.seg button em {
  font-style:normal;
  color:var(--faint);
  font-size:12px;
  margin-left:2px;
}
.seg.sm button {
  min-height:24px;
  padding:0 9px;
  font-size:12px;
}
.seg.full {
  display:flex;
  width:100%;
}
.seg.full button {
  flex:1 1 0;
  min-width:0;
  white-space:normal;
  min-height:30px;
  padding:4px 8px;
  line-height:1.3;
}

/* ---- a switch drawn on a button ---- */
.switch-button {
  position:relative;
  width:36px;
  height:20px;
  flex:none;
  border-radius:99px;
  background:var(--line-strong);
  transition:background .15s;
}
.switch-button span {
  position:absolute;
  left:2px;
  top:2px;
  width:16px;
  height:16px;
  border-radius:50%;
  background:#fff;
  box-shadow:0 1px 2px rgba(0,0,0,.2);
  transition:transform .15s;
}
.switch-button[aria-pressed=true] {
  background:var(--accent);
}
.switch-button[aria-pressed=true] span {
  transform:translateX(16px);
}
html[dir=rtl] .switch-button[aria-pressed=true] span {
  transform:translateX(-16px);
}
html[dir=rtl] .switch-button span {
  left:auto;
  right:2px;
}

/* ---- popovers and menus ---- */
.popover {
  position:fixed;
  z-index:60;
  background:var(--surface);
  color:var(--ink);
  border:1px solid var(--line);
  border-radius:12px;
  box-shadow:var(--shadow-menu);
}
/* A menu is as wide as its longest entry on one line, but never wider than
   the window: an entry longer than that (some interface languages, on a
   phone) wraps instead of sticking out (T033). */
.menu {
  width:max-content;
  min-width:200px;
  max-width:calc(100vw - 16px);
  padding:5px;
}
.menu button {
  display:flex;
  width:100%;
  align-items:center;
  gap:10px;
  min-height:34px;
  padding:5px 10px;
  border-radius:7px;
  font-size:13.5px;
  line-height:1.3;
  text-align:start;
  white-space:normal;
  overflow-wrap:anywhere;
}
.menu button > * {
  flex:none;
}
.menu button > span:not(.i):not(.hint):not(.check) {
  flex:0 1 auto;
  min-width:0;
}
.menu button:hover,
.menu button:focus-visible {
  background:var(--hover);
  outline:none;
}
.menu button.danger {
  color:var(--fail);
}
.menu button:disabled:hover {
  background:none;
}
.menu .i {
  color:var(--muted);
}
.menu button.danger .i {
  color:var(--fail);
}
.menu .hint,
.menu .check {
  margin-inline-start:auto;
  color:var(--muted);
  display:inline-flex;
}
.menu .check {
  color:var(--accent);
}
.menu-label {
  padding:6px 10px 2px;
  font-size:11.5px;
  color:var(--faint);
}
.menu-separator {
  border-top:1px solid var(--line-soft);
  margin:4px 2px;
}

/* ---- the toast ---- */
.toast {
  position:fixed;
  left:50%;
  bottom:24px;
  transform:translateX(-50%);
  z-index:90;
  max-width:calc(100vw - 32px);
  display:flex;
  align-items:center;
  gap:12px;
  padding:10px 16px;
  border-radius:10px;
  background:var(--ink);
  color:var(--bg);
  font-size:13.5px;
  line-height:1.5;
  box-shadow:var(--shadow-menu);
  overflow-wrap:anywhere;
}
.toast.error {
  background:var(--fail);
  color:#fff;
}
.toast button {
  flex:none;
  padding:4px 10px;
  border-radius:6px;
  background:color-mix(in srgb,currentColor 18%,transparent);
  color:inherit;
  font-weight:600;
}

@keyframes spin {
  to {transform:rotate(360deg);}
}
@keyframes pulse {
  50% {opacity:.35;}
}
@media(prefers-reduced-motion:reduce) {
  *,
  *::before,
  *::after {
    transition:none!important;
    animation:none!important;
    scroll-behavior:auto!important;
  }
}
