/* ===== AEONZ — soft blue app style ===== */
:root {
  --bg: #f1f5fc;
  --bg-deep: #e3ecfb;
  --surface: #ffffff;
  --ink: #111a2e;
  --muted: #6b7489;
  --line: #e4e9f3;
  --blue: #3d7ef5;
  --blue-soft: #e6efff;
  --hero-top: #e4eeff;
  --hero-bottom: #a8c7f8;
  --navy: #0e1730;
  --navy-ink: #ffffff;
  --danger: #d6455d;
  --danger-soft: #ffe9ed;
  --warn-ink: #9a6400;
  --warn-soft: #fff3d6;
  --good: #1f9d74;
  --good-soft: #def6ec;
  --r-lg: 26px;
  --r-md: 18px;
  --r-sm: 12px;
  --shadow: 0 1px 2px rgba(25, 45, 90, 0.05), 0 8px 24px rgba(25, 45, 90, 0.07);
  --shadow-lift: 0 10px 30px rgba(14, 23, 48, 0.18);
  --font: 'Plus Jakarta Sans', ui-rounded, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, 'Roboto Mono', monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0b1120;
    --bg-deep: #0e1630;
    --surface: #151e36;
    --ink: #eaf0ff;
    --muted: #97a3bf;
    --line: #243152;
    --blue: #6b9dff;
    --blue-soft: #1c2c55;
    --hero-top: #1b2a52;
    --hero-bottom: #2d4c8f;
    --navy: #6b9dff;
    --navy-ink: #0b1120;
    --danger: #ff8b9d;
    --danger-soft: #3b1a24;
    --warn-ink: #ffcf73;
    --warn-soft: #3a2c10;
    --good: #5fd6ab;
    --good-soft: #13372b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    --shadow-lift: 0 10px 30px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 500 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--blue); }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { letter-spacing: -0.02em; }
.hidden { display: none !important; }

.wrap { max-width: 560px; margin: 0 auto; padding: 0 16px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 54px; padding: 12px 20px;
  border: 0; border-radius: var(--r-md);
  background: var(--navy); color: var(--navy-ink);
  font-weight: 700; font-size: 16px; cursor: pointer; text-decoration: none;
  box-shadow: var(--shadow-lift);
  transition: transform 0.12s ease, opacity 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }
.btn.block { width: 100%; }
.btn.soft { background: var(--blue-soft); color: var(--blue); box-shadow: none; }
.btn.ghost { background: var(--surface); color: var(--ink); box-shadow: none; border: 1px solid var(--line); }
.btn.danger { background: var(--danger-soft); color: var(--danger); box-shadow: none; }
.btn.small { min-height: 38px; padding: 8px 14px; font-size: 14px; border-radius: var(--r-sm); }

/* ---------- forms ---------- */
label { display: block; font-size: 14px; font-weight: 700; margin: 0 0 8px; }
.hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; font-weight: 500; }
.field { margin: 0 0 16px; }
input[type='text'], input[type='password'], input[type='search'], input[type='date'], input[type='number'], select {
  width: 100%;
  min-height: 52px;
  padding: 12px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg);
  outline: none;
  font-weight: 600;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder { color: var(--muted); font-weight: 500; opacity: 0.8; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 4px var(--blue-soft); }
input[type='file'] {
  width: 100%; font-size: 14px; font-weight: 600; color: var(--muted);
  padding: 14px; border: 1.5px dashed var(--line); border-radius: var(--r-md); background: var(--bg);
}
input[type='file']::file-selector-button {
  font: inherit; font-weight: 700; color: var(--blue); background: var(--blue-soft);
  border: 0; border-radius: 999px; padding: 8px 14px; margin-right: 10px; cursor: pointer;
}

/* ---------- surfaces ---------- */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card + .card { margin-top: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 14px; }
.card-head h3 { margin: 0; font-size: 17px; font-weight: 700; }
.card-head .link { font-size: 14px; font-weight: 700; color: var(--blue); background: none; border: 0; cursor: pointer; padding: 0; }

.notice { border-radius: var(--r-sm); padding: 12px 14px; font-size: 14px; font-weight: 600; margin: 0 0 16px; }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.notice.info { background: var(--blue-soft); color: var(--blue); }
.notice.warn { background: var(--warn-soft); color: var(--warn-ink); }

