/* Design tokens follow shadcn/ui's default "zinc" theme. */
:root {
  color-scheme: light;
  --background: #ffffff;
  --foreground: #09090b;
  --card: #ffffff;
  --muted: #f4f4f5;
  --muted-foreground: #71717a;
  --border: #e4e4e7;
  --input: #e4e4e7;
  --primary: #18181b;
  --primary-foreground: #fafafa;
  --secondary: #f4f4f5;
  --accent: #f4f4f5;
  --ring: #a1a1aa;
  --destructive: #dc2626;
  --destructive-soft: #fef2f2;
  --success: #16a34a;
  --radius: 0.5rem;
  font-family: ui-sans-serif, system-ui, "Segoe UI Variable Text", "Segoe UI", -apple-system, sans-serif;
  color: var(--foreground);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --background: #09090b;
    --foreground: #fafafa;
    --card: #09090b;
    --muted: #27272a;
    --muted-foreground: #a1a1aa;
    --border: #27272a;
    --input: #27272a;
    --primary: #fafafa;
    --primary-foreground: #18181b;
    --secondary: #27272a;
    --accent: #27272a;
    --ring: #52525b;
    --destructive: #f87171;
    --destructive-soft: #2a1215;
    --success: #4ade80;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--background); }
body { margin: 0; min-width: 280px; min-height: 100vh; display: flex; flex-direction: column; font-size: 15px; line-height: 1.6; }
main { flex: 1; }
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
svg { flex: none; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted-foreground); }
.small { font-size: 12px; }

.container { width: min(100% - 40px, 820px); margin-inline: auto; }

/* Header */
.site-header { border-bottom: 1px solid var(--border); }
.header-row { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; text-decoration: none; letter-spacing: -.01em; }
.brand img { border-radius: 7px; width: 28px; height: 28px; }
.header-actions { display: flex; align-items: center; gap: 12px; }

/* Intro */
.intro { padding: 64px 0 36px; }
h1 { font-size: 38px; line-height: 1.15; font-weight: 700; letter-spacing: -.03em; }
.intro p { margin-top: 12px; font-size: 17px; max-width: 520px; }
body[data-state="inbox"] .intro { padding: 48px 0 28px; }
body[data-state="inbox"] .intro p { display: none; }
body[data-state="inbox"] h1 { font-size: 30px; }

/* Card */
.card { background: var(--card); border: 1px solid var(--border); border-radius: calc(var(--radius) + 6px); box-shadow: 0 1px 2px #0000000d; }
.card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 32px 36px 0; }
.card-title { font-size: 21px; font-weight: 600; letter-spacing: -.02em; line-height: 1.3; }
.card-desc { color: var(--muted-foreground); margin-top: 6px; }
.card-content { padding: 32px 36px 36px; }

/* Badge */
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 9999px; padding: 2px 10px; font-size: 12px; font-weight: 600; line-height: 18px; white-space: nowrap; border: 1px solid transparent; }
.badge-outline { border-color: var(--border); color: var(--foreground); }
.badge-secondary { background: var(--secondary); color: var(--foreground); padding: 0 8px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); display: inline-block; }
.dot-live { margin-right: 6px; vertical-align: 1px; animation: blink 2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .35; } }

/* Button */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 20px; border-radius: var(--radius); border: 1px solid transparent; font-size: 15px; font-weight: 500; white-space: nowrap; transition: background-color .15s, color .15s, opacity .15s; }
.btn:disabled { opacity: .5; cursor: wait; }
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { opacity: .9; }
.btn-outline { background: var(--background); border-color: var(--input); box-shadow: 0 1px 2px #0000000d; }
.btn-outline:hover, .btn-ghost:hover { background: var(--accent); }
.btn-ghost { background: transparent; }
.btn-sm { height: 38px; padding: 0 14px; font-size: 14px; }
.btn-block { width: 100%; height: 48px; margin-top: 8px; }
.btn-danger { color: var(--muted-foreground); }
.btn-danger:hover { color: var(--destructive); background: var(--destructive-soft); }

/* Inputs */
.field-label { display: block; font-size: 15px; font-weight: 500; margin-bottom: 10px; padding: 0; }
.field-hint { margin-top: 10px; font-size: 14px; color: var(--muted-foreground); }
.field { border: 0; margin: 0 0 28px; padding: 0; min-width: 0; }
.input { width: 100%; height: 44px; padding: 0 14px; background: transparent; border: 1px solid var(--input); border-radius: var(--radius); box-shadow: 0 1px 2px #0000000d; transition: border-color .15s, box-shadow .15s; }
.input:focus { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 35%, transparent); }
.input::placeholder { color: var(--muted-foreground); }
.mono { font-family: ui-monospace, "Cascadia Mono", SFMono-Regular, Consolas, monospace; font-size: 15px; background: var(--muted); text-overflow: ellipsis; }
.form-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; }
.select-wrap { position: relative; }
.select-wrap select { appearance: none; padding-right: 36px; background: var(--background); }
.select-wrap::after { content: ""; position: absolute; right: 16px; top: 16px; width: 6px; height: 6px; border-right: 1.5px solid var(--muted-foreground); border-bottom: 1.5px solid var(--muted-foreground); transform: rotate(45deg); pointer-events: none; }

