/* Стиль «Сумерки» */
@font-face { font-family: Onest; font-weight: 400; font-display: swap; src: url(fonts/onest-cyrillic-400-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Onest; font-weight: 400; font-display: swap; src: url(fonts/onest-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: Onest; font-weight: 500; font-display: swap; src: url(fonts/onest-cyrillic-500-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Onest; font-weight: 500; font-display: swap; src: url(fonts/onest-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: Onest; font-weight: 600; font-display: swap; src: url(fonts/onest-cyrillic-600-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Onest; font-weight: 600; font-display: swap; src: url(fonts/onest-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: Unbounded; font-weight: 500; font-display: swap; src: url(fonts/unbounded-latin-500-normal.woff2) format("woff2"); }

:root {
  --bg: #1D2330; --surface: #262E3D; --line: #3A4558; --track: #2C3545;
  --text: #E4E8EF; --text-strong: #F1F4F8; --soft: #C3CAD6; --muted: #94A0B4;
  --accent: #8CC7B8; --accent-hover: #A9D8CB; --on-accent: #14201D;
  --error: #F0A3A3; --ok: #8CC7B8;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 400 16px/1.5 Onest, system-ui, -apple-system, "Segoe UI", sans-serif;
}
.wrap { max-width: 1040px; min-height: 100vh; margin: 0 auto; padding: 28px 24px 40px; display: flex; flex-direction: column; }
.wrap > main { width: 100%; }
.narrow { max-width: 420px; }

/* Шапка */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; color: var(--text); text-decoration: none; }
.brand svg { color: var(--accent); }
.top-right { display: flex; align-items: center; gap: 20px; font-size: 14px; color: var(--muted); min-width: 0; }
.top-right .email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

h1 { margin: 0; font-size: 22px; font-weight: 500; line-height: 1.3; }
h2 { margin: 0 0 6px; font-size: 16px; font-weight: 600; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); font-size: 14px; }
.soft { color: var(--soft); font-size: 14px; line-height: 1.5; }
.error { color: var(--error); font-size: 14px; min-height: 1.5em; margin: 8px 0 0; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

/* Поля и кнопки */
label { display: block; font-size: 14px; color: var(--soft); margin: 0 0 6px; }
input {
  width: 100%; height: 50px; padding: 0 14px; margin: 0 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: #1A202B; color: var(--text); font: inherit;
}
input::placeholder { color: #6E7A8F; }
input:focus { outline: none; border-color: var(--accent); }
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; width: 100%; height: 52px;
  padding: 0 24px; border: 0; border-radius: 14px; background: var(--accent); color: var(--on-accent);
  font: 600 16px Onest, system-ui, sans-serif; cursor: pointer; text-decoration: none;
}
button:hover { background: var(--accent-hover); }
button:disabled { opacity: .6; cursor: default; }
button.ghost { height: 46px; background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 500; font-size: 15px; border-radius: 12px; }
button.ghost:hover { background: #2C3545; }
button.link { width: auto; height: auto; padding: 0; background: none; color: var(--muted); font-weight: 400; font-size: 14px; }
button.link:hover { color: var(--text); background: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Вход */
.login { margin: auto; padding: 48px 0 12vh; }
.login h1 { margin-bottom: 8px; }
.login > .muted { margin-bottom: 24px; }

/* Код */
.view {
  margin: auto 0; padding: 48px 0; width: 100%;
  display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: 20px; align-items: stretch;
}
.card { background: var(--surface); border-radius: 24px; padding: 36px; }
.code-card { display: flex; flex-direction: column; }
.digits {
  display: flex; gap: .3em; align-items: baseline; margin-top: 28px;
  font: 500 clamp(52px, 8vw, 92px)/1 Unbounded, Onest, sans-serif; color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}
.digits.small { font-size: 40px; margin-top: 16px; }
.digits-btn { width: auto; height: auto; padding: 0; background: none; border-radius: 8px; cursor: copy; align-self: flex-start; color: var(--text-strong); }
.digits-btn:hover { background: none; color: #fff; }
.meter { margin-top: 28px; height: 6px; background: var(--track); border-radius: 3px; overflow: hidden; }
.meter div { height: 100%; background: var(--accent); border-radius: 3px; transition: width 1s linear; }
.meter.low div { background: #E6C98F; }
.timer { margin: 12px 0 0; font-size: 15px; color: var(--muted); }
.timer b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.code-card .primary { margin-top: auto; gap: 10px; }
.code-card .hint { margin: 6px 0 32px; }
.code-card .primary.copied { background: var(--accent-hover); }

.access-card { display: flex; flex-direction: column; gap: 18px; }
.access-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.access-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.state { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px; border-radius: 15px; background: #1F2633; font-size: 13px; color: var(--muted); white-space: nowrap; }
.state i { width: 8px; height: 8px; border-radius: 50%; background: #5C6880; }
.access-card p { margin: 0; flex: 1; }
.access-card button { margin-top: auto; gap: 10px; }
button.secondary { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
button.secondary:hover { background: #24363A; }
button.outline-danger { background: transparent; color: var(--error); border: 1.5px solid #8A5A64; }
button.outline-danger:hover { background: #2E2630; }
.countdown { font: 500 52px/1 Unbounded, Onest, sans-serif; color: var(--accent); font-variant-numeric: tabular-nums; }
.access-card.open { box-shadow: inset 0 0 0 1.5px var(--accent); }
.access-card.open .state { background: #1E3A35; color: var(--accent); }
.access-card.open .state i { background: var(--accent); }

/* Настройка по ссылке: шаги идут по порядку */
.steps { margin: 32px 0 0; padding: 0; list-style: none; counter-reset: s; max-width: 560px; }
.steps > li { counter-increment: s; position: relative; padding: 0 0 28px 44px; }
.steps > li::before {
  content: counter(s); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface); color: var(--accent); font-size: 14px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.steps > li:not(:last-child)::after { content: ""; position: absolute; left: 13.5px; top: 34px; bottom: 6px; width: 1px; background: var(--line); }
.steps p { color: var(--soft); font-size: 15px; }
.path { color: var(--text); }
.claim-head { margin-top: 48px; }
.done { margin: auto; padding: 48px 0 12vh; }

/* Админка */
.section { margin-top: 40px; }
.section > h2 { margin-bottom: 14px; }
.add-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) auto; gap: 12px; align-items: start; }
.add-form input { margin: 0; }
.add-form button { width: auto; height: 50px; }
.link-box { margin-top: 14px; padding: 16px; background: var(--surface); border-radius: 14px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.link-box code { flex: 1 1 300px; word-break: break-all; font-size: 13px; color: var(--soft); }
.link-box button { width: auto; }
.table { border-top: 1px solid var(--track); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 14px 0; border-bottom: 1px solid var(--track); }
.row .who { flex: 1 1 220px; min-width: 0; word-break: break-all; }
.row .num { font: 500 20px Unbounded, sans-serif; color: var(--text-strong); letter-spacing: .04em; }
.row button { width: auto; height: 38px; padding: 0 14px; font-size: 14px; }
.tag { font-size: 13px; color: var(--muted); }
.tag.wait { color: #E6C98F; }
.tag.ok { color: var(--ok); }
.search { max-width: 360px; }
.danger { color: var(--error) !important; }

@media (max-width: 640px) {
  .wrap { padding: 20px 20px 36px; }
  .view { grid-template-columns: minmax(0, 1fr); padding: 24px 0 0; margin: 0; gap: 14px; }
  .card { padding: 24px; border-radius: 20px; }
  .countdown { font-size: 40px; }
  .add-form { grid-template-columns: minmax(0, 1fr); }
  .add-form button { width: 100%; }
  .top-right .email { display: none; }
}
@media (prefers-reduced-motion: reduce) { .bar div, .meter div { transition: none; } }
.bar { margin-top: 20px; max-width: 520px; height: 4px; background: var(--track); border-radius: 2px; overflow: hidden; }
.bar div { height: 100%; background: var(--accent); transition: width 1s linear; }

/* Главная: подсказка для новых и галочка */
.first-time { padding: 18px 20px; margin: 0 0 32px; background: var(--surface); border-radius: 14px; }
.first-time h2 { margin-bottom: 6px; }
.first-time p { margin: 0; }
#login-form > h2 { margin-bottom: 14px; }
.field-hint { margin: -10px 0 18px; font-size: 13px; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 10px; margin: 0 0 20px; color: var(--text); font-size: 15px; cursor: pointer; }
label.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); flex: none; }
