/* ------------------------------------------------------------------
   Tool Wrapper UI kit. Shared by the orchestrator UI and tool apps.

   In a tool app:  <link rel="stylesheet" href="/kit/tw.css">
   Calm, native-feeling surfaces inspired by macOS and elementary OS.
   Light and dark follow the system setting.
   ------------------------------------------------------------------ */

@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('./fonts/inter-latin-ext.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-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('./fonts/inter-latin.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;
}

:root {
  color-scheme: light dark;
  --font: 'Inter Variable', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;

  --bg: #ffffff;
  --sidebar: #f3f3f5;
  --surface: #ffffff;
  --surface-sunken: #f6f6f8;
  --field: #ffffff;
  --hover: rgba(0, 0, 0, 0.04);
  --selected: rgba(0, 0, 0, 0.068);
  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.15);
  --text: #1c1c1e;
  --text-2: #636366;
  --text-3: #9c9ca1;

  --accent: #3689e6;
  --accent-strong: #2a74c9;
  --accent-soft: rgba(54, 137, 230, 0.12);
  --focus: 0 0 0 3px rgba(54, 137, 230, 0.32);

  --green: #3a8a0c;
  --green-soft: rgba(104, 183, 35, 0.15);
  --red: #c6262e;
  --red-soft: rgba(198, 38, 46, 0.09);
  --orange: #c24e00;
  --orange-soft: rgba(243, 115, 41, 0.13);
  --purple: #8a4fd0;
  --gray-soft: rgba(0, 0, 0, 0.055);

  --r-sm: 6px;
  --r: 9px;
  --r-lg: 13px;
  --shadow-card: 0 0 0 1px var(--line), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-raised: 0 0 0 1px var(--line), 0 6px 20px rgba(0, 0, 0, 0.07), 0 1px 3px rgba(0, 0, 0, 0.05);
  --segment-on: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1e;
    --sidebar: #242427;
    --surface: #242427;
    --surface-sunken: #1a1a1c;
    --field: #1a1a1c;
    --hover: rgba(255, 255, 255, 0.05);
    --selected: rgba(255, 255, 255, 0.09);
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.16);
    --text: #f2f2f4;
    --text-2: #a5a5ab;
    --text-3: #6f6f76;

    --accent: #4f9cf0;
    --accent-strong: #6cadf3;
    --accent-soft: rgba(79, 156, 240, 0.16);
    --focus: 0 0 0 3px rgba(79, 156, 240, 0.38);

    --green: #8fd15a;
    --green-soft: rgba(143, 209, 90, 0.13);
    --red: #ff6f6f;
    --red-soft: rgba(255, 111, 111, 0.11);
    --orange: #ffa45c;
    --orange-soft: rgba(255, 164, 92, 0.13);
    --purple: #c29cf2;
    --gray-soft: rgba(255, 255, 255, 0.08);

    --shadow-card: 0 0 0 1px var(--line);
    --shadow-raised: 0 0 0 1px var(--line-strong), 0 10px 30px rgba(0, 0, 0, 0.35);
    --segment-on: #48484c;
  }
}

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

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

body {
  margin: 0;
  font: 14px/1.5 var(--font);
  font-feature-settings: 'cv11', 'ss01';
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  letter-spacing: -0.012em;
}

code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--gray-soft);
  padding: 1px 5px;
  border-radius: 5px;
}

::selection {
  background: var(--accent-soft);
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

[hidden] {
  display: none !important;
}

.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;
  opacity: 0;
}

.muted {
  color: var(--text-2);
  margin: 0;
}

.hint {
  margin: 1px 0 0;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text-2);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stack h4 {
  font-size: 13px;
  font-weight: 600;
  margin-top: 8px;
}

.card {
  padding: 16px 18px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

/* ---------------------------------------------------------------- Grouped list (settings style) */

.group {
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.row {
  position: relative;
  display: block;
  padding: 11px 14px;
  color: var(--text);
}

.row + .row::before {
  content: '';
  position: absolute;
  top: 0;
  left: 14px;
  right: 0;
  border-top: 1px solid var(--line);
}

.row.inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
}

.row-label {
  min-width: 0;
}

.row-label label {
  display: block;
  font-weight: 520;
}

.row.inline .row-control {
  flex: 0 1 58%;
  display: flex;
  justify-content: flex-end;
}

.row.stacked .row-control {
  margin-top: 9px;
}

.required {
  margin-left: 3px;
  color: var(--text-3);
  font-weight: 400;
}

.field-error {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--red);
}

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

.field {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--field);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field::placeholder {
  color: var(--text-3);
}

