:root {
  --bg: #14110f;
  --bg-2: #1c1815;
  --panel: #1a1714;
  --card: #211d19;
  --line: #3a332c;
  --text: #f3eee9;
  --muted: #a79d93;
  --copper: #c8733f;
  --copper-2: #e39a63;
  --copper-dark: #8a4a24;
  --alu: #c9ced4;
  --alu-dark: #7e858d;
  --danger: #ff7b72;
  --danger-bg: rgba(255, 123, 114, .1);
  --ok: #5fd39a;
  --ok-bg: rgba(95, 211, 154, .1);
  --ring: rgba(227, 154, 99, .45);
  --radius: 14px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f3ef;
    --bg-2: #ece6df;
    --panel: #f6f3ef;
    --card: #ffffff;
    --line: #e2d9cf;
    --text: #1d1915;
    --muted: #6d645b;
    --copper: #b4612d;
    --copper-2: #c8733f;
    --danger: #c0392b;
    --danger-bg: #fdecea;
    --ok: #1e8a57;
    --ok-bg: #e7f6ee;
    --ring: rgba(180, 97, 45, .35);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--copper-2); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }

.shell {
  min-height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
}

/* ---------- Brand panel ---------- */
.brand {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 40px 56px;
  color: #f3eee9;
  background:
    radial-gradient(1200px 600px at -10% 110%, rgba(200, 115, 63, .55), transparent 60%),
    radial-gradient(900px 500px at 110% -10%, rgba(201, 206, 212, .22), transparent 60%),
    linear-gradient(160deg, #1b1613 0%, #0f0d0b 100%);
}
.brand::after {                      /* subtle brushed-metal grain */
  content: "";
  position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, rgba(255,255,255,.018) 0 1px, transparent 1px 3px);
  pointer-events: none;
}
.brand > * { position: relative; z-index: 1; }

.logo, .mobile-logo {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 20px; letter-spacing: .2px;
}
.logo svg, .mobile-logo svg { color: var(--copper-2); }
.logo-sub {
  font-size: 11px; font-weight: 700; letter-spacing: 2px;
  padding: 3px 7px; border-radius: 6px; margin-left: 2px;
  border: 1px solid rgba(255,255,255,.25); color: #d7d1ca;
}

