/* The key page. Its own document on its own origin: the tokens are a copy of web/css/theme.css (dark only),
   so this page never loads styles from the T2T site. Contrast on --bg: --fg 16.3:1, --muted 6.29:1,
   --accent 8.18:1, --accent2-text 8.36:1, --warn 9.19:1, --err 7.27:1. No animation. */

:root {
  --bg: #090a11;
  --bg2: #101317;
  --bg3: #161a24;
  --line: #20252c;
  --line-strong: #2e3542;
  --fg: #eae8f2;
  --muted: #8b929c;
  --accent: #c8a06a;
  --accent2: #8272ff;
  --accent2-text: #a99cff;
  --ok: #3fb970;
  --warn: #e5a53a;
  --err: #ff6b8b;
  --grad: linear-gradient(135deg, var(--accent), var(--accent2));
  --tint-warn: rgba(229, 165, 58, 0.12);
  --tint-err: rgba(255, 107, 139, 0.12);
  --serif: "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --hit: 44px;
  color-scheme: dark;
}

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

html,
body {
  margin: 0;
  overflow-x: clip;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
}

.k-app {
  min-height: 100vh;
}

.k-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg2);
}

.k-brand {
  font-family: var(--serif);
  font-size: 1.05rem;
}

.k-brand b {
  color: var(--accent);
  font-weight: 600;
}

.k-lang {
  display: flex;
  gap: 4px;
}

.k-main {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 48px;
  outline: none;
}

h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 12px;
}

h1 {
  font-size: clamp(1.4rem, 1.2rem + 1.5vw, 1.9rem);
  margin-top: 8px;
}

h2 {
  font-size: 1.15rem;
}

h3 {
  font-size: 1rem;
  margin-top: 16px;
}

p {
  margin: 0 0 12px;
}

a {
  color: var(--accent2-text);
  text-underline-offset: 0.18em;
}

:focus {
  outline: none;
}

:focus-visible {
  outline: 3px solid var(--accent2-text);
  outline-offset: 2px;
  border-radius: 4px;
}

[tabindex="-1"]:focus:not(:focus-visible) {
  outline: none;
}

[hidden] {
  display: none !important;
}

.k-sr,
.k-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

.k-origin {
  display: inline-block;
  margin: 0 0 8px;
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.88rem;
}

.k-origin b {
  color: var(--fg);
  font-weight: 600;
}

.k-lead {
  color: var(--fg);
  font-size: 1.02rem;
}

.k-hint {
  color: var(--muted);
  font-size: 0.92rem;
}

.k-mono {
  font-family: var(--mono);
  font-size: 0.92em;
  overflow-wrap: anywhere;
}

.k-addr {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg3);
}

.k-card {
  margin: 16px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg2);
}

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

.k-explain,
.k-notes,
.k-list {
  margin: 0 0 12px;
  padding-left: 1.2em;
}

.k-explain li,
.k-notes li,
.k-list li {
  margin-bottom: 6px;
}

.k-notes {
  color: var(--muted);
}

.k-rows {
  margin: 16px 0;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--bg2);
}

.k-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.k-row:last-child {
  border-bottom: 0;
}

.k-row dt {
  color: var(--muted);
  font-size: 0.86rem;
}

.k-row dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.k-row.is-strong dd {
  font-weight: 600;
  color: var(--fg);
}

.k-fields {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px 12px;
}

.k-fields dt {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.82rem;
  margin-top: 6px;
}

.k-fields dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.k-type {
  color: var(--muted);
}

.k-warn {
  padding: 10px 12px;
  border: 1px solid var(--warn);
  border-radius: 8px;
  background: var(--tint-warn);
  color: var(--fg);
}

.k-error {
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid var(--err);
  border-radius: 8px;
  background: var(--tint-err);
  color: var(--fg);
}

.k-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px -16px 0;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.k-actions .k-btn {
  flex: 1 1 140px;
}

.k-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--hit);
  min-width: var(--hit);
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--bg3);
  color: var(--fg);
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}

.k-btn:hover {
  border-color: var(--accent2);
}

.k-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.k-btn-primary {
  border: 0;
  background: var(--grad);
  color: var(--bg);
  font-weight: 600;
}

.k-btn-danger {
  background: transparent;
  border-color: var(--err);
  color: var(--err);
}

.k-btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.k-lang-btn {
  padding: 0 8px;
  font-size: 0.85rem;
}

.k-lang-btn[aria-pressed="true"] {
  color: var(--fg);
  border-color: var(--line-strong);
}

.k-card .k-btn + .k-btn,
.k-plain .k-btn {
  margin: 8px 8px 0 0;
}

.k-form {
  display: grid;
  gap: 12px;
  margin: 12px 0;
}

.k-field {
  display: grid;
  gap: 4px;
}

.k-field label {
  font-weight: 600;
}

.k-field .k-hint {
  margin: 0;
}

.k-input {
  width: 100%;
  min-height: var(--hit);
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--bg3);
  color: var(--fg);
  font: inherit;
}

input[type="file"].k-input {
  display: block;
  line-height: 26px;
}

textarea.k-input {
  min-height: 88px;
  resize: vertical;
}

.k-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 12px 0;
}

.k-check input {
  width: 24px;
  height: 24px;
  margin: 10px;
  flex: none;
  accent-color: var(--accent);
}

.k-check label {
  padding-top: 8px;
}

.k-pre {
  max-height: 220px;
  overflow: auto;
  margin: 8px 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg3);
  font-family: var(--mono);
  font-size: 0.8rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.k-demo-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.k-demo-list .k-btn {
  width: 100%;
  justify-content: flex-start;
}

@media (min-width: 560px) {
  .k-row {
    grid-template-columns: 11em minmax(0, 1fr);
    gap: 12px;
  }

  .k-fields {
    grid-template-columns: 12em minmax(0, 1fr);
  }

  .k-fields dt {
    margin-top: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