.field:focus {
  border-color: var(--accent);
  box-shadow: var(--focus);
}

.row.invalid .field,
.field.has-error {
  border-color: var(--red);
}

textarea.field {
  height: auto;
  min-height: 84px;
  padding: 8px 10px;
  line-height: 1.5;
  resize: vertical;
}

.field.mono {
  font-family: var(--mono);
  font-size: 12.5px;
}

.field-number {
  max-width: 112px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

select.field {
  appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='14' fill='none' stroke='%238e8e93' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 5l3-3 3 3M2 9l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
}

.switch {
  position: relative;
  flex: none;
  width: 40px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 12px;
  background: var(--line-strong);
  cursor: pointer;
  transition: background 0.2s ease;
}

.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
  transition: transform 0.22s cubic-bezier(0.3, 0.7, 0.4, 1);
}

.switch[aria-checked='true'] {
  background: var(--accent);
}

.switch[aria-checked='true']::after {
  transform: translateX(16px);
}

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: 8px;
  background: var(--selected);
}

.segmented > button,
.segmented > a {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 520;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.segmented > button:hover,
.segmented > a:hover {
  color: var(--text);
  text-decoration: none;
}

.segmented > [aria-checked='true'],
.segmented > [aria-current='page'] {
  background: var(--segment-on);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
}

.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
}

.choice {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.choice input {
  accent-color: var(--accent);
}

.dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 14px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r);
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.dropzone strong {
  color: var(--accent);
  font-weight: 560;
}

.dropzone:hover,
.dropzone.over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.file-chips {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.file-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 4px 3px 10px;
  border-radius: 7px;
  background: var(--surface-sunken);
  font-size: 13px;
}

.file-chip svg {
  flex: none;
  color: var(--text-3);
}

.file-chip .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-chip .size {
  color: var(--text-3);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border: none;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 560;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, filter 0.15s, color 0.15s;
}

.btn:hover {
  text-decoration: none;
}

.btn:active:not(:disabled) {
  transform: translateY(0.5px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(180deg, color-mix(in oklab, var(--accent) 86%, white), var(--accent));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 0 0 0.5px rgba(0, 0, 0, 0.18), 0 1px 2px rgba(0, 0, 0, 0.14);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.05);
}

.btn-primary:focus-visible {
  box-shadow: var(--focus);
}

.btn-primary kbd {
  margin-left: 2px;
  font: 500 11.5px var(--font);
  opacity: 0.72;
}

.btn-secondary {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line-strong), 0 1px 1px rgba(0, 0, 0, 0.04);
}

.btn-secondary:hover:not(:disabled) {
  background: color-mix(in oklab, var(--surface) 94%, var(--text));
}

.btn-plain {
  color: var(--text-2);
  background: transparent;
}

.btn-plain:hover:not(:disabled) {
  color: var(--text);
  background: var(--hover);
}

.btn-sm {
  height: 27px;
  padding: 0 10px;
  font-size: 12.5px;
  border-radius: 7px;
}

.btn-icon {
  width: 32px;
  padding: 0;
}

.btn-icon.btn-xs {
  width: 24px;
  height: 24px;
  border-radius: 6px;
}

.spin {
  animation: spin 0.9s linear infinite;
}

/* ---------------------------------------------------------------- Status, callouts, empty states */

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  height: 22px;
  padding: 0 9px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 560;
  background: var(--gray-soft);
  color: var(--text-2);
  white-space: nowrap;
}

.status i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-succeeded,
.status-online {
  background: var(--green-soft);
  color: var(--green);
}

.status-failed,
.status-offline,
.status-invalid {
  background: var(--red-soft);
  color: var(--red);
}

.status-running,
.status-queued {
  background: var(--accent-soft);
  color: var(--accent);
}

.status-running i {
  animation: pulse 1.2s ease-in-out infinite;
}

.status-degraded {
  background: var(--orange-soft);
  color: var(--orange);
}

.callout {
  display: flex;
  gap: 10px;
  padding: 11px 13px;
  border-radius: var(--r);
  background: var(--gray-soft);
  font-size: 13px;
  line-height: 1.45;
}

.callout > svg {
  flex: none;
  margin-top: 1px;
  color: var(--text-2);
}

.callout-body {
  min-width: 0;
  overflow-wrap: anywhere;
}

.callout-body strong {
  display: block;
  font-weight: 600;
}

.callout-body ul {
  margin: 4px 0 0;
  padding-left: 18px;
}

.callout-error {
  background: var(--red-soft);
}

.callout-error > svg,
.callout-error strong {
  color: var(--red);
}

.callout-warn {
  background: var(--orange-soft);
}

