/* j-marceli gateway — one stylesheet for every page the gateway renders. */

:root {
  color-scheme: dark;
  --bg: #0c0d0f;
  --surface: #141518;
  --surface-2: #1b1d21;
  --border: #25272c;
  --border-strong: #34373d;
  --text: #ececf1;
  --muted: #a1a3ab;
  --faint: #6c6f78;
  --danger: #ff8f86;
  --warning: #f5b85c;
  --success: #6fd6a8;
  --accent: #adc6ff;
  --on-accent: #0b1a33;
  --radius: 14px;
  --radius-sm: 10px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
}
[data-theme="amber"]  { --accent: #f0bd7a; --on-accent: #2a1a00; }
[data-theme="purple"] { --accent: #cdb4f0; --on-accent: #241245; }
[data-theme="yellow"] { --accent: #e3c964; --on-accent: #292000; }
[data-theme="green"]  { --accent: #8fd6a4; --on-accent: #00210f; }
[data-theme="rose"]   { --accent: #f0aeb8; --on-accent: #3a0710; }

/* ── Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--border-strong) transparent; }
body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.ic { display: block; flex-shrink: 0; }
[hidden] { display: none !important; }

/* ── Layout ───────────────────────────────────────────── */
.shell { width: min(100% - 2.5rem, 960px); margin: 0 auto; padding: 1.75rem 0 4rem; }
.center { min-height: 100dvh; display: grid; place-items: center; padding: 1.25rem; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 2.5rem; }
.brand { display: inline-flex; align-items: center; gap: .65rem; font-weight: 650; letter-spacing: -.01em; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--accent);
}
.brand small { color: var(--faint); font-weight: 500; margin-left: .15rem; }

/* ── Sections & tiles ─────────────────────────────────── */
.section + .section { margin-top: 2.25rem; }
.section-title {
  display: flex; align-items: baseline; gap: .5rem; margin-bottom: .85rem;
  font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--faint);
}
.section-title span { font-variant-numeric: tabular-nums; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .6rem; }
.tile {
  display: flex; align-items: center; gap: .8rem; min-width: 0;
  padding: .8rem .9rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  transition: background .15s var(--ease), border-color .15s var(--ease), transform .15s var(--ease);
}
a.tile:hover { background: var(--surface-2); border-color: var(--border-strong); }
a.tile:active { transform: scale(.985); }
.tile-icon {
  width: 36px; height: 36px; border-radius: var(--radius-sm); display: grid; place-items: center; flex-shrink: 0;
  background: var(--surface-2); color: var(--muted); transition: color .15s var(--ease);
}
a.tile:hover .tile-icon { color: var(--accent); }
.tile-text { min-width: 0; display: flex; flex-direction: column; }
.tile-title { font-weight: 600; font-size: .93rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-desc { color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .tag { margin-left: auto; }

[data-view="list"] .grid { grid-template-columns: 1fr; gap: .35rem; }
[data-view="list"] .tile { padding: .55rem .8rem; }
[data-view="list"] .tile-icon { width: 30px; height: 30px; }
[data-view="list"] .tile-text { flex-direction: row; align-items: baseline; gap: .75rem; }

.offline { margin-top: 2.25rem; }
.offline summary {
  list-style: none; cursor: pointer; user-select: none; display: inline-flex; align-items: center; gap: .35rem;
  font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--faint);
}
.offline summary::-webkit-details-marker { display: none; }
.offline summary:hover { color: var(--muted); }
.offline summary .ic { transition: transform .2s var(--ease); }
.offline[open] summary .ic { transform: rotate(180deg); }
.offline .grid { margin-top: .85rem; }
.offline .tile { opacity: .55; }

/* ── Tags & notices ───────────────────────────────────── */
.tag {
  display: inline-flex; align-items: center; padding: .1rem .5rem; border-radius: 999px; flex-shrink: 0;
  font-size: .68rem; font-weight: 600; letter-spacing: .03em; text-transform: lowercase;
  background: var(--surface-2); color: var(--muted);
}
.tag-accent { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.tag-success { background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success); }
.tag-warning { background: color-mix(in srgb, var(--warning) 14%, transparent); color: var(--warning); }
.tag-danger { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

.notice {
  display: flex; align-items: center; gap: .55rem; margin-bottom: 1.25rem;
  padding: .7rem .9rem; border-radius: var(--radius-sm); font-size: .87rem;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
}
.notice-success { color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.notice-error { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.notice-warning { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }

/* ── Menu ─────────────────────────────────────────────── */
.menu { position: relative; }
.menu-trigger {
  display: inline-flex; align-items: center; gap: .55rem; padding: .25rem .3rem .25rem .75rem;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  font-size: .87rem; font-weight: 550; transition: border-color .15s var(--ease);
}
.menu-trigger:hover, .menu-trigger[aria-expanded="true"] { border-color: var(--border-strong); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-size: .75rem; font-weight: 700; text-transform: uppercase;
  background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent);
}
.menu-panel {
  position: absolute; right: 0; top: calc(100% + .5rem); z-index: 50; width: 250px;
  padding: .4rem; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--border-strong); box-shadow: 0 16px 40px rgb(0 0 0 / .45);
  animation: pop .14s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } }
.menu-head { padding: .55rem .65rem .65rem; border-bottom: 1px solid var(--border); margin-bottom: .3rem; }
.menu-head strong { display: block; font-weight: 600; }
.menu-head span { font-size: .78rem; color: var(--faint); }
.menu-item {
  display: flex; align-items: center; gap: .6rem; width: 100%; padding: .5rem .65rem;
  border-radius: 8px; color: var(--muted); font-size: .88rem; text-align: left;
}
.menu-item:hover { background: var(--surface-2); color: var(--text); }
.menu-item.danger:hover { color: var(--danger); }
.menu-sep { height: 1px; background: var(--border); margin: .3rem 0; }
.menu-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .45rem .65rem; font-size: .82rem; color: var(--faint); }

.segmented { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--surface-2); }
.segmented button { padding: .25rem .4rem; border-radius: 6px; color: var(--faint); }
.segmented button[aria-pressed="true"] { background: var(--border-strong); color: var(--text); }

.swatches { display: flex; gap: .4rem; }
.swatch {
  width: 16px; height: 16px; border-radius: 50%; background: var(--sw);
  box-shadow: 0 0 0 2px var(--surface); transition: transform .12s var(--ease);
}
.swatch:hover { transform: scale(1.15); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--sw); }

/* ── Panels (auth & settings) ─────────────────────────── */
.panel {
  width: 100%; max-width: 360px; padding: 2rem 1.75rem;
  border-radius: 18px; background: var(--surface); border: 1px solid var(--border);
}
.panel-head { text-align: center; margin-bottom: 1.5rem; }
.panel-head .brand-mark { width: 40px; height: 40px; border-radius: 12px; margin: 0 auto 1rem; }
.panel-head h1 { font-size: 1.2rem; font-weight: 650; letter-spacing: -.015em; }
.panel-head p { color: var(--muted); font-size: .88rem; margin-top: .25rem; }
.panel-foot { margin-top: 1.25rem; text-align: center; }
.panel .notice { margin-bottom: 1rem; }

/* ── Forms & buttons ──────────────────────────────────── */
.stack { display: flex; flex-direction: column; gap: .65rem; }
.field { display: flex; flex-direction: column; gap: .4rem; }
.field > label, .field-label { font-size: .8rem; font-weight: 550; color: var(--muted); }
.input {
  width: 100%; padding: .7rem .85rem; border-radius: var(--radius-sm);
  background: var(--bg); border: 1px solid var(--border); outline: none;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.input::placeholder { color: var(--faint); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.input:disabled { color: var(--faint); }
.input-mono { font-family: var(--mono); font-size: .85rem; }
.input-group { display: flex; gap: .4rem; }
.input-group .input { flex: 1; min-width: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .55rem .95rem; border-radius: var(--radius-sm); white-space: nowrap;
  font-size: .87rem; font-weight: 600; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
  transition: background .15s var(--ease), border-color .15s var(--ease), filter .15s var(--ease), transform .1s var(--ease);
}
.btn:hover { border-color: var(--border-strong); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.btn-primary:hover { filter: brightness(1.08); border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn-ghost { background: none; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }
.btn-block { width: 100%; padding: .75rem; margin-top: .25rem; }
.btn-sm { padding: .3rem .6rem; font-size: .78rem; border-radius: 8px; }

.link-back { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); font-size: .85rem; }
.link-back:hover { color: var(--text); }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  display: inline-flex; align-items: center; gap: .4rem; padding: .4rem .7rem; cursor: pointer; user-select: none;
  border-radius: 999px; border: 1px solid var(--border); background: var(--bg); font-size: .82rem; color: var(--muted);
  transition: border-color .15s var(--ease), color .15s var(--ease), background .15s var(--ease);
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:hover { border-color: var(--border-strong); }
.chip:has(input:checked) {
  color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.hint { font-size: .78rem; color: var(--faint); }

/* ── Admin ────────────────────────────────────────────── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.75rem; }
.page-head h1 { font-size: 1.5rem; font-weight: 650; letter-spacing: -.02em; }
.page-head p { color: var(--muted); font-size: .88rem; }

.card { border-radius: 16px; background: var(--surface); border: 1px solid var(--border); }
.card + .card { margin-top: 1.25rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.15rem; }
.card-head h2 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 0 1.15rem 1.25rem; }
.card-body .stack { gap: 1.1rem; }
.form-actions { display: flex; gap: .5rem; margin-top: .4rem; }

.table-wrap { overflow-x: auto; border-top: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: .87rem; }
th {
  text-align: left; padding: .6rem 1.15rem; white-space: nowrap;
  font-size: .7rem; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--faint);
}
td { padding: .7rem 1.15rem; border-top: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.cell-user { display: flex; align-items: center; gap: .6rem; font-weight: 600; white-space: nowrap; }
.cell-user .avatar { width: 26px; height: 26px; font-size: .7rem; }
.cell-muted { color: var(--muted); white-space: nowrap; }
.cell-mono { font-family: var(--mono); font-size: .8rem; }
.cell-apps { color: var(--muted); font-size: .8rem; max-width: 260px; }
.actions { display: flex; justify-content: flex-end; gap: .3rem; }
.actions form { display: contents; }
.empty { padding: 2rem 1.15rem; text-align: center; color: var(--faint); font-size: .88rem; border-top: 1px solid var(--border); }

.secret {
  display: grid; grid-template-columns: auto 1fr; gap: .45rem 1rem; margin: .25rem 0 1rem;
  padding: 1rem; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--border);
  font-size: .87rem;
}
.secret dt { color: var(--faint); }
.secret dd { font-family: var(--mono); word-break: break-all; }

/* ── Responsive / motion ──────────────────────────────── */
@media (max-width: 640px) {
  .shell { width: min(100% - 1.5rem, 960px); padding-top: 1.1rem; }
  .topbar { margin-bottom: 1.75rem; }
  .menu-trigger .menu-name { display: none; }
  .menu-trigger { padding: .25rem; }
  .grid { grid-template-columns: 1fr; gap: .45rem; }
  .page-head { flex-direction: column; align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
