:root {
  --bg: #171029;
  --surface: #271e45;
  --surface-deep: #1f1738;
  --line: rgba(244, 240, 255, 0.08);
  --text: #f4f0ff;
  --text-2: #cfc8e8;
  --text-3: #8d84ab;
  --gold: #ffc533;
  --gold-light: #fff0a0;
  --on-gold: #2a1600;
  --warn: #ff7b72;
  --radius: 18px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB",
    "Helvetica Neue", "Noto Sans SC", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding:
    calc(env(safe-area-inset-top) + 14px)
    calc(env(safe-area-inset-right) + 20px)
    calc(env(safe-area-inset-bottom) + 20px)
    calc(env(safe-area-inset-left) + 20px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-weight: 600;
  font-size: 16px;
  color: var(--text-2);
}
.brand img { border-radius: 8px; }

main { flex: 1; padding-top: 28px; }

h1 {
  margin: 0 0 14px;
  font-size: 30px;
  line-height: 1.22;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: pre-line;
  text-wrap: balance;
}

.lead, .hint, .status, .error, .note, .result, .confirm p { white-space: pre-line; }
.lead { margin: 0 0 24px; color: var(--text-2); }
.hint { margin: 8px 0 0; color: var(--text-3); font-size: 15px; }
.status { color: var(--text-3); }
.error { min-height: 1.5em; margin: 10px 0 0; color: var(--warn); font-size: 15px; }
.error:empty { min-height: 0; }

.waiting::after {
  content: "";
  display: inline-block;
  width: 28px;
  height: 2px;
  margin-left: 10px;
  vertical-align: middle;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  background-size: 200% 100%;
  animation: sweep 1.4s linear infinite;
}
@keyframes sweep { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* Pairing */

.steps { list-style: none; margin: 8px 0 28px; padding: 0; }
.steps li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}
.steps li:last-child { border-bottom: 0; }
.glyph { display: inline-flex; color: var(--gold); flex: none; }

.code {
  margin: 0;
  font: 600 clamp(30px, 10vw, 40px)/1.2 var(--mono);
  letter-spacing: 0.06em;
  color: var(--gold);
  word-break: keep-all;
  white-space: nowrap;
}

.sas {
  margin: 8px 0 20px;
  font-size: clamp(52px, 18vw, 72px);
  line-height: 1.1;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: var(--gold);
}

.label { display: block; margin: 0 0 8px; color: var(--text-3); font-size: 15px; }

.field {
  width: 100%;
  min-height: 54px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 19px;
  outline: none;
}
.field:focus { border-color: rgba(255, 197, 51, 0.7); }
.code-input { font-family: var(--mono); letter-spacing: 0.08em; text-transform: uppercase; }
.code-input::placeholder { color: var(--text-3); opacity: 0.6; }

/* Buttons */

button { font: inherit; cursor: pointer; }
button:disabled { opacity: 0.55; cursor: default; }

.primary, .secondary, .deny, .quiet {
  width: 100%;
  min-height: 54px;
  padding: 12px 18px;
  border: 0;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 600;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.primary:active:not(:disabled), .secondary:active:not(:disabled), .deny:active:not(:disabled) {
  transform: scale(0.985);
  filter: brightness(0.94);
}
.primary {
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  color: var(--on-gold);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 6px 18px rgba(255, 197, 51, 0.16);
}
.secondary { background: rgba(244, 240, 255, 0.08); color: var(--text); }
.deny { background: rgba(255, 123, 114, 0.13); color: var(--warn); }
.quiet { background: transparent; color: var(--text-3); }

.link {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--gold);
  font-size: 15px;
}
.link.warn { color: var(--text-3); }

.actions { display: grid; gap: 10px; margin-top: 24px; }

/* Requests */

.list h1 { margin-bottom: 20px; }

.card {
  position: relative;
  overflow: hidden;
  margin: 0 0 16px;
  padding: 18px 18px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.card.focus { box-shadow: 0 0 0 1px rgba(255, 197, 51, 0.45); }
.card.done { opacity: 0.6; }
.card.done .actions { display: none; }

.bar {
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  transform-origin: left center;
  transition: transform 1s linear;
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-3);
  font-size: 14px;
}
.time { font-variant-numeric: tabular-nums; white-space: nowrap; }

.ask {
  margin: 8px 0 14px;
  font-size: 21px;
  line-height: 1.32;
  font-weight: 650;
  overflow-wrap: anywhere;
}
.ask .key { color: var(--gold); }

.fields { margin: 0; }
.fields dt { margin-top: 12px; color: var(--text-3); font-size: 13px; }
.fields dd { margin: 3px 0 0; color: var(--text-2); font-size: 15px; overflow-wrap: anywhere; }
.fields dd.mono { font-family: var(--mono); font-size: 13.5px; }

.command {
  margin: 4px 0 0;
  max-height: 4.6em;
  overflow: hidden;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-deep);
  color: var(--text);
  font: 13.5px/1.5 var(--mono);
  white-space: pre-wrap;
  word-break: break-all;
}
.command.open { max-height: none; }

.note {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 197, 51, 0.08);
  color: var(--text-2);
  font-size: 15px;
}

.card .actions { margin-top: 18px; }
.result { margin: 10px 0 0; color: var(--text); font-weight: 600; text-align: center; }
.result:empty { display: none; }
.result.failed { color: var(--warn); font-weight: 500; }

.empty { padding: 48px 0 24px; }
.empty-title { margin: 0; font-size: 21px; font-weight: 600; color: var(--text-2); }

/* Footer */

.footer { padding-top: 28px; color: var(--text-3); font-size: 14px; }
.footer:empty { display: none; }
.row { display: flex; align-items: center; gap: 10px; }
.row.spread { justify-content: space-between; }
.row > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.confirm p { margin: 0 0 12px; color: var(--text-2); }
.confirm .row > button { flex: 1; }

[hidden] { display: none !important; }

@media (max-width: 350px) {
  h1 { font-size: 26px; }
  .app { padding-left: calc(env(safe-area-inset-left) + 16px); padding-right: calc(env(safe-area-inset-right) + 16px); }
}

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