.callout-warn > svg,
.callout-warn strong {
  color: var(--orange);
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 300px;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-2);
}

.empty > svg {
  margin-bottom: 8px;
  color: var(--text-3);
}

.empty h3 {
  font-size: 15px;
  font-weight: 620;
  color: var(--text);
}

.empty-body {
  max-width: 40ch;
}

.chip {
  padding: 0 5px;
  border-radius: 4px;
  background: var(--gray-soft);
  color: var(--text-2);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.02em;
  line-height: 17px;
}

.progress {
  height: 3px;
  background: var(--line);
  overflow: hidden;
}

.progress > span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 0.35s ease;
}

.progress.indeterminate > span {
  width: 30%;
  animation: slide 1.15s ease-in-out infinite;
}

/* ---------------------------------------------------------------- Content blocks */

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.metric {
  padding: 12px 14px;
  border-radius: var(--r);
  background: var(--surface-sunken);
}

.metric-label {
  font-size: 12.5px;
  color: var(--text-2);
}

.metric-value {
  margin-top: 1px;
  font-size: 23px;
  font-weight: 680;
  letter-spacing: -0.02em;
}

.metric-hint {
  font-size: 12px;
  color: var(--text-3);
}

.code-block {
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--r);
  background: var(--surface-sunken);
  font: 12.5px/1.6 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow: auto;
  max-height: 520px;
}

.json .k {
  color: var(--accent);
}

.json .s {
  color: var(--green);
}

.json .n {
  color: var(--orange);
}

.json .l {
  color: var(--purple);
}

.prose {
  line-height: 1.62;
  overflow-wrap: anywhere;
}

.prose > :first-child {
  margin-top: 0;
}

.prose > :last-child {
  margin-bottom: 0;
}

.prose p,
.prose ul,
.prose ol {
  margin: 0.6em 0;
}

.prose h1 {
  font-size: 20px;
  margin: 1.1em 0 0.4em;
}

.prose h2 {
  font-size: 17px;
  margin: 1.1em 0 0.4em;
}

.prose h3 {
  font-size: 15px;
  margin: 1em 0 0.3em;
}

.prose blockquote {
  margin: 0.6em 0;
  padding-left: 12px;
  border-left: 3px solid var(--line-strong);
  color: var(--text-2);
}

.prose pre {
  padding: 12px 14px;
  border-radius: var(--r);
  background: var(--surface-sunken);
  overflow: auto;
}

.prose pre code {
  padding: 0;
  background: none;
}

.prose table {
  margin: 0.6em 0;
  box-shadow: 0 0 0 1px var(--line);
  border-radius: var(--r);
  overflow: hidden;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--line);
}

.table-wrap {
  max-height: 520px;
  overflow: auto;
  border-radius: var(--r);
  box-shadow: inset 0 0 0 1px var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

th {
  position: sticky;
  top: 0;
  background: var(--surface-sunken);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
}

th,
td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
}

tbody tr:last-child td {
  border-bottom: none;
}

th.num,
td.num {
  text-align: right;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r);
  background: var(--surface-sunken);
  color: var(--text);
  transition: background 0.15s;
}

.file-row:hover {
  text-decoration: none;
  background: var(--selected);
}

.file-row svg {
  flex: none;
  color: var(--accent);
}

.file-row .name {
  flex: 1;
  font-weight: 520;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-row .size {
  color: var(--text-3);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- Toast (toast() in /kit/tw.js) */

.tw-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 11px;
  max-width: calc(100vw - 32px);
  padding: 11px 18px 11px 13px;
  border-radius: 13px;
  background: var(--surface);
  box-shadow: var(--shadow-raised);
  transform: translateX(-50%);
  animation: tw-toast-in 0.4s cubic-bezier(0.3, 0.7, 0.4, 1.2) both;
}

.tw-toast.leaving {
  animation: tw-toast-out 0.35s ease forwards;
}

.tw-toast > svg {
  flex: none;
  color: var(--accent);
}

.tw-toast-success > svg {
  color: var(--green);
}

.tw-toast-error > svg {
  color: var(--red);
}

.tw-toast-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}

.tw-toast-text strong {
  font-weight: 620;
}

.tw-toast-text span {
  color: var(--text-2);
  font-size: 13px;
}

@keyframes tw-toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 14px) scale(0.97);
  }
}

@keyframes tw-toast-out {
  to {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
}

/* ---------------------------------------------------------------- Motion */

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  50% {
    opacity: 0.3;
  }
}

@keyframes slide {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(340%);
  }
}

@keyframes shake {
  20%,
  60% {
    transform: translateX(-7px);
  }
  40%,
  80% {
    transform: translateX(7px);
  }
}

