/* GrapesLabs User admin. Styles shared with gl-morpheus (keep them alike); this app's additions are at the end. */
:root {
  color-scheme: light dark;
  --bg: #f6f6f8; --surface: #fff; --fg: #18181b; --muted: #6b6b76; --line: #e4e4ea; --line-strong: #cfcfd8;
  --accent: #6d3fd1; --accent-fg: #fff; --accent-soft: #efe9fc;
  --ok: #157a3c; --ok-soft: #e6f5ec; --bad: #c0261c; --bad-soft: #fdecea; --warn: #9a6200;
  --radius: 12px; --shadow: 0 1px 2px rgb(16 16 24 / .05), 0 1px 1px rgb(16 16 24 / .03);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111114; --surface: #1a1a1f; --fg: #ececf1; --muted: #9a9aa6; --line: #2b2b33; --line-strong: #3a3a44;
    --accent: #a184f0; --accent-fg: #15121e; --accent-soft: #2a2140;
    --ok: #5bd08a; --ok-soft: #15291d; --bad: #ff8a80; --bad-soft: #3a1a18; --warn: #e3b341;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--fg); background: var(--bg); }
body.staging { border-top: 3px solid var(--warn); }
a { color: inherit; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.5rem; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1rem; font-weight: 600; }
h3 { font-size: .95rem; font-weight: 600; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: .9em; }
h1.mono { font-size: 1.45rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }

/* Header */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-in { max-width: 920px; margin: 0 auto; padding: .7rem 1.25rem; display: flex; align-items: center; gap: .75rem; }
.brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 650; text-decoration: none; letter-spacing: -.01em; }
.mark { width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #c9b3ff, var(--accent) 60%, #3b1f86); box-shadow: 0 0 0 3px var(--accent-soft); }
.env { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--warn); border: 1px solid currentColor; border-radius: 999px; padding: 0 .5rem; }
.signout { margin-left: auto; }

/* Layout */
.page { max-width: 920px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.page.narrow { max-width: 560px; }
.title-row { display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap; margin: .25rem 0 1.25rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 .6rem; }
.count { font-weight: 500; color: var(--muted); margin-left: .25rem; }
.crumbs { display: flex; gap: .4rem; font-size: .85rem; color: var(--muted); margin-bottom: .75rem; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--fg); }
.stack { display: grid; gap: .8rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .8rem; align-items: start; }

/* Flash */
.flash { border-radius: 10px; padding: .6rem .9rem; margin: 0 0 1rem; font-size: .9rem; transition: opacity .4s, transform .4s; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-err { background: var(--bad-soft); color: var(--bad); }
.flash.gone { opacity: 0; transform: translateY(-4px); pointer-events: none; }

/* Forms */
label { display: grid; gap: .3rem; font-size: .85rem; font-weight: 500; }
.opt { font-weight: 400; color: var(--muted); font-size: .78rem; margin-left: .3rem; }
.hint { font-size: .78rem; color: var(--muted); margin-top: -.5rem; }
input, select, textarea {
  font: inherit; font-size: .92rem; font-weight: 400; color: inherit; background: var(--bg);
  border: 1px solid var(--line-strong); border-radius: 8px; padding: .5rem .65rem; width: 100%;
}
textarea { font-family: var(--mono); font-size: .86rem; resize: vertical; min-height: 4.5rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[readonly] { color: var(--muted); }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-size: .85rem; font-weight: 500; padding: 0; margin-bottom: .3rem; }

button, .button {
  font: inherit; font-size: .88rem; font-weight: 550; display: inline-flex; align-items: center; gap: .4rem;
  padding: .45rem .9rem; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--fg); cursor: pointer; text-decoration: none; white-space: nowrap;
}
button:hover, .button:hover { border-color: var(--muted); }
button:focus-visible, .button:focus-visible, summary:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
button.danger:hover { background: var(--bad-soft); }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); font-weight: 500; }
button.ghost:hover { color: var(--fg); }
.actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.push { margin-left: auto; }
.copy-row { display: flex; gap: .5rem; }
.copy-row input { flex: 1; min-width: 0; }
.inline-form { display: flex; gap: .5rem; }
.inline-form input { flex: 1; min-width: 0; }

