:root {
  color-scheme: light dark;
  --page: light-dark(#f8f8f6, #121313);
  --surface: light-dark(#fff, #191a1a);
  --paper: light-dark(#f1f2ef, #202222);
  --hover: light-dark(#eeefeb, #242626);
  --ink: light-dark(#181918, #f1f1ed);
  --muted: light-dark(#575b56, #b2b5af);
  --accent: light-dark(#252825, #edeee8);
  --on-accent: light-dark(#fff, #131513);
  --line: light-dark(#dcded8, #383b37);
  --control-line: light-dark(#adafa8, #686d65);
  --good: light-dark(#3e5e4b, #a5c0ad);
  --good-fill: light-dark(#798d7e, #81978a);
  --warning: light-dark(#725629, #d2ba8d);
  --bad: light-dark(#8c3d36, #edaaa2);
  --bad-fill: light-dark(#a26257, #a97069);
  --sans: "Segoe UI Variable", "Segoe UI", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, monospace;
  font: 16px/1.55 var(--sans);
  color: var(--ink);
  background: var(--page);
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 0; }
a { color: inherit; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
:focus:not(:focus-visible) { outline: none; }
h1[tabindex="-1"]:focus, #content:focus { outline: none; }
h1, h2, p, dl, dd { margin: 0; }
h1, h2 { line-height: 1.08; letter-spacing: -.045em; font-weight: 650; }
h1 { font-size: clamp(2.5rem, 5vw, 4.2rem); }
h2 { font-size: 1.55rem; }
.frame { width: min(1200px, calc(100% - 96px)); margin-inline: auto; }
.skip-link { position: fixed; z-index: 1; top: -100px; left: 12px; background: var(--surface); padding: 12px 16px; }
.skip-link:focus { top: 12px; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; justify-content: space-between; align-items: stretch; min-height: 68px; gap: 12px; }
.navigation, .topbar-actions { display: flex; align-items: center; gap: clamp(12px, 3vw, 34px); }
.topbar-actions { gap: 8px; }
.navigation a {
  display: flex;
  align-items: center;
  align-self: stretch;
  border-block: 2px solid transparent;
  color: var(--muted);
  font-size: .94rem;
  font-weight: 600;
  text-decoration: none;
}
.navigation a:hover, .navigation a[aria-current="page"] { color: var(--ink); }
.navigation a[aria-current="page"] { border-bottom-color: var(--ink); }
.theme-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
}
.theme-button:hover { background: var(--hover); border-color: var(--line); }
.theme-glyph {
  width: 17px;
  height: 17px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 0 16px;
  background: transparent;
  font-size: .91rem;
  font-weight: 620;
  text-decoration: none;
  line-height: 1.2;
  transition: background-color 120ms, border-color 120ms;
}
.button.primary { background: var(--accent); color: var(--on-accent); }
.button.primary:hover:not(:disabled) { background: var(--ink); }
.button.secondary { border-color: var(--control-line); background: var(--surface); }
.button.secondary:hover:not(:disabled), .button.quiet:hover:not(:disabled) { background: var(--hover); }
.button.quiet { color: var(--muted); }
.button.full { width: 100%; }
.button.compact { padding-inline: 12px; min-height: 44px; font-size: .84rem; }
.text-button { border: 0; background: transparent; padding: 0; min-height: 44px; font-weight: 630; text-decoration: underline; text-underline-offset: 4px; }

.auth-layout {
  min-height: calc(100svh - 69px);
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, .95fr);
  gap: clamp(28px, 7vw, 105px);
  align-items: center;
  padding-block: 48px 94px;
}
.auth-intro { padding-bottom: 34px; }
.auth-intro h1 { font-size: clamp(2.8rem, 5.15vw, 4.8rem); letter-spacing: -.053em; }
.auth-intro > p { color: var(--muted); font-size: clamp(1rem, 1.45vw, 1.19rem); max-width: 38ch; margin-top: 24px; }
.auth-facts {
  display: grid;
  grid-template-columns: 1.13fr 1fr 1fr;
  gap: 14px;
  border-top: 1px solid var(--control-line);
  margin-top: 47px;
  padding-top: 18px;
  max-width: 560px;
}
.auth-facts div { display: flex; flex-direction: column-reverse; gap: 3px; }
.auth-facts dt { color: var(--muted); font-size: .83rem; }
.auth-facts dd { font-size: clamp(1.18rem, 2.75vw, 2rem); font-weight: 600; letter-spacing: -.04em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.auth-box { padding: clamp(22px, 3.4vw, 42px); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.auth-box h2 { font-size: 2rem; margin-bottom: 26px; }
.auth-box .primary { margin-top: 22px; }
.auth-alternate { display: flex; gap: 0 7px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: .89rem; margin-top: 12px; }
.auth-alternate button { color: var(--ink); }

label { display: block; font-size: .89rem; font-weight: 620; margin-bottom: 7px; }
input {
  width: 100%;
  min-width: 0;
  height: 46px;
  border: 1px solid var(--control-line);
  border-radius: 5px;
  padding: 0 12px;
  background: var(--surface);
}
input::placeholder { color: var(--muted); opacity: 1; }
input + label { margin-top: 17px; }
.password-field { display: flex; gap: 4px; align-items: center; }
.password-field input { flex: 1; }
.password-field button { padding-inline: 9px; }
.help { color: var(--muted); font-size: .83rem; margin-top: 6px; }
.notice { padding: 9px 0 9px 12px; border-left: 2px solid var(--control-line); margin-top: 13px; color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.notice[data-tone="error"] { color: var(--bad); border-color: var(--bad); }
.notice a { font-weight: 650; }

.page { padding-block: clamp(32px, 6vw, 73px) 64px; }
.page-heading { margin-bottom: 38px; border-bottom: 1px solid var(--line); padding-bottom: 30px; }
.page-heading p { color: var(--muted); margin-top: 12px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); grid-template-areas: "history create"; align-items: start; gap: clamp(22px, 3.3vw, 46px); }
.history { grid-area: history; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-heading span { color: var(--muted); font-size: .88rem; }
.filters { display: flex; gap: 12px; flex-wrap: wrap; margin-block: 8px 14px; }
.filters button {
  min-height: 44px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 610;
  padding: 0 6px;
}
.filters button:hover, .filters button[aria-pressed="true"] { color: var(--ink); border-color: var(--control-line); }
.filters button[aria-pressed="true"] { border-color: var(--ink); }
.ledger { border: 1px solid var(--line); border-radius: 7px; overflow: clip; background: var(--surface); }
table { border-collapse: collapse; width: 100%; text-align: left; table-layout: fixed; }
th, td { padding: 12px 13px; vertical-align: middle; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .81rem; font-weight: 620; background: var(--paper); line-height: 1.25; }
td { font-size: .9rem; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--hover); }
#history-table th:first-child { width: 44%; }
#history-table th:nth-child(2) { width: 23%; }
#history-table th:nth-child(3) { width: 13%; }
#history-table th:nth-child(4) { width: 20%; }
.site-link { display: block; color: var(--ink); font-weight: 620; text-decoration: none; overflow-wrap: anywhere; line-height: 1.35; }
.site-link:hover { text-decoration: underline; }
.site-path { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .78rem; margin-top: 3px; font-weight: 400; }
.status { display: inline-flex; gap: 7px; align-items: center; font-size: .84rem; line-height: 1.2; font-weight: 620; }
.status::before { content: ""; flex: 0 0 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status[data-status="active"] { color: var(--warning); }
.status[data-status="active"]::before { background: transparent; border: 1px solid currentColor; }
.status[data-status="completed"] { color: var(--good); }
.status[data-status="failed"] { color: var(--bad); }
.date { color: var(--muted); font-size: .8rem; }
.table-state { padding: 32px 14px; color: var(--muted); font-size: .91rem; }
.table-state a { display: inline-block; margin-top: 5px; font-weight: 620; color: var(--ink); }
.skeleton { display: block; height: 10px; width: 70%; border-radius: 3px; background: var(--paper); }
.skeleton.wide { width: 86%; height: 12px; }
#history-table[aria-busy="true"] td { height: 49px; }
.pagination { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 14px; }
.pagination span { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .84rem; white-space: nowrap; }

.create-panel { grid-area: create; padding: 23px 24px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.create-panel h2 { margin-bottom: 22px; }
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-block: 15px 19px; }
.create-note { color: var(--muted); font-size: .82rem; margin-top: 13px; }
.create-panel .notice { margin-block: 0 12px; }

.back-link { display: inline-flex; align-items: center; min-height: 40px; color: var(--muted); font-size: .91rem; margin-bottom: 11px; }
.detail-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 28px; }
.detail-title > div { min-width: 0; }
.detail-title h1 { overflow-wrap: anywhere; font-size: clamp(2.15rem, 4.7vw, 3.8rem); }
.detail-url { overflow-wrap: anywhere; margin-top: 9px; color: var(--muted); }
.summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-block: 1px solid var(--line); }
.summary > div { padding: 17px 12px 16px 16px; min-width: 0; }
.summary > div:first-child { padding-left: 0; }
.summary > div + div { border-left: 1px solid var(--line); }
.summary > div > span { display: block; color: var(--muted); font-size: .86rem; margin-bottom: 6px; }
.summary strong { display: block; min-height: 28px; font-size: 1.38rem; font-weight: 650; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.progress-strip { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; margin-block: 15px 34px; }
.progress-strip span { height: 8px; border-radius: 1px; background: var(--line); }
.progress-strip .good { background: var(--good-fill); }
.progress-strip .bad { background: var(--bad-fill); }
.attempts-heading { margin-bottom: 12px; }
.attempt-table th:nth-child(1) { width: 7%; }
.attempt-table th:nth-child(2) { width: 44%; }
.attempt-table th:nth-child(3) { width: 19%; }
.attempt-table th:nth-child(4) { width: 30%; }
.http-code { font: 600 .91rem var(--mono); }
.http-code[data-outcome="good"] { color: var(--good); }
.http-code[data-outcome="bad"] { color: var(--bad); }
.attempt-error { color: var(--bad); font-size: .79rem; display: block; line-height: 1.4; padding-top: 3px; overflow-wrap: anywhere; }

.settings-body { max-width: 650px; }
.connection-panel { padding: 24px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.connection-panel ol { padding-left: 24px; margin: 17px 0 22px; color: var(--muted); }
.connection-panel li + li { margin-top: 7px; }
.connection-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.telegram-result { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.telegram-result span { color: var(--muted); font-size: .84rem; }

@media (max-width: 950px) {
  .frame { width: calc(100% - 48px); }
  .workspace { grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; }
  #history-table th:nth-child(3), #history-table td:nth-child(3) { display: none; }
  #history-table th:first-child { width: 48%; }
  #history-table th:nth-child(2), #history-table th:nth-child(4) { width: 26%; }
  .auth-layout { gap: 28px; }
}

@media (max-width: 760px) {
  .topbar-inner { min-height: 58px; }
  .frame { width: calc(100% - 36px); }
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-areas: "create" "history"; gap: 27px; }
  .page-heading { margin-bottom: 24px; padding-bottom: 20px; }
  #history-table th:nth-child(3), #history-table td:nth-child(3) { display: table-cell; }
  #history-table th:first-child { width: 41%; }
  #history-table th:nth-child(2) { width: 24%; }
  #history-table th:nth-child(3) { width: 15%; }
  #history-table th:nth-child(4) { width: 20%; }
  .auth-layout { min-height: 0; grid-template-columns: minmax(0, 1fr); padding-block: 42px 56px; max-width: 570px; gap: 24px; }
  .auth-intro { padding-bottom: 0; }
  .auth-intro h1 { font-size: clamp(2.15rem, 8vw, 3.8rem); }
  .auth-intro > p { margin-top: 10px; max-width: 50ch; }
  .auth-facts { display: none; }
}

@media (max-width: 470px) {
  .frame { width: calc(100% - 32px); }
  .topbar-inner { gap: 5px; }
  .navigation { gap: 13px; }
  .topbar-actions { gap: 0; }
  .topbar-actions .quiet { padding-inline: 9px; }
  .page { padding-top: 28px; }
  .page-heading h1 { font-size: clamp(2.04rem, 9vw, 2.7rem); }
  .create-panel, .connection-panel { padding: 18px; }
  #history-table th:nth-child(3), #history-table td:nth-child(3),
  #history-table th:nth-child(4), #history-table td:nth-child(4) { display: none; }
  #history-table th:first-child { width: 59%; }
  #history-table th:nth-child(2) { width: 41%; }
  .filters { gap: 5px; }
  th, td { padding-inline: 9px; }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary > div:nth-child(3) { padding-left: 0; border-left: none; }
  .summary > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .detail-title { flex-wrap: wrap; }
  .detail-title h1 { font-size: 2.2rem; }
  .attempt-table th:nth-child(1) { width: 10%; }
  .attempt-table th:nth-child(2) { width: 43%; }
  .attempt-table th:nth-child(3) { width: 20%; }
  .attempt-table th:nth-child(4) { width: 27%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; }
}
