:root {
  --bg: #141415;
  --sidebar: #0f0f10;
  --card: #19191b;
  --raised: #232325;
  --line: rgba(237, 237, 237, 0.08);
  --text: #ededed;
  --secondary: #a1a1a6;
  --muted: #85858b;
  --accent: #2563eb;
  --accent-hover: #1d55d6;
  --accent-text: #8ab4ff;
  --danger: #e5484d;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font: 14px/20px var(--font); -webkit-font-smoothing: antialiased;
}
h1 { font-size: 22px; line-height: 28px; font-weight: 500; margin: 0; }
h2 { font-size: 15px; line-height: 20px; font-weight: 500; margin: 0; }
p { margin: 0; }
b { font-weight: 600; color: var(--text); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

.secondary { color: var(--secondary); }
.muted { color: var(--muted); font-size: 13px; }

/* top bar */
.topbar {
  height: 56px; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 24px; border-bottom: 1px solid var(--line); background: var(--sidebar);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-size: 16px; font-weight: 500; }
.brand-mark { width: 20px; height: 20px; color: var(--accent-text); stroke-width: 1.75; }
.account { display: flex; align-items: center; gap: 8px; min-width: 0; }
.avatar {
  flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--raised); color: var(--text); font-size: 13px; font-weight: 500; text-transform: uppercase;
}
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 10; width: 240px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.menu-head { padding: 8px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-email { overflow-wrap: anywhere; margin-top: 2px; }
.menu-item {
  display: block; width: 100%; height: 36px; padding: 0 12px; text-align: left;
  border: 0; border-radius: 8px; background: transparent;
}
.menu-item:hover { background: var(--raised); }
.account-email { color: var(--secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* buttons & inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid transparent;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease);
}
.btn-primary { background: var(--accent); color: #fff; font-weight: 500; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-block { width: 100%; height: 40px; }
.btn-quiet { background: transparent; border-color: var(--line); color: var(--secondary); }
.btn-quiet:hover { background: var(--raised); color: var(--text); }
.btn-quiet:disabled { opacity: .6; }

.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted);
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}
.icon-btn:hover { background: var(--raised); color: var(--text); }

label { display: block; margin: 16px 0 8px; color: var(--secondary); }
input {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--raised); color: var(--text); font: inherit;
  transition: border-color 150ms var(--ease);
}
input:focus { outline: none; border-color: var(--accent-text); }

/* loading */
.loading { flex: 1; }

/* login */
.login-wrap { flex: 1; display: flex; justify-content: center; align-items: flex-start; padding: 96px 16px 48px; }
.login {
  width: 100%; max-width: 360px; padding: 32px 24px 24px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
}
.login .secondary { margin-top: 4px; margin-bottom: 8px; }
.password { position: relative; }
.password input { padding-right: 44px; }
.password .icon-btn { position: absolute; right: 4px; top: 4px; }
.password .icon-btn[aria-pressed="true"] { color: var(--text); }
.form-error { min-height: 20px; margin: 12px 0 8px; color: var(--danger); }

/* mail shell: message list on the left, the Telegram panel in the middle */
.shell { flex: 1; display: grid; grid-template-columns: 320px minmax(0, 1fr); }
.list { background: var(--sidebar); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.list-head { display: flex; align-items: center; gap: 8px; height: 56px; padding: 0 20px; border-bottom: 1px solid var(--line); }
.list-head h2 { flex: 1; }
.folder-count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.list-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 48px 20px; color: var(--muted); }
.list-empty svg { width: 24px; height: 24px; }

.pane { padding: 32px; min-width: 0; }
/* one rhythm: every block in the panel is 16px apart */
.pane > section { max-width: 720px; display: flex; flex-direction: column; gap: 16px; }
.pane-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 8px; }
.pane-head .secondary { margin-top: 4px; }
#refresh.spinning svg { animation: spin 800ms linear infinite; }

.label { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.phone-block { padding: 16px 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.phone-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.country {
  flex: none; padding: 0 6px; height: 20px; line-height: 20px; border-radius: 4px;
  background: var(--raised); color: var(--secondary); font-size: 12px; font-weight: 500;
}
.country:empty { display: none; }
.phone { flex: 1; min-width: 0; font-size: 18px; line-height: 24px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.checked { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--muted); font-size: 13px; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: #4cc38a; flex: none; }
.checked.stale .live-dot { background: var(--muted); }

/* code list: the one bright thing on the page */
.codes { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.codes li { display: flex; align-items: center; gap: 16px; padding: 16px 20px; background: var(--card); }
.codes li + li { border-top: 1px solid var(--line); }
.codes .code-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.codes .code { font-size: 18px; line-height: 24px; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.codes .meta { color: var(--muted); font-size: 13px; }
.codes li.latest { padding: 20px; background: var(--raised); }
.codes li.latest .code { font-size: 30px; line-height: 36px; font-weight: 500; letter-spacing: 0.04em; }
.codes li.latest .meta { color: var(--secondary); }

.waiting { padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.waiting .secondary { margin-top: 4px; }
.howto { list-style: none; counter-reset: step; margin: 16px 0; padding: 0; display: grid; gap: 8px; }
.howto li { counter-increment: step; display: flex; gap: 12px; color: var(--secondary); }
.howto li::before {
  content: counter(step); flex: none; width: 20px; height: 20px; line-height: 20px; text-align: center;
  border-radius: 4px; background: var(--raised); color: var(--text); font-size: 12px; font-variant-numeric: tabular-nums;
}

.notice { padding: 16px 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--secondary); }

.rules { margin-top: 8px; display: flex; flex-direction: column; gap: 16px; }
.rule {
  padding: 16px 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--card);
  color: var(--secondary); font-size: 13px; line-height: 20px;
}

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 8px);
  padding: 8px 12px; border-radius: 8px; background: var(--raised); border: 1px solid var(--line);
  opacity: 0; pointer-events: none; transition: opacity 180ms var(--ease), transform 180ms var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 720px) {
  .topbar { padding: 0 16px; }
  .account-email { display: none; }
  .shell { grid-template-columns: 1fr; }
  .list { order: 2; border-right: 0; border-top: 1px solid var(--line); }
  .list-head { padding: 0 16px; }
  .list-empty { padding: 32px 16px; }
  .pane { padding: 24px 16px 40px; }
  .pane-head #refresh span { display: none; }
  .pane-head #refresh { width: 32px; padding: 0; }
  .login-wrap { padding-top: 48px; }
}

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