:root {
  color-scheme: dark;
  --bg: #000;
  --panel: #090909;
  --text: #f5f5f5;
  --muted: #a1a1a1;
  --border: #262626;
  --border-focus: #fff;
  --input-bg: #111;
  --input-border: #3b3b3b;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 280px; min-height: 100%; background: var(--bg); }
body {
  min-width: 280px;
  min-height: 100svh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.shell {
  display: flex;
  min-height: 100svh;
  align-items: center;
  justify-content: center;
  padding: max(32px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}
.app-card {
  width: 100%;
  max-width: 460px;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 1px 0 #ffffff08 inset;
}
.app-header { margin-bottom: 24px; }
.status-kicker {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .11em;
  line-height: 1.5;
  text-transform: uppercase;
}
h1 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 28px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -.035em;
  overflow-wrap: anywhere;
}
.status-message {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  text-wrap: pretty;
}
.credential-form { display: flex; flex-direction: column; gap: 10px; margin: 0; }
.secure-details { display: flex; flex-direction: column; gap: 24px; margin-bottom: 14px; }
.origin-line {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0e0e0e;
  overflow-wrap: anywhere;
}
.origin-line span { color: var(--muted); font-size: 12px; line-height: 1.3; }
.origin-line strong { color: var(--text); font-family: var(--font-mono); font-size: 13px; font-weight: 400; line-height: 1.45; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { width: 100%; margin: 0 0 18px; padding: 0; font-size: 12px; font-weight: 500; line-height: 1.5; }
legend span:last-child { float: right; color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.field-list { display: flex; flex-direction: column; gap: 18px; }
.field-row { display: flex; min-width: 0; flex-direction: column; gap: 8px; }
.field-row label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.required-mark { flex-shrink: 0; color: var(--muted); font-size: 11px; font-weight: 400; }
.field-row :is(input, textarea, select) {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  outline: none;
  color: var(--text);
  background: var(--input-bg);
  caret-color: var(--text);
  font-size: 16px;
  line-height: 1.4;
  transition: border-color 120ms ease, background-color 120ms ease;
}
.field-row :is(input, textarea, select):hover:not(:disabled) { border-color: #626262; }
.field-row :is(input, textarea, select):focus { border-color: var(--border-focus); background-color: #151515; }
.field-row :is(input, textarea, select):focus-visible { outline: 2px solid var(--border-focus); outline-offset: 3px; }
.field-row :is(input, textarea, select):disabled { opacity: .55; }
.field-row input:-webkit-autofill,
.field-row input:-webkit-autofill:hover,
.field-row input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px #111 inset;
  caret-color: var(--text);
}
.field-row textarea { min-height: 112px; resize: vertical; }
.field-row small { color: var(--muted); font-size: 12px; line-height: 1.5; }
.field-row .field-error { color: var(--text); }
.field-row .segmented-code-input {
  min-height: 58px;
  padding-inline: 18px;
  font-family: var(--font-mono);
  font-size: 24px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: .42em;
  line-height: 1;
  text-align: center;
}
.view-stack, .view-section { display: grid; gap: 18px; min-width: 0; }
.view-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr)); gap: 14px; min-width: 0; }
.view-section { padding: 16px; border: 1px solid var(--border); border-radius: 16px; background: #0c0c0c; }
.view-section h2 { margin: 0; font-size: 15px; line-height: 1.3; }
.view-text { margin: 0; color: var(--text); font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.view-text[data-tone="muted"] { color: var(--muted); }
.view-divider { width: 100%; margin: 0; border: 0; border-top: 1px solid var(--border); }
.field-row:has(input[type="checkbox"]) { position: relative; min-height: 48px; justify-content: center; }
.field-row:has(input[type="checkbox"]) label {
  align-items: center;
  min-height: 48px;
  padding-left: 42px;
  padding-right: 12px;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  background: var(--input-bg);
  cursor: pointer;
}
.field-row input[type="checkbox"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 42px;
  height: 48px;
  margin: 0;
  padding: 0;
  appearance: none;
  background: transparent;
  border: 0;
  border-radius: 8px 0 0 8px;
  cursor: pointer;
}
.field-row input[type="checkbox"]::before {
  content: '';
  position: absolute;
  top: 15px;
  left: 14px;
  width: 18px;
  height: 18px;
  border: 1px solid #737373;
  border-radius: 4px;
  background: #151515;
}
.field-row input[type="checkbox"]:checked::before { background: var(--text); border-color: var(--text); }
.field-row input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  top: 18px;
  left: 20px;
  width: 5px;
  height: 9px;
  border: solid #111;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.field-row input[type="range"] { accent-color: var(--text); padding: 0; }
.field-row [aria-invalid="true"], .field-row:has([aria-invalid="true"]) label { border-color: var(--text); }
.field-row [aria-invalid="true"] { outline: 1px solid var(--text); outline-offset: 2px; }
.action-summary { margin: 0; color: var(--text); font-size: 15px; line-height: 1.55; }
.action-approval-row label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  cursor: pointer;
}
.action-approval-row input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--text); }

.send-button, .cancel-button {
  display: flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 13px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  text-align: center;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.send-button { color: #090909; background: #f5f5f5; border-color: #f5f5f5; font-weight: 600; }
.send-button:hover:not(:disabled) { background: #dedede; border-color: #dedede; }
.send-button:disabled { color: #b3b3b3; background: #242424; border-color: #333; cursor: default; }
.cancel-button { color: #bfbfbf; background: transparent; border-color: var(--border); }
.cancel-button:hover { color: var(--text); border-color: #505050; background: #111; }
.send-button:focus-visible, .cancel-button:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 3px; }
.privacy-note { margin: 20px 0 0; padding-top: 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; line-height: 1.55; text-align: center; text-wrap: pretty; }
.app-card[data-state="error"] .status-message,
.app-card[data-state="send-failed"] .status-message { color: #dedede; }

@media (max-width: 480px) {
  .shell { padding: max(20px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .app-card { padding: 24px 20px; border-radius: 14px; }
  h1 { font-size: 24px; }
}
@media (max-width: 340px) {
  .app-card { padding: 22px 16px; }
  .origin-line { padding: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
@media (forced-colors: active) {
  .field-row input[type="checkbox"] { appearance: auto; }
  .field-row input[type="checkbox"]::before, .field-row input[type="checkbox"]::after { display: none; }
}