/* ---------- hero with mascot ---------- */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-lg);
  background:
    radial-gradient(120% 70% at 50% -10%, rgba(255, 255, 255, 0.9), transparent 60%),
    linear-gradient(180deg, var(--hero-top) 0%, var(--hero-bottom) 100%);
  padding: 18px 16px 16px;
  box-shadow: var(--shadow);
}
.hero::before {
  /* soft light beams */
  content: '';
  position: absolute; inset: -20% 10% auto;
  height: 80%;
  background: repeating-linear-gradient(100deg, rgba(255, 255, 255, 0) 0 34px, rgba(255, 255, 255, 0.28) 34px 52px);
  filter: blur(6px);
  opacity: 0.7;
  pointer-events: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .hero::before { opacity: 0.12; }
  :root:not([data-theme='light']) .hero { background: linear-gradient(180deg, var(--hero-top), var(--hero-bottom)); }
}
.hero-title { position: relative; display: flex; align-items: center; gap: 6px; font-size: 18px; font-weight: 800; margin: 0; }
.stage { position: relative; display: grid; place-items: center; padding: 8px 0 6px; min-height: 190px; }
.bubble {
  position: relative; z-index: 2;
  background: var(--surface); color: var(--ink);
  font-size: 14px; font-weight: 600; line-height: 1.35;
  padding: 10px 14px; border-radius: 16px;
  box-shadow: var(--shadow);
  max-width: 230px; text-align: center;
  margin: 0 0 6px;
}
.bubble::after {
  content: '';
  position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%) rotate(45deg);
  width: 14px; height: 14px; background: var(--surface); border-radius: 3px;
}
.mascot { width: 132px; height: 140px; display: block; position: relative; z-index: 1; }
.mascot svg { width: 100%; height: 100%; overflow: visible; }
.bob { animation: bob 3.2s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.sparkle { position: absolute; color: #fff; opacity: 0.95; animation: twinkle 2.6s ease-in-out infinite; }
.sparkle svg { display: block; width: 100%; height: 100%; }
@keyframes twinkle { 0%, 100% { transform: scale(1); opacity: 0.95; } 50% { transform: scale(0.7); opacity: 0.5; } }
@media (prefers-reduced-motion: reduce) { .bob, .sparkle { animation: none; } }

.tiles { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.tile { background: var(--surface); border-radius: 14px; padding: 10px 12px; box-shadow: 0 1px 2px rgba(25, 45, 90, 0.06); }
.tile .k { font-size: 13px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.tile .v { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- sign-in ---------- */
.signin-bg {
  min-height: 100vh;
  background:
    radial-gradient(60% 45% at 85% 5%, rgba(61, 126, 245, 0.22), transparent 70%),
    radial-gradient(55% 40% at 0% 100%, rgba(61, 126, 245, 0.16), transparent 70%),
    var(--bg);
}
.signin { max-width: 420px; margin: 0 auto; padding: 28px 16px 40px; }
.signin .hero { margin-bottom: 14px; }
.signin h1 { font-size: 26px; font-weight: 800; margin: 2px 0 4px; }
.signin .tagline { color: var(--muted); margin: 0 0 20px; font-size: 15px; }
.code-input {
  font-family: var(--mono) !important;
  font-size: 24px !important;
  font-weight: 700 !important;
  letter-spacing: 0.16em;
  text-align: center;
  text-transform: uppercase;
  min-height: 62px !important;
}
.foot { margin: 16px 0 0; font-size: 13px; color: var(--muted); text-align: center; }

/* ---------- library ---------- */
.greet { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 22px 0 16px; }
.greet h1 { margin: 0; font-size: 22px; font-weight: 800; }
.greet p { margin: 2px 0 0; color: var(--muted); font-size: 14px; font-weight: 600; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border-radius: 14px; padding: 8px 12px;
  font-weight: 800; font-size: 15px; box-shadow: var(--shadow); white-space: nowrap;
}
.cta { margin: 16px 0 6px; }
.cta-sub { text-align: center; font-size: 13px; color: var(--muted); margin: 8px 0 18px; font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 7px 14px; font-size: 14px; font-weight: 700;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chip[aria-pressed='true'] { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 4px 12px rgba(61, 126, 245, 0.35); }

.search { margin: 14px 0 0; }

.list { list-style: none; margin: 0; padding: 0; }
.list li + li { margin-top: 4px; }
.item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 6px; border-radius: 14px;
  color: var(--ink); text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.item:active { background: var(--blue-soft); }
.icon-tile {
  flex: none; width: 44px; height: 44px; border-radius: 13px;
  display: grid; place-items: center; font-size: 22px;
  background: var(--blue-soft);
}
.item .txt { flex: 1; min-width: 0; }
.item .t { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-weight: 700; line-height: 1.3; }
.item .d { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.item .chev { color: var(--muted); font-size: 22px; line-height: 1; }
.new-badge { display: inline-block; margin-left: 6px; font-size: 10px; font-weight: 800; letter-spacing: 0.06em; color: #fff; background: var(--blue); border-radius: 999px; padding: 2px 7px; vertical-align: 2px; }
.empty { text-align: center; color: var(--muted); padding: 28px 8px; font-weight: 600; }
.topnav { display: flex; justify-content: flex-end; padding: 14px 0 0; }
.linkbtn { background: none; border: 0; padding: 6px 0; color: var(--muted); cursor: pointer; font-size: 14px; font-weight: 700; }
.page-foot { padding: 24px 0 40px; text-align: center; font-size: 13px; color: var(--muted); font-weight: 600; }

/* ---------- admin ---------- */
.seg { display: flex; gap: 4px; padding: 5px; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); margin: 0 0 16px; }
.seg button { flex: 1; border: 0; border-radius: 14px; background: transparent; padding: 11px; font-weight: 700; cursor: pointer; color: var(--muted); }
.seg button[aria-selected='true'] { background: var(--blue); color: #fff; box-shadow: 0 4px 12px rgba(61, 126, 245, 0.35); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .row { grid-template-columns: 1fr; } }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0 0 14px; }
.stat { background: var(--surface); border-radius: 16px; padding: 12px; box-shadow: var(--shadow); }
.stat .k { font-size: 12px; font-weight: 700; color: var(--muted); }
.stat .v { font-size: 22px; font-weight: 800; }
.codes { display: grid; gap: 12px; }
.code-card { background: var(--surface); border-radius: 22px; padding: 16px; box-shadow: var(--shadow); }
.code-card .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.code-card .name { font-weight: 800; }
.code-card .code { font-family: var(--mono); font-size: 18px; font-weight: 700; letter-spacing: 0.08em; margin: 2px 0 0; }
.code-card .meta { font-size: 13px; color: var(--muted); font-weight: 600; margin: 10px 0 0; }
.code-card .meta div + div { margin-top: 3px; }
.code-card .actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; }
.status { display: inline-block; font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.status.unused { background: var(--bg-deep); color: var(--muted); }
.status.active { background: var(--good-soft); color: var(--good); }
.status.idle { background: var(--blue-soft); color: var(--blue); }
.status.off { background: var(--danger-soft); color: var(--danger); }
.created-list { display: grid; gap: 10px; }
.created-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: 12px 14px; border-radius: 16px; background: var(--blue-soft); }
.created-item .code { font-family: var(--mono); font-size: 19px; font-weight: 700; letter-spacing: 0.08em; }
.edit-box { margin: 14px 0 0; padding: 14px 0 0; border-top: 1.5px dashed var(--line); }
.rev-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.rev-row + .rev-row { border-top: 1px solid var(--line); }
.rev-row .txt { flex: 1; min-width: 0; }
.rev-row .t { display: block; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rev-row .d { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.rev-actions { display: flex; gap: 6px; }
.progress { height: 8px; background: var(--bg-deep); border-radius: 999px; overflow: hidden; margin: 12px 0 0; }
.progress > div { height: 100%; width: 0; background: var(--blue); border-radius: 999px; transition: width 0.2s; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--navy); color: var(--navy-ink); padding: 12px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 700; z-index: 50; box-shadow: var(--shadow-lift); max-width: calc(100vw - 32px);
}