.brand-mid { max-width: 520px; }
.brand h1 {
  font-size: clamp(30px, 3.4vw, 46px);
  line-height: 1.08; letter-spacing: -.02em;
  margin: 28px 0 16px;
}
.accent {
  background: linear-gradient(90deg, var(--copper-2), #f4c39b 45%, var(--alu));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lede { color: #bdb3a9; font-size: 16px; margin: 0; max-width: 46ch; }

.elements { display: flex; gap: 14px; }
.el {
  width: 104px; height: 112px; border-radius: 12px; padding: 10px 12px;
  display: grid; grid-template-rows: auto 1fr auto auto;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 12px 30px rgba(0,0,0,.35);
}
.el-al { background: linear-gradient(145deg, #e9ecef, #9aa1a9 60%, #c4c9cf); color: #1d2024; }
.el-cu { background: linear-gradient(145deg, #f0a774, #b0582a 55%, #d98552); color: #2a1206; }
.el-n { font-size: 12px; font-weight: 700; opacity: .8; }
.el-s { font-size: 36px; font-weight: 800; line-height: 1; align-self: center; }
.el-name { font-size: 11px; font-weight: 700; }
.el-w { font-size: 10px; opacity: .75; }

.brand-foot {
  list-style: none; margin: 0; padding: 0;
  display: flex; gap: 22px; flex-wrap: wrap;
  color: #a89e94; font-size: 13px;
}
.brand-foot b { color: #e8e2dc; font-weight: 600; }

/* ---------- Auth panel ---------- */
.panel {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 24px 24px;
  background: var(--panel);
}
.card {
  width: 100%; max-width: 420px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 30px 60px -30px rgba(0,0,0,.5);
  animation: rise .35s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.mobile-logo { display: none; margin-bottom: 20px; }

.tabs {
  position: relative;
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--bg-2);
  border-radius: 12px; padding: 4px;
  margin-bottom: 22px;
}
.tab {
  position: relative; z-index: 1;
  appearance: none; border: 0; background: none; cursor: pointer;
  font: inherit; font-weight: 600; color: var(--muted);
  padding: 9px 10px; border-radius: 9px;
  transition: color .2s;
}
.tab[aria-selected="true"] { color: var(--text); }
.tab:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.tab-ink {
  position: absolute; top: 4px; bottom: 4px; left: 4px;
  width: calc(50% - 4px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 9px;
  transition: transform .25s cubic-bezier(.3,.7,.2,1);
}
.tabs.is-signup .tab-ink { transform: translateX(100%); }

.form-head h2 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.01em; }
.form-head p { margin: 0 0 20px; color: var(--muted); }

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input {
  width: 100%;
  font: inherit; color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 13px;
  transition: border-color .15s, box-shadow .15s;
}
.field input::placeholder { color: var(--muted); opacity: .7; }
.field input:focus { outline: none; border-color: var(--copper); box-shadow: 0 0 0 3px var(--ring); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.err { display: block; color: var(--danger); font-size: 12.5px; min-height: 0; margin-top: 5px; }
.err:empty { display: none; }
.hint { display: block; color: var(--muted); font-size: 12.5px; margin-top: 6px; }

.pw { position: relative; }
.pw input { padding-right: 64px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  appearance: none; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 12.5px; font-weight: 600; color: var(--muted);
  padding: 6px 8px; border-radius: 6px;
}
.pw-toggle:hover { color: var(--text); }
.pw-toggle:focus-visible { outline: 2px solid var(--ring); }

.meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 8px; }
.meter i { height: 4px; border-radius: 4px; background: var(--line); transition: background .2s; }
.meter[data-score="1"] i:nth-child(-n+1) { background: var(--danger); }
.meter[data-score="2"] i:nth-child(-n+2) { background: #e6a23c; }
.meter[data-score="3"] i:nth-child(-n+3) { background: var(--copper-2); }
.meter[data-score="4"] i { background: var(--ok); }

.check { display: flex; align-items: center; gap: 9px; margin: 4px 0 20px; color: var(--muted); font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--copper); }

.btn {
  position: relative;
  width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  appearance: none; border: 0; cursor: pointer;
  font: inherit; font-weight: 700; font-size: 15px;
  color: #fff;
  padding: 12px 16px; border-radius: 10px;
  background: linear-gradient(180deg, var(--copper-2), var(--copper) 60%, var(--copper-dark));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 8px 20px -8px rgba(200,115,63,.7);
  transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
.btn[disabled] { cursor: progress; filter: saturate(.6) brightness(.9); }
.btn-ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--line); box-shadow: none;
}
.spinner {
  display: none; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.btn.is-loading .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.switch { text-align: center; color: var(--muted); font-size: 14px; margin: 18px 0 0; }

.alert {
  border-radius: 10px; padding: 11px 13px; margin-bottom: 18px;
  font-size: 14px; border: 1px solid;
}
.alert.is-error { color: var(--danger); background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.alert.is-ok { color: var(--ok); background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }

/* Signed-in view */
#home-view { text-align: center; }
.home-badge {
  width: 52px; height: 52px; margin: 4px auto 14px; border-radius: 50%;
  display: grid; place-items: center;
  color: var(--ok); background: var(--ok-bg);
}
#home-view h2 { margin: 0 0 6px; }
.muted { color: var(--muted); margin: 0 0 16px; }
.small { font-size: 13px; }
.meta { text-align: left; margin: 0 0 18px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.meta div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; }
.meta div + div { border-top: 1px solid var(--line); }
.meta dt { color: var(--muted); font-size: 13px; }
.meta dd { margin: 0; font-size: 13px; font-weight: 600; overflow-wrap: anywhere; text-align: right; }

.legal { color: var(--muted); font-size: 12px; margin: 22px 0 0; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .brand { display: none; }
  .mobile-logo { display: inline-flex; }
  .panel { padding: 24px 16px; min-height: 100vh; }
  .card { padding: 22px; }
}

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

.mobile-logo .logo-sub { border-color: var(--line); color: var(--muted); }
