/* Persona Studio — one stylesheet, no build step. */
:root {
  --bg: #f6f4f0;
  --panel: #ffffff;
  --ink: #1d1b19;
  --muted: #6d6760;
  --line: #e4dfd7;
  --accent: #3a5a8c;
  --accent-ink: #ffffff;
  --accent-soft: #e6ecf5;
  --ok: #2f7d4f;
  --ok-soft: #e3f2e8;
  --warn: #a06200;
  --warn-soft: #fbf0dc;
  --bad: #b3261e;
  --bad-soft: #fbe5e3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(30, 25, 20, .06), 0 2px 8px rgba(30, 25, 20, .04);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.12rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; line-height: 1.5; }
code, pre { font-family: var(--mono); font-size: .85rem; }
pre { background: #faf8f5; border: 1px solid var(--line); border-radius: 8px; padding: .75rem; overflow: auto; max-height: 360px; white-space: pre-wrap; }
small, .muted { color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

/* Layout */
.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.side { background: #1f2430; color: #d8dce6; padding: 1.1rem .8rem; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { font-weight: 700; color: #fff; font-size: 1.05rem; padding: .2rem .6rem 1rem; letter-spacing: .01em; }
.brand span { color: #9fb6dd; font-weight: 500; }
.side nav a { display: flex; justify-content: space-between; align-items: center; color: #c9cfdc; padding: .5rem .65rem; border-radius: 7px; margin-bottom: 2px; }
.side nav a:hover { background: #2b3242; text-decoration: none; color: #fff; }
.side nav a.on { background: #34405a; color: #fff; }
.side .pill { background: #5a7bb5; color: #fff; border-radius: 99px; font-size: .72rem; padding: 0 .45rem; }
.side .foot { margin-top: auto; font-size: .78rem; color: #8790a3; padding: .5rem .6rem; }
.side .foot button { background: none; border: 0; color: #aab3c5; padding: 0; cursor: pointer; font: inherit; }
.main { padding: 1.25rem 1.75rem 3rem; min-width: 0; }
.top { display: flex; gap: 1rem; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; flex-wrap: wrap; }
.switcher { display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; }
.switcher a { border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: .25rem .75rem; color: var(--ink); font-size: .88rem; display: inline-flex; gap: .4rem; align-items: center; }
.switcher a.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.switcher a:hover { text-decoration: none; border-color: var(--muted); }
.switcher img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head p { margin: 0; color: var(--muted); }

.grid { display: grid; gap: 1rem; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
@media (max-width: 1100px) { .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .side nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
  .main { padding: 1rem; }
}

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); min-width: 0; }
.card + .card { margin-top: 1rem; }
.grid > .card + .card { margin-top: 0; }
.card.flat { box-shadow: none; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .75rem; }
.card-head h2 { margin: 0; }
.section { scroll-margin-top: 1rem; }
.compact-form { display: flex; gap: .4rem; align-items: center; }
.compact-form input[type=number] { width: 5.5rem; }

/* Forms */
label { display: block; font-weight: 600; font-size: .86rem; margin: .65rem 0 .3rem; }
label .hint, .hint { font-weight: 400; color: var(--muted); font-size: .82rem; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], input[type=url], input[type=search], select, textarea {
  width: 100%; padding: .5rem .6rem; border: 1px solid #d6d0c6; border-radius: 7px; font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 5.5rem; resize: vertical; line-height: 1.45; }
textarea.tall { min-height: 16rem; }
textarea.code { font-family: var(--mono); font-size: .82rem; min-height: 9rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.row { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1 1 160px; min-width: 0; }
.row > .shrink { flex: 0 0 auto; }
.check { display: flex; gap: .45rem; align-items: center; font-weight: 500; margin: .5rem 0; }
.check input { width: auto; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .9rem; }
form.inline { display: inline; }

.btn, button { display: inline-flex; align-items: center; gap: .35rem; font: inherit; font-weight: 600; font-size: .88rem; padding: .48rem .9rem; border-radius: 7px; border: 1px solid #cfc8bd; background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover, button:hover { border-color: var(--muted); text-decoration: none; }
.btn.primary, button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover, button.primary:hover { filter: brightness(1.08); }
.btn.danger, button.danger { color: var(--bad); border-color: #e6b8b4; }
.btn.small, button.small { padding: .25rem .55rem; font-size: .8rem; }
.btn.ghost, button.ghost { border-color: transparent; background: transparent; }
button[disabled] { opacity: .5; cursor: not-allowed; }
.htmx-request.btn, .htmx-request button { opacity: .6; }

/* Status */
.badge { display: inline-block; font-size: .74rem; font-weight: 600; padding: .1rem .5rem; border-radius: 99px; background: #eeeae4; color: #4b463f; white-space: nowrap; }
.badge.ok, .badge.succeeded, .badge.published, .badge.ready { background: var(--ok-soft); color: var(--ok); }
.badge.running, .badge.publishing, .badge.training, .badge.scheduled, .badge.starting { background: var(--accent-soft); color: var(--accent); }
.badge.queued, .badge.draft, .badge.none, .badge.manual { background: #eeeae4; color: #5b554d; }
.badge.failed, .badge.error, .badge.canceled { background: var(--bad-soft); color: var(--bad); }
.badge.warn, .badge.due { background: var(--warn-soft); color: var(--warn); }
.badge.destroyed { background: #ece9f5; color: #4d3f86; }
.bar { height: 6px; background: #ece7df; border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.bar.over > span { background: var(--bad); }

.flash { padding: .65rem .9rem; border-radius: 8px; margin-bottom: .6rem; background: var(--ok-soft); color: #1f5a37; border: 1px solid #c6e3cf; }
.flash.error { background: var(--bad-soft); color: #7d1b15; border-color: #efc4c0; }
.notice { padding: .75rem .9rem; border-radius: 8px; background: var(--warn-soft); border: 1px solid #efd9b0; color: #6e4600; margin-bottom: 1rem; }
.notice.info { background: var(--accent-soft); border-color: #cbd7ea; color: #24406a; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; padding: .45rem .5rem; border-bottom: 1px solid var(--line); }
td { padding: .55rem .5rem; border-bottom: 1px solid #efebe5; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* Media */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .65rem; }
.media-grid.small { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
.tile { position: relative; border-radius: 8px; overflow: hidden; background: #e9e4dc; aspect-ratio: 4 / 5; border: 1px solid var(--line); }
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .tag { position: absolute; left: 6px; top: 6px; background: rgba(20, 18, 16, .65); color: #fff; font-size: .7rem; border-radius: 99px; padding: .05rem .45rem; }
.tile .tools { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: .3rem; justify-content: space-between; padding: .35rem; background: linear-gradient(transparent, rgba(0, 0, 0, .55)); }
.tile .tools button, .tile .tools .btn { padding: .2rem .45rem; font-size: .74rem; background: rgba(255, 255, 255, .92); border: 0; }
.tile.kept { outline: 3px solid var(--ok); outline-offset: -3px; }
.tile.chosen { outline: 3px solid var(--accent); outline-offset: -3px; }
.tile .fav { position: absolute; right: 6px; top: 4px; background: none; border: 0; padding: 0; font-size: 1.1rem; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); cursor: pointer; }
.tile .fav.on { color: #ffcf4a; }
.placeholder { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--muted); font-size: .8rem; text-align: center; padding: .5rem; }
.avatar { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; background: #e3ddd3; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: #6d6760; font-size: 1.2rem; }
.avatar.lg { width: 84px; height: 84px; font-size: 1.6rem; }
.viewer { background: #1b1a18; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; min-height: 320px; overflow: hidden; }
.viewer img, .viewer video { max-width: 100%; max-height: 78vh; display: block; }

/* Characters */
.char-card { display: flex; gap: .85rem; align-items: flex-start; }
.char-card .meta { flex: 1; min-width: 0; }
.char-card h3 { margin: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .25rem .75rem; font-size: .88rem; margin-top: .5rem; }
.kv dt { color: var(--muted); white-space: nowrap; }
.kv dd { margin: 0; }
.chips { display: flex; gap: .3rem; flex-wrap: wrap; }

/* Stepper */
.stepper { display: flex; gap: 0; margin: .25rem 0 1.25rem; counter-reset: step; flex-wrap: wrap; }
.stepper a { flex: 1; min-width: 120px; padding: .6rem .75rem; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: .86rem; font-weight: 600; position: relative; }
.stepper a:first-child { border-radius: 8px 0 0 8px; }
.stepper a:last-child { border-radius: 0 8px 8px 0; }
.stepper a + a { border-left: 0; }
.stepper a::before { counter-increment: step; content: counter(step); display: inline-flex; width: 1.35rem; height: 1.35rem; border-radius: 50%; background: #ece7df; color: var(--muted); align-items: center; justify-content: center; margin-right: .45rem; font-size: .76rem; }
.stepper a.done { color: var(--ok); }
.stepper a.done::before { background: var(--ok-soft); color: var(--ok); content: "✓"; }
.stepper a.now { color: var(--ink); background: var(--accent-soft); border-color: #c9d6ea; }
.stepper a.now::before { background: var(--accent); color: #fff; }
.stepper a:hover { text-decoration: none; }

/* Calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .5rem; }
@media (max-width: 1100px) { .cal { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.day { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; min-height: 140px; padding: .5rem; display: flex; flex-direction: column; gap: .4rem; }
.day.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.day .d { font-size: .78rem; font-weight: 700; color: var(--muted); display: flex; justify-content: space-between; }
.post-chip { display: flex; gap: .4rem; align-items: center; border: 1px solid var(--line); border-radius: 7px; padding: .3rem; background: #fcfbf9; color: var(--ink); font-size: .8rem; }
.post-chip:hover { text-decoration: none; border-color: var(--muted); }
.post-chip img, .post-chip .ph { width: 34px; height: 42px; object-fit: cover; border-radius: 4px; background: #e9e4dc; flex: 0 0 auto; }
.post-chip .t { min-width: 0; overflow: hidden; }
.post-chip .t div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Checklist */
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; gap: .6rem; padding: .4rem 0; border-bottom: 1px solid #efebe5; align-items: baseline; }
.checklist li:last-child { border-bottom: 0; }
.checklist .mark { width: 1.2rem; flex: 0 0 auto; font-weight: 700; }
.checklist .done .mark { color: var(--ok); }
.checklist .todo .mark { color: var(--warn); }

/* Concepts */
.concept { display: flex; flex-direction: column; }
.concept .look { font-size: .86rem; color: #4a453e; background: #faf8f5; border-radius: 7px; padding: .5rem .6rem; margin: .5rem 0; }

/* Login */
.login { max-width: 380px; margin: 12vh auto; }
.login .brand-lg { font-size: 1.4rem; font-weight: 700; margin-bottom: 1rem; text-align: center; }

.stat { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.split { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
.empty { text-align: center; color: var(--muted); padding: 1.5rem .5rem; }
details summary { cursor: pointer; font-weight: 600; font-size: .88rem; margin: .5rem 0; }
.copy-src { position: absolute; left: -9999px; }
.secret-set { color: var(--ok); font-weight: 600; font-size: .82rem; }

/* Settings: tabs per group, sub-sections, search */
.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.settings-layout [hidden] { display: none !important; }
.settings-nav { position: sticky; top: 1rem; padding: .5rem; max-height: calc(100vh - 2rem); overflow-y: auto; }
.settings-nav a { display: flex; justify-content: space-between; align-items: center; padding: .42rem .6rem; border-radius: 6px; color: var(--ink); font-weight: 600; font-size: .9rem; }
.settings-nav a:hover { background: var(--bg); text-decoration: none; }
.settings-nav a.on { background: var(--accent-soft); color: var(--accent); }
.settings-nav .subs { margin: .1rem 0 .35rem; }
.settings-nav .subs a { font-weight: 400; font-size: .82rem; color: var(--muted); padding: .28rem .6rem .28rem 1.3rem; }
.settings-nav .dirty { display: none; color: var(--warn); font-size: .7rem; }
.settings-nav a.is-dirty .dirty { display: inline; }
.settings-search input { width: 260px; }
.settings-panels { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.settings-panels .card + .card { margin-top: 0; }
.settings-sub:not([hidden]) ~ .settings-sub:not([hidden]) { border-top: 1px solid var(--line); margin-top: 1.1rem; padding-top: 1rem; }
.settings-sub h3 { font-size: .98rem; margin: 0 0 .35rem; }
.settings-sub > p.hint { margin: 0 0 .75rem; }
.settings-sub .field.wide { grid-column: 1 / -1; }
.settings-sub details.field summary { margin: .2rem 0 .4rem; }
.panel-actions { position: sticky; bottom: 0; background: var(--panel); padding: .75rem 0 .25rem; border-top: 1px solid var(--line); margin-top: 1rem; }
@media (max-width: 820px) {
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { position: static; max-height: none; display: flex; flex-wrap: wrap; gap: 2px; }
  .settings-nav .subs { display: none; }
  .settings-search, .settings-search input { width: 100%; }
}
.commit-list { margin: .75rem 0 0; padding-left: 1.1rem; font-size: .88rem; }
.commit-list li { margin: .15rem 0; }
.update-log summary { margin-top: 1rem; }
.update-log pre.log { font-size: .78rem; max-height: 420px; }
.label-row { display: flex; justify-content: space-between; align-items: flex-end; gap: .5rem; margin: .65rem 0 .3rem; min-height: 1.75rem; }
.label-row label { margin: 0; }
.keycheck:not(:empty) { margin-top: .35rem; font-size: .85rem; }
#kc-all:not(:empty) { margin: -.25rem 0 .75rem; }
