[hidden] { display: none !important; }
:root {
  --bg: #f6f5f2; --card: #fff; --ink: #1f2430; --muted: #6b7280; --line: #e3e1db;
  --brand: #3730a3; --brand-ink: #fff; --ok: #15803d; --warn: #b45309; --fail: #b91c1c; --sel: #e0e7ff;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14161b; --card: #1d2027; --ink: #e8e9ec; --muted: #9aa0ab; --line: #2e323b;
          --brand: #818cf8; --brand-ink: #111; --ok: #4ade80; --warn: #fbbf24; --fail: #f87171; --sel: #2b2f55; color-scheme: dark; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
       padding-bottom: env(safe-area-inset-bottom); }
a { color: var(--brand); }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; justify-content: space-between;
       padding: 8px 12px; background: var(--card); border-bottom: 1px solid var(--line); }
.top strong { flex: 1; text-align: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
main { max-width: 1100px; margin: 0 auto; padding: 12px 16px 96px; }
.pad { padding: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .fail { color: var(--fail); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin: 0 0 12px; }
h2 { font-size: 18px; margin: 0 0 8px; } h3 { font-size: 15px; margin: 12px 0 6px; }
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 10px;
               padding: 10px 14px; min-height: 44px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center;
               justify-content: center; gap: 6px; }
button.primary, .btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
button.ghost { border: none; background: none; padding: 8px; min-height: 40px; color: var(--brand); }
button:disabled { opacity: .45; cursor: default; }
button.danger { color: var(--fail); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.row > .grow { flex: 1; min-width: 0; }
input[type=text], input[type=password], input[type=search], textarea, select {
  font: inherit; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); }
textarea { min-height: 120px; resize: vertical; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
textarea.json { min-height: 260px; }
.today .line { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.today .line:first-of-type { border-top: none; }
.group > summary { list-style: none; cursor: pointer; font-weight: 600; padding: 10px 2px; display: flex; justify-content: space-between; }
.group > summary::-webkit-details-marker { display: none; }
.item { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-top: 1px solid var(--line); cursor: pointer; }
.item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .dots { font-size: 12px; letter-spacing: 1px; color: var(--muted); }
.item.selected { background: var(--sel); }
.badge { font-size: 12px; padding: 2px 7px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }
.badge.warn { color: var(--warn); border-color: currentColor; }
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 8px 0 12px; position: sticky; top: 57px; z-index: 4;
        background: var(--bg); padding: 4px 0; }
.tabs button { padding: 8px 4px; font-size: 14px; }
.tabs button.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.banner { background: #fef3c7; color: #78350f; border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
@media (prefers-color-scheme: dark) { .banner { background: #3b2f0f; color: #fde68a; } }
.selection { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.selection .cover-wrap { grid-column: 1 / -1; }
.slot { position: relative; aspect-ratio: 3/2; background: var(--bg); border: 1px dashed var(--line); border-radius: 8px; overflow: hidden;
        padding: 0; min-height: 0; width: 100%; display: block; }
.slot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.slot .tag { position: absolute; left: 4px; top: 4px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 6px; }
@media (min-width: 700px) { .selection { grid-template-columns: repeat(4, 1fr); } .selection .cover-wrap { grid-column: span 2; grid-row: span 2; } }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-top: 10px; }
.tile { background: var(--card); border: 2px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.tile.is-cover { border-color: var(--warn); } .tile.is-gallery { border-color: var(--brand); }
.tile img { width: 100%; aspect-ratio: 3/2; object-fit: cover; display: block; background: var(--bg); cursor: zoom-in; }
.tile .cap { font-size: 12px; color: var(--muted); padding: 4px 6px; min-height: 2.6em; }
.tile .acts { display: grid; grid-template-columns: 1fr 1fr; }
.tile .acts button { border-radius: 0; border: none; border-top: 1px solid var(--line); min-height: 40px; font-size: 13px; padding: 4px; }
.tile .acts button.on { background: var(--brand); color: var(--brand-ink); }
.checks li { margin: 4px 0; }
.checks { padding-left: 0; list-style: none; }
.preview dt { font-weight: 600; margin-top: 8px; font-size: 14px; }
.preview dd { margin: 2px 0 0; white-space: pre-wrap; }
.log { font: 12px/1.4 ui-monospace, monospace; white-space: pre-wrap; background: var(--bg); border-radius: 8px; padding: 8px; max-height: 220px; overflow: auto; }
.footer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--card); border-top: 1px solid var(--line);
          padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: center; }
.footer .grow { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 84px; z-index: 20; max-width: min(92vw, 560px); }
#toast div { background: #111827; color: #fff; padding: 10px 14px; border-radius: 10px; margin-top: 6px; font-size: 14px; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
#toast div.fail { background: #7f1d1d; } #toast div.ok { background: #14532d; } #toast div.warn { background: #78350f; }
.sheet { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; }
.sheet > .panel { background: var(--card); width: 100%; max-width: 720px; max-height: 92vh; overflow: auto; border-radius: 16px 16px 0 0;
                  padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet .menu button { width: 100%; justify-content: flex-start; margin: 4px 0; }
.viewer { position: fixed; inset: 0; z-index: 40; background: #000; display: flex; flex-direction: column; }
.viewer img { flex: 1; min-height: 0; object-fit: contain; width: 100%; }
.viewer .bar { display: flex; gap: 8px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: #111; color: #ddd; flex-wrap: wrap; align-items: center; }
.viewer .bar .grow { flex: 1; font-size: 13px; min-width: 50%; }
.crop { position: fixed; inset: 0; z-index: 45; background: #000; display: flex; flex-direction: column; color: #eee; }
.crop .stage { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: none; }
.crop .stage img { max-width: 100%; max-height: 100%; display: block; user-select: none; -webkit-user-drag: none; }
.crop .frame { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(0,0,0,.55); cursor: move; }
.crop .bar { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: #111; }
.crop input[type=range] { width: 100%; }
.selbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 7; background: var(--card); border-top: 1px solid var(--line); padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); }
.field { margin: 10px 0; } .field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 2px; }