/* Segmented control (shadcn ToggleGroup / Tabs look) */
.segmented { display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: 4px; padding: 5px; background: var(--muted); border-radius: var(--radius); }
.segmented label { position: relative; display: flex; align-items: center; justify-content: center; height: 38px; border-radius: calc(var(--radius) - 2px); font-size: 15px; font-weight: 500; color: var(--muted-foreground); cursor: pointer; transition: background-color .15s, color .15s; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented label:hover { color: var(--foreground); }
.segmented label:has(input:checked) { background: var(--background); color: var(--foreground); box-shadow: 0 1px 3px #0000001a, 0 1px 2px #0000000f; }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--ring); outline-offset: 1px; }

/* Loading */
.loading { display: flex; align-items: center; gap: 10px; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--foreground); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Expiry */
.expiry { margin-top: 24px; }
.expiry-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
time { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--foreground); }
.progress { height: 8px; border-radius: 9999px; background: var(--secondary); overflow: hidden; }
.progress span { display: block; height: 100%; width: 100%; background: var(--primary); border-radius: inherit; transition: width 1s linear, background-color .3s; }
.progress span.low { background: var(--destructive); }

.separator { height: 1px; background: var(--border); margin: 36px 0 28px; }

/* Messages */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
h3 { font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.empty { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 48px 20px; border: 1px dashed var(--border); border-radius: var(--radius); color: var(--muted-foreground); }
.empty strong { color: var(--foreground); font-weight: 600; margin-top: 6px; }
.empty p { font-size: 14px; max-width: 340px; }

.messages { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.messages:empty { display: none; }
details { overflow-wrap: anywhere; }
details + details { border-top: 1px solid var(--border); }
summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 18px 20px; transition: background-color .15s; }
summary::-webkit-details-marker { display: none; }
summary:hover, details[open] summary { background: var(--muted); }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; font-weight: 600; background: var(--secondary); border: 1px solid var(--border); text-transform: uppercase; }
.message-text { min-width: 0; }
.subject { display: block; font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.message-meta { display: block; font-size: 14px; color: var(--muted-foreground); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.message-time { font-size: 13px; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.message-body { white-space: pre-wrap; padding: 20px 20px 24px 76px; border-top: 1px solid var(--border); line-height: 1.6; }
details.fresh summary { animation: fresh 1.2s ease-out; }
@keyframes fresh { from { background: color-mix(in srgb, var(--success) 14%, transparent); } }

/* Alert */
.alert { margin-top: 24px; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; }
.alert.error { color: var(--destructive); border-color: color-mix(in srgb, var(--destructive) 40%, transparent); background: var(--destructive-soft); }

/* Steps */
.steps { list-style: none; margin: 24px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.steps li { display: flex; gap: 14px; padding: 18px; border: 1px solid var(--border); border-radius: calc(var(--radius) + 2px); }
.step-num { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 7px; font-size: 13px; font-weight: 600; background: var(--secondary); }
.steps strong { font-size: 15px; font-weight: 600; }
.steps p { font-size: 14px; margin-top: 2px; }
body[data-state="inbox"] .steps { display: none; }

/* Workspace: address history beside the inbox */
body[data-state="inbox"] .container { width: min(100% - 40px, 1140px); }
.workspace { display: grid; gap: 24px; align-items: start; }
body[data-state="inbox"] .workspace { grid-template-columns: 320px minmax(0, 1fr); }
.history { padding: 24px 20px; position: sticky; top: 24px; }
.history-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; padding: 0 4px; }
.history-title { font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 10px; letter-spacing: -.01em; }
.history-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.history-list button { width: 100%; text-align: left; display: grid; gap: 4px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid transparent; background: transparent; transition: background-color .15s, border-color .15s; }
.history-list button:hover { background: var(--muted); }
.history-list button[aria-current="true"] { background: var(--muted); border-color: var(--border); }
.history-address { font-family: ui-monospace, "Cascadia Mono", SFMono-Regular, Consolas, monospace; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted-foreground); }
.history-meta .unread { color: var(--foreground); font-weight: 600; }
.history-empty { font-size: 14px; padding: 0 4px; }
.history-list:not(:empty) + .history-empty { display: none; }
.history-foot { display: grid; gap: 8px; justify-items: start; margin-top: 16px; padding: 16px 4px 0; border-top: 1px solid var(--border); }
.history-foot .btn { margin-left: -14px; }
.history-list:empty ~ .history-foot .btn { display: none; }
.create-row { display: flex; gap: 12px; margin-top: 8px; }
.create-row .btn-block { margin-top: 0; flex: 1; }
#expires-on { margin-left: 4px; }

.site-footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px 16px; padding: 48px 0 40px; font-size: 13px; }

@media (max-width: 900px) {
  body[data-state="inbox"] .workspace { grid-template-columns: 1fr; }
  .history { position: static; order: 2; }
}
@media (max-width: 640px) {
  .container, body[data-state="inbox"] .container { width: calc(100% - 32px); }
  .create-row { flex-direction: column-reverse; }
  .steps { grid-template-columns: 1fr; }
  .badge-outline { display: none; }
  .intro { padding: 36px 0 24px; }
  h1, body[data-state="inbox"] h1 { font-size: 28px; }
  body[data-state="inbox"] .intro { padding: 32px 0 20px; }
  .card-header { padding: 24px 20px 0; }
  .card-content { padding: 24px 20px 24px; }
  summary { padding: 14px 16px; gap: 12px; }
  .message-body { padding: 16px; }
}
@media (max-width: 420px) {
  .form-row { grid-template-columns: 1fr; }
  .message-time { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
