:root {
  color-scheme: light dark;
  --bg: #0f1115;
  --bg-elevated: #171a21;
  --bg-selected: #1f2430;
  --line: #262b36;
  --text: #e8eaf0;
  --text-dim: #9aa3b2;
  --accent: #6ea8fe;
  --ok: #3ecf8e;
  --warn: #e3b341;
  --danger: #f0616d;
  --radius: 10px;
  --sidebar-w: 320px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100dvh;
}

/* ------------------------------------------------------------------ sidebar */

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  border-right: 1px solid var(--line);
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  max-height: 100dvh;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 18px 16px 12px;
}

.sidebar-head h1 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}

.icon-button:hover { background: var(--bg-selected); color: var(--text); }
.icon-button[aria-busy="true"] svg { animation: spin 900ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.search-row { padding: 0 12px 10px; }

.search-row input {
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.search-row input::placeholder { color: var(--text-dim); }
.search-row input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.app-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 7px 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.row:hover { background: var(--bg-selected); }
.row[aria-current="true"] {
  background: var(--bg-selected);
  border-color: var(--line);
}
.row:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.row-select {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.row-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.row-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }

.row-name {
  font-size: 13.5px;
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-sub {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 5px;
  background: var(--text-dim);
  vertical-align: 1px;
}
.row[data-published="true"] .dot { background: var(--ok); }

/* ------------------------------------------------------------------- button */

button.action {
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

button.action:hover { border-color: var(--accent); color: var(--accent); }
button.action:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.action:disabled { opacity: 0.55; cursor: progress; }
button.action.published { color: var(--ok); border-color: color-mix(in oklab, var(--ok) 45%, var(--line)); }

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 10px 16px;
}

.summary { margin: 0; font-size: 11.5px; color: var(--text-dim); }

/* ------------------------------------------------------------------- detail */

.detail {
  padding: 32px clamp(20px, 5vw, 56px);
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.empty { max-width: 46ch; color: var(--text-dim); }
.empty h2 { color: var(--text); font-size: 20px; margin: 0 0 8px; }
.empty p { margin: 0; line-height: 1.6; font-size: 14px; }

.detail h2 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text-dim);
}
.chip.ok { color: var(--ok); border-color: color-mix(in oklab, var(--ok) 45%, var(--line)); }
.chip.idle { color: var(--warn); border-color: color-mix(in oklab, var(--warn) 40%, var(--line)); }

.facts { display: grid; gap: 14px; margin: 0; }
.facts div { display: grid; gap: 3px; }
.facts dt { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-dim); }
.facts dd { margin: 0; font-size: 13.5px; word-break: break-all; }
.facts a { color: var(--accent); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions a.action { text-decoration: none; display: inline-flex; align-items: center; }
.actions .primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06121f;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 8px;
}
.actions .primary:hover { filter: brightness(1.06); color: #06121f; }

.log {
  margin: 0;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  color: var(--text-dim);
  white-space: pre-wrap;
  overflow-x: auto;
}

.notice { font-size: 13px; color: var(--text-dim); line-height: 1.6; }
.notice[data-tone="error"] { color: var(--danger); }
.notice[data-tone="ok"] { color: var(--ok); }

@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--line); }
  .app-list { max-height: 45dvh; }
  .detail { padding: 22px 18px; }
}
