/* Stash WebClient: mobile-first, no JavaScript required. */

:root {
  --bg: #101318;
  --panel: #171b21;
  --panel-2: #1d222a;
  --line: #2a313b;
  --text: #e7eaef;
  --muted: #8d95a3;
  --accent: #f2a93b;
  --accent-ink: #1b1305;
  --danger: #e5534b;
  --ok: #4fbf73;
  --info: #5b9be6;

  --common: #9aa3ad;
  --uncommon: #4fbf73;
  --rare: #4a90e2;
  --epic: #a66cf0;
  --legendary: #f0a43a;

  --radius: 12px;
  --gap: 8px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6rem; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; color: var(--muted); font-weight: 600; margin-top: 1.2rem; }
small, .muted { color: var(--muted); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(16, 19, 24, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 700; text-decoration: none; letter-spacing: .02em; }
.brand-mark { width: 18px; height: 18px; border-radius: 5px; background: linear-gradient(135deg, var(--accent), #c56f12); }
.topnav { display: flex; gap: 4px; }
.topnav a {
  color: var(--muted); text-decoration: none; font-size: .92rem; font-weight: 600;
  padding: 8px 12px; border-radius: 999px;
}
.topnav a.active { color: var(--text); background: var(--panel-2); }

.page { width: 100%; max-width: 760px; margin: 0 auto; padding: 16px; }

/* ---------- messages ---------- */
.flash, .notice {
  border-radius: var(--radius); padding: 10px 14px; margin: 0 0 14px;
  background: var(--panel-2); border-left: 4px solid var(--info);
}
.flash-success { border-left-color: var(--ok); }
.flash-error { border-left-color: var(--danger); }
.notice { border-left-color: var(--accent); color: var(--text); }
.hint { color: var(--muted); font-size: .88rem; margin: 0; }
.badge {
  display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 8px; margin-left: 6px;
  border-radius: 999px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line);
}
.badge-live { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); margin: 0; }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 10px;
  font: inherit; font-weight: 650; color: var(--text); text-decoration: none;
  background: var(--panel-2); border: 1px solid var(--line); cursor: pointer;
}
.btn:hover { border-color: #3a434f; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
:is(.btn, .tab, .tile, .pick, input):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.stack { display: grid; gap: 14px; }
.row { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.field { display: grid; gap: 6px; font-size: .9rem; color: var(--muted); }
.field em { font-style: normal; opacity: .7; }
.field-inline { min-width: 120px; flex: 0 1 140px; }
.help { font-size: .8rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"] {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px;
  font: inherit; font-size: 16px; /* stops iOS zooming on focus */
  color: var(--text); background: var(--bg); border: 1px solid var(--line);
}
input[aria-invalid="true"] { border-color: var(--danger); }
.check { display: flex; align-items: center; gap: 10px; margin: 12px 0; color: var(--muted); font-size: .92rem; }
.check input { width: 20px; height: 20px; accent-color: var(--danger); }

/* ---------- auth pages ---------- */
.auth { max-width: 380px; margin: 6vh auto 0; }
.lede { color: var(--muted); margin: 0 0 18px; }
.alt { color: var(--muted); text-align: center; margin-top: 18px; }

/* ---------- inventory ---------- */
.summary { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.summary .label { display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.credits { font-size: 1.6rem; font-variant-numeric: tabular-nums; }

.tabs { display: flex; gap: 6px; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; }
.tab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 650;
}
.tab.active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.tab .count { font-size: .78rem; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.tabs-small { margin: 0 0 10px; }
.tabs-small .tab { min-height: 36px; font-size: .9rem; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: var(--gap);
}
.cell { aspect-ratio: 1; min-width: 0; }
.empty, .tile, .pick { display: block; width: 100%; height: 100%; border-radius: 10px; }
.empty { background: var(--panel); border: 1px dashed #252b34; }

.tile, .pick {
  --r: var(--common);
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 6px; text-decoration: none; color: var(--text);
  background: radial-gradient(120% 90% at 50% 120%, color-mix(in srgb, var(--r) 28%, transparent), transparent 60%), var(--panel-2);
  border: 1px solid color-mix(in srgb, var(--r) 45%, var(--line));
  box-shadow: inset 0 -3px 0 var(--r);
}
.tile:active, .pick:active { transform: scale(.97); }
.icon { width: 30px; height: 30px; fill: none; stroke: var(--r, var(--text)); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.tile-name {
  width: 100%; text-align: center; font-size: .68rem; line-height: 1.15; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tile-qty {
  position: absolute; top: 4px; right: 6px; font-size: .72rem; font-weight: 700;
  font-variant-numeric: tabular-nums; color: var(--text); text-shadow: 0 1px 2px #000;
}
.rarity-common { --r: var(--common); }
.rarity-uncommon { --r: var(--uncommon); }
.rarity-rare { --r: var(--rare); }
.rarity-epic { --r: var(--epic); }
.rarity-legendary { --r: var(--legendary); }

/* slot picker on the item page */
.grid-picker { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); margin: 12px 0 8px; }
.pick { font: inherit; cursor: pointer; }
.pick .icon { width: 22px; height: 22px; }
.pick.is-empty { --r: transparent; background: var(--panel); border: 1px dashed #333b46; box-shadow: none; }
.pick.is-empty:hover { border-color: var(--accent); }
.pick.is-self { outline: 2px solid var(--accent); outline-offset: -2px; opacity: .55; cursor: default; }
.slot-no { font-size: .75rem; color: #59616d; font-variant-numeric: tabular-nums; }

/* ---------- item page ---------- */
.back { display: inline-block; margin-bottom: 12px; color: var(--muted); text-decoration: none; font-weight: 600; }
.item-card {
  --r: var(--common);
  background: linear-gradient(180deg, color-mix(in srgb, var(--r) 14%, var(--panel)), var(--panel) 70%);
  border: 1px solid color-mix(in srgb, var(--r) 40%, var(--line)); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}
.item-head { display: flex; gap: 14px; align-items: center; }
.item-head h1 { margin: 0 0 2px; }
.item-icon {
  flex: none; display: grid; place-items: center; width: 64px; height: 64px; border-radius: 14px;
  background: var(--bg); border: 1px solid color-mix(in srgb, var(--r) 50%, var(--line));
}
.item-icon .icon { width: 38px; height: 38px; }
.meta { margin: 0; color: var(--muted); font-size: .88rem; text-transform: capitalize; }
.rarity-label { color: var(--r); font-weight: 700; }
.desc { color: #c3c9d2; margin: 14px 0 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 14px 0 0; }
.stats div { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.stats dt { font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.stats dd { margin: 2px 0 0; font-weight: 650; font-variant-numeric: tabular-nums; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.panel-danger { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.panel .row .hint { flex: 1 1 200px; }

/* ---------- account ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.list-row:first-child { border-top: 0; }
.delta { color: var(--ok); font-weight: 700; font-variant-numeric: tabular-nums; }

@media (min-width: 640px) {
  .page { padding: 24px; }
  h1 { font-size: 1.7rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 10px; }
  .tile-name { font-size: .74rem; }
}

@media (prefers-reduced-motion: reduce) {
  .tile:active, .pick:active { transform: none; }
}