@media (max-width: 760px) {
  .row.inline {
    flex-wrap: wrap;
  }

  .row.inline .row-control {
    flex-basis: 100%;
    justify-content: flex-start;
  }

  .row.inline:has(.switch) {
    flex-wrap: nowrap;
  }

  .row.inline:has(.switch) .row-control {
    flex-basis: auto;
  }
}

/* ---------------------------------------------------------------- Phone form (tabBar() and sheet() in /kit/tw.js)

   Opt-in: <html class="tw-phone"> plus viewport-fit=cover in the viewport meta. Below 700px the
   app then gets touch-sized controls, 16px fields (iOS zooms into anything smaller) and room for
   the tab bar. Above 700px nothing here applies, and the tab bar is hidden. */

.tw-tabbar {
  display: none;
}

.tw-sheet-scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  animation: tw-scrim-in 0.2s ease both;
}

.tw-sheet {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  max-height: 86dvh;
  border-radius: 16px 16px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-raised);
  animation: tw-sheet-in 0.28s cubic-bezier(0.3, 0.7, 0.4, 1) both;
}

.tw-sheet-handle {
  flex: none;
  display: grid;
  place-items: center;
  height: 22px;
  touch-action: none;
}

.tw-sheet-handle::before {
  content: '';
  width: 36px;
  height: 5px;
  border-radius: 999px;
  background: var(--line-strong);
}

.tw-sheet-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 8px 6px 18px;
}

.tw-sheet-head h2 {
  font-size: 17px;
  font-weight: 650;
}

.tw-sheet-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 16px calc(18px + env(safe-area-inset-bottom));
}

.tw-sheet-list {
  display: flex;
  flex-direction: column;
}

.tw-sheet-link {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 50px;
  padding: 0 4px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: var(--text);
  font-size: 16px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.tw-sheet-link:last-child {
  border-bottom: 0;
}

.tw-sheet-link:hover {
  text-decoration: none;
}

.tw-sheet-link > svg {
  flex: none;
  color: var(--text-2);
}

.tw-sheet-link[aria-current='page'],
.tw-sheet-link[aria-current='page'] > svg {
  color: var(--accent);
}

.tw-sheet-link-danger,
.tw-sheet-link-danger > svg {
  color: var(--red);
}

@keyframes tw-scrim-in {
  from {
    opacity: 0;
  }
}

@keyframes tw-sheet-in {
  from {
    transform: translateY(100%);
  }
}

@media (max-width: 700px) {
  .tw-phone {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
  }

  .tw-phone body {
    overflow-x: hidden;
  }

  /* Room for the tab bar, so the last row is never underneath it. */
  .tw-phone body:has(> .tw-tabbar) {
    padding-bottom: calc(58px + env(safe-area-inset-bottom));
  }

  .tw-tabbar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 40;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    padding: 0 max(4px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(4px, env(safe-area-inset-left));
    border-top: 1px solid var(--line);
    background: color-mix(in oklab, var(--surface) 94%, transparent);
    -webkit-backdrop-filter: saturate(1.6) blur(16px);
    backdrop-filter: saturate(1.6) blur(16px);
  }

  .tw-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 54px;
    padding: 6px 2px 5px;
    border: 0;
    background: none;
    color: var(--text-3);
    font: 550 10.5px/1.1 var(--font);
    text-decoration: none;
    cursor: pointer;
  }

  .tw-tab:hover {
    text-decoration: none;
  }

  .tw-tab > span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .tw-tab[aria-current='page'] {
    color: var(--accent);
  }

  /* Touch-sized controls. */
  /* :where keeps this easy to override for an app's larger display fields. */
  :where(.tw-phone) input:not([type='checkbox'], [type='radio'], [type='range']),
  :where(.tw-phone) select,
  :where(.tw-phone) textarea {
    font-size: 16px;
  }

  :where(.tw-phone) .field {
    min-height: 44px;
  }

  .tw-phone .btn {
    height: auto;
    min-height: 44px;
    font-size: 15px;
  }

  .tw-phone .btn-sm {
    min-height: 38px;
    font-size: 14px;
  }

  .tw-phone .btn-icon {
    width: auto;
    min-width: 44px;
  }

  .tw-phone .btn-icon.btn-sm {
    min-width: 38px;
  }

  .tw-phone .btn-icon.btn-xs {
    width: auto;
    height: auto;
    min-width: 36px;
    min-height: 36px;
  }

  .tw-phone .segmented > button,
  .tw-phone .segmented > a {
    height: 36px;
    font-size: 14px;
  }

  .tw-phone .tw-toast {
    bottom: calc(72px + env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
