:root {
  color-scheme: light dark;
  --blue: #1247e6;
  --bg: #f4f6fb;
  --surface: #fff;
  --text: #111a33;
  --muted: #5b6480;
  --line: #d9deec;
  --code: #0a35b8;
  --danger: #b3261e;
  --notice: #e6ecff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --blue: #2f62f5;
    --bg: #0b1020;
    --surface: #151c33;
    --text: #eef1fb;
    --muted: #a3acc8;
    --line: #2a3354;
    --code: #8fb0ff;
    --danger: #ff8a80;
    --notice: #1d2a55;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 480px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom));
}

h1 { font-size: 1.35rem; margin: 0; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }

.welcome { display: flex; flex-direction: column; align-items: center; gap: 14px; padding-top: 24px; text-align: center; }
.welcome img { border-radius: 20px; }
.welcome form, .welcome details { width: 100%; text-align: left; }
.welcome summary { text-align: center; }
.welcome details form { margin-top: 12px; }

form, dialog[open] { display: flex; flex-direction: column; gap: 12px; }
form p { margin: 0; }
fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .9rem; }
details > label { margin-top: 10px; }
summary { cursor: pointer; color: var(--muted); }

input, select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 400;
}

button {
  min-height: 46px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--blue);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button:disabled { opacity: .55; cursor: progress; }
button.secondary { background: var(--surface); color: var(--text); border-color: var(--line); }
button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button.link { background: none; color: var(--muted); text-decoration: underline; }
button.small { min-height: 36px; padding: 6px 12px; font-size: .85rem; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

.muted { color: var(--muted); margin: 0; }
.small-text { font-size: .85rem; font-weight: 400; }
.error { color: var(--danger); margin: 0; }
.error:empty { display: none; }
.fatal { text-align: center; padding: 32px 16px; }

.notice {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  width: 100%;
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--notice);
  text-align: left;
  font-size: .9rem;
}

button.wide { width: 100%; }
legend { padding: 0; margin-bottom: 8px; font-weight: 600; font-size: .9rem; }
label.choice { flex-direction: row; align-items: center; gap: 10px; min-height: 32px; font-weight: 400; }
label.choice input { width: 20px; min-height: 20px; margin: 0; accent-color: var(--blue); }
.cloud-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }

header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
header img { border-radius: 9px; }
header h1 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.15rem; }
header img, header button { flex: none; }
#search { margin-bottom: 12px; }
.empty { text-align: center; padding: 48px 8px; }

ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}
button.copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  background: none;
  color: var(--text);
  padding: 6px 10px;
  text-align: left;
}
.issuer, .account { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account { color: var(--muted); font-size: .85rem; font-weight: 400; }
.code { color: var(--code); font-size: 2rem; font-weight: 700; letter-spacing: .06em; font-variant-numeric: tabular-nums; }
button.more { background: none; color: var(--muted); min-width: 40px; padding: 0; font-size: 1.4rem; }

.ring { width: 38px; height: 38px; flex: none; }
.ring circle { fill: none; stroke-width: 3; }
.ring .track { stroke: var(--line); }
.ring .arc { stroke: var(--blue); transform: rotate(-90deg); transform-origin: center; }
.ring text { fill: var(--muted); font-size: 11px; text-anchor: middle; }
.ring.ending .arc { stroke: var(--danger); }
.ring.ending text { fill: var(--danger); }

button.floating {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  min-width: 200px;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgb(0 0 0 / .25);
}

dialog {
  width: min(440px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--bg);
  color: var(--text);
}
dialog::backdrop { background: rgb(5 8 20 / .65); }
dialog p { margin: 0; }
dialog > * { flex: none; }
video { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 16px; background: #000; }
.preview { display: flex; flex-direction: column; align-items: center; text-align: center; }

.toast, .update {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: .9rem;
  width: max-content;
  max-width: calc(100vw - 24px);
}
.toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
.update { top: max(8px, env(safe-area-inset-top)); display: flex; align-items: center; gap: 12px; }