/* Segmented control (type picker) */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 9px; padding: 3px; gap: 3px; width: max-content; }
.seg label { display: block; font-weight: 500; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { display: block; padding: .3rem .85rem; border-radius: 6px; cursor: pointer; color: var(--muted); }
.seg input:checked + span { background: var(--accent-soft); color: var(--accent); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
/* Show only the value field for the chosen type (browsers without :has() show both, which still works). */
form:has(input[name=type][value=bool]:checked) .only-text,
form:has(input[name=type][value=text]:checked) .only-bool { display: none; }

/* Chips */
.chip { display: inline-block; font-size: .72rem; font-weight: 550; letter-spacing: .02em; color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: .05rem .55rem; }

/* App cards */
.app-card { display: grid; gap: .35rem; text-decoration: none; transition: border-color .15s, transform .15s; min-height: 118px; align-content: start; }
.app-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.app-name { font-family: var(--mono); font-weight: 600; font-size: 1rem; }
.app-card .chip { justify-self: start; margin-top: auto; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: .88rem; }

/* "New" disclosure cards */
.new-card, .new-feature { border-style: dashed; box-shadow: none; background: transparent; }
.new-card[open], .new-feature[open] { border-style: solid; background: var(--surface); }
.new-card summary, .new-feature summary { cursor: pointer; font-weight: 600; color: var(--accent); list-style: none; display: flex; align-items: center; gap: .5rem; }
.new-card:not([open]) { min-height: 118px; display: grid; place-items: center; }
.new-card summary::-webkit-details-marker, .new-feature summary::-webkit-details-marker { display: none; }
.plus { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); font-weight: 600; }
.new-card[open] summary, .new-feature[open] summary { margin-bottom: .9rem; }
.new-feature { margin-top: .8rem; }
.new-feature form { max-width: 520px; }

/* Features */
.features { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.feature { display: grid; grid-template-columns: 1fr auto; gap: .35rem 1rem; align-items: center; padding: .85rem 1rem; scroll-margin-top: 80px; }
.feature:target { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.feature-main { min-width: 0; }
.feature-id { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.fname { font-weight: 600; font-size: .95rem; }
.fdesc { font-size: .85rem; margin-top: .15rem; }
.tvalue { grid-column: 1 / -1; }
.tvalue pre { margin: .15rem 0 0; font-family: var(--mono); font-size: .85rem; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .65rem; white-space: pre-wrap; word-break: break-word; }
.feature:has(.edit[open]) .tvalue { display: none; } /* the editor shows the value */
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.feature > .edit { grid-column: 1 / -1; }
.edit > summary { cursor: pointer; font-size: .8rem; color: var(--muted); width: max-content; list-style: none; }
.edit > summary::-webkit-details-marker { display: none; }
.edit > summary::before { content: "›"; display: inline-block; margin-right: .35rem; transition: transform .15s; }
.edit[open] > summary::before { transform: rotate(90deg); }
.edit > summary:hover { color: var(--fg); }
.edit[open] > summary { margin-bottom: .7rem; }
.edit[open] { border-top: 1px solid var(--line); padding-top: .6rem; margin-top: .2rem; }
.unsaved { display: none; font-size: .8rem; color: var(--warn); font-weight: 550; }
form.dirty .unsaved { display: inline; }
form.dirty button.primary { box-shadow: 0 0 0 3px var(--accent-soft); }
.delete-row { margin-top: .8rem; }

/* Switch: a real button, so one click saves. */
.switch-form { margin: 0; }
.switch {
  --w: 74px; position: relative; width: var(--w); height: 32px; padding: 0 .7rem; border-radius: 999px; justify-content: flex-end;
  background: var(--line-strong); border-color: transparent; color: var(--fg); font-size: .78rem; font-weight: 650; letter-spacing: .03em; text-transform: uppercase;
  transition: background .15s;
}
.switch .knob { position: absolute; left: 4px; top: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .25); transition: left .15s; }
.switch[aria-pressed=true] { background: var(--ok); color: #fff; justify-content: flex-start; }
.switch[aria-pressed=true] .knob { left: calc(var(--w) - 28px); }
.switch:hover { filter: brightness(1.05); border-color: transparent; }

/* Confirm-before-delete disclosures */
.confirm > summary { cursor: pointer; font-size: .82rem; color: var(--bad); list-style: none; width: max-content; }
.confirm > summary::-webkit-details-marker { display: none; }
.confirm[open] > summary { margin-bottom: .5rem; }
.confirm .muted { margin-left: .5rem; }

/* Settings */
.settings { margin-top: 2.75rem; display: grid; gap: .6rem; }
.settings h2 { margin-bottom: .1rem; }
.setting { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: .5rem 1.5rem; align-items: center; }
.setting h3 + p { margin-top: .15rem; }
.danger-card { border-color: color-mix(in srgb, var(--bad) 30%, var(--line)); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: 100%; max-width: 360px; padding: 1.75rem; display: grid; gap: 1.1rem; }
.login-card .brand { font-size: 1.15rem; }
.login-card .flash { margin: 0; }
.login-card button { justify-content: center; }

@media (max-width: 640px) {
  .setting { grid-template-columns: 1fr; }
  .inline-form, .copy-row { flex-wrap: wrap; }
  .feature { grid-template-columns: 1fr auto; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---- GrapesLabs User additions ---- */
.mark { background: radial-gradient(circle at 35% 35%, #d9c8ff, var(--accent) 55%, #2e1a6e); }
.tabs { display: flex; gap: .15rem; margin-left: .75rem; }
.tabs a { text-decoration: none; font-size: .88rem; font-weight: 550; color: var(--muted); padding: .3rem .65rem; border-radius: 7px; }
.tabs a:hover { color: var(--fg); background: var(--bg); }
.tabs a[aria-current=page] { color: var(--accent); background: var(--accent-soft); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.sub { display: block; color: var(--muted); font-size: .8rem; font-weight: 400; margin-top: .1rem; }
.button.ghost { border-color: transparent; background: transparent; color: var(--muted); font-weight: 500; }

/* Toolbar */
.toolbar { margin-bottom: .9rem; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.filters input[type=search] { flex: 1 1 260px; width: auto; }
.filters select { width: auto; flex: 0 1 220px; }

/* Tables */
.table-card { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .6rem .9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th { font-size: .75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: var(--bg); white-space: nowrap; }
thead th code { text-transform: none; letter-spacing: 0; font-size: .76rem; }
tbody tr:last-child > * { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
tbody th { font-weight: 500; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.kcol { text-align: center; width: 1%; padding-left: .3rem; padding-right: .3rem; }
thead th.kcol code { font-size: .7rem; }
.plink { display: grid; text-decoration: none; min-width: 10rem; }
.plink:hover .plabel { color: var(--accent); }
.plabel { font-weight: 600; }
.psub { font-size: .78rem; color: var(--muted); }
.keys td .chip { margin-right: .4rem; }
.keys .num a { margin-left: .4rem; color: var(--muted); }
.keys .num a:hover { color: var(--accent); }
.legend { margin-top: .6rem; display: flex; align-items: center; gap: .35rem; }
.legend .dot + * { margin-right: .6rem; }

/* Filled / not filled marks */
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: middle; }
.dot.on { background: var(--ok); }
.dot.off { border: 2px dashed var(--muted); opacity: .7; }
.ratio { font-weight: 600; }
.ratio.full { color: var(--ok); }
.ratio.none { color: var(--muted); }
.badge { font-size: .74rem; font-weight: 600; border-radius: 999px; padding: .12rem .6rem; white-space: nowrap; justify-self: end; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.none { color: var(--muted); border: 1px dashed var(--line-strong); }

/* Profile page */
.summary { display: grid; grid-template-columns: 1fr minmax(140px, 260px); gap: 1rem; align-items: center; margin-bottom: 1.5rem; }
.summary-num { font-size: 1.05rem; }
progress { width: 100%; height: 10px; appearance: none; border: 0; border-radius: 999px; background: var(--line); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--line); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--ok); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--ok); border-radius: 999px; }
.value.is-empty { border-style: dashed; box-shadow: none; background: transparent; }
.vlabel { font-weight: 600; }
.value .fname { font-size: .8rem; font-weight: 500; }
.vvalue { grid-column: 1 / -1; font-size: .95rem; }
.value.is-filled .vvalue { font-weight: 500; }
.feature:has(.edit[open]) .vvalue { display: none; }
.feature .edit .hint { margin-top: -.35rem; }
.empty { text-align: center; padding: 2rem 1rem; display: grid; gap: .3rem; }

@media (max-width: 640px) {
  .summary { grid-template-columns: 1fr; }
  .tabs { margin-left: 0; }
  .top-in { flex-wrap: wrap; }
}
