:root {
  color-scheme: dark;
  --bg: #07090d;
  --panel: #11151e;
  --panel-2: #161b25;
  --line: #31394a;
  --line-soft: #232a38;
  --text: #f2f5fb;
  --muted: #a5adbd;
  --accent: #c9ff45;
  --accent-ink: #111700;
  --blue: #54b5ff;
  --danger: #ff7882;
  --warning: #ffc966;
  --success: #63e6a0;
  --radius: 22px;
  --safe-bottom: max(16px, env(safe-area-inset-bottom));
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Hiragino Sans", "Noto Sans JP", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { min-height: 100dvh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--blue); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.shell { min-height: 100dvh; padding-bottom: calc(88px + var(--safe-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 16px 12px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(18px); border-bottom: 1px solid var(--line-soft);
}
.brand { min-width: 0; }
.brand h1 { margin: 0; font-size: 20px; letter-spacing: .01em; }
.brand p { margin: 3px 0 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 8px; }
.icon-btn, .button, .chip, select, input, textarea {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 14px;
}
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; font-size: 18px; }
.icon-btn:hover, .button:hover { border-color: #566176; }
.main { width: min(1180px, 100%); margin: 0 auto; padding: 18px 16px 28px; }
.hero { display: grid; gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card h2, .card h3 { margin: 0 0 10px; }
.card p { color: var(--muted); line-height: 1.65; }
.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.metric { background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: 18px; padding: 14px; }
.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 5px; font-size: 25px; }
.section-head { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin: 22px 0 10px; }
.section-head h2 { margin: 0; font-size: 19px; }
.section-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.button { min-height: 44px; padding: 10px 15px; font-weight: 700; }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.button.ghost { background: transparent; }
.button.small { min-height: 36px; padding: 7px 11px; font-size: 13px; }
.button:disabled { opacity: .45; cursor: not-allowed; }
.app-grid, .item-grid { display: grid; gap: 12px; }
.app-card { position: relative; overflow: hidden; }
.app-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--accent); }
.app-title { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.app-title h3 { margin: 0; }
.muted { color: var(--muted); }
.meta-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.chip { display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 5px 9px; font-size: 12px; white-space: nowrap; }
.chip.p0, .chip.blocked, .chip.incident { color: #ffd3d6; border-color: #7f3b43; background: #2a151a; }
.chip.done, .chip.released, .chip.active { color: #c9ffe1; border-color: #2c6b4d; background: #11291e; }
.chip.progress, .chip.testing, .chip.reviewing { color: #d4edff; border-color: #305f7e; background: #102334; }
.chip.warning, .chip.ready, .chip.new { color: #ffedc1; border-color: #73582c; background: #2b2111; }
.item { display: grid; gap: 10px; }
.item-top { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; min-width: 0; }
.item-top > * { min-width: 0; }
.item-title { font-weight: 800; line-height: 1.5; }
.item-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; word-break: break-word; }
.item-details { color: var(--muted); white-space: pre-wrap; line-height: 1.55; overflow-wrap: anywhere; }
.item-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.filters select, .filters input { width: 100%; min-height: 44px; padding: 8px 11px; }
.filters .filter-query, .filters .filter-reset { grid-column: 1 / -1; }
.empty { padding: 28px 14px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.bottom-nav {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px;
  padding: 8px 8px var(--safe-bottom); background: color-mix(in srgb, #0b0e14 94%, transparent);
  backdrop-filter: blur(18px); border-top: 1px solid var(--line-soft);
}
.nav-btn { border: 0; background: transparent; color: var(--muted); min-height: 58px; border-radius: 15px; font-size: 11px; font-weight: 700; }
.nav-btn span { display: block; font-size: 20px; margin-bottom: 3px; }
.nav-btn.active { color: var(--text); background: #172131; box-shadow: inset 0 3px 0 var(--blue); }
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)); }
.login-card { width: min(560px, 100%); padding: 26px; }
.login-card h1 { margin: 0 0 16px; font-size: clamp(34px, 9vw, 58px); }
.login-card .lead { font-size: 18px; color: var(--muted); line-height: 1.55; }
.field { display: grid; gap: 7px; margin-top: 15px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 700; }
.field input, .field select, .field textarea { width: 100%; min-height: 50px; padding: 11px 13px; }
.field textarea { min-height: 110px; resize: vertical; }
.login-card .button { width: 100%; min-height: 58px; margin-top: 16px; font-size: 18px; }
.notice { border: 1px solid var(--line); border-radius: 18px; padding: 14px; margin-top: 16px; color: var(--muted); line-height: 1.6; }
.notice.error { color: #ffd7da; border-color: #793d46; background: #241317; }
.notice.success { color: #d1ffe4; border-color: #30674c; background: #10271b; }
.dialog { width: min(680px, calc(100% - 24px)); max-height: calc(100dvh - 28px); overflow: auto; border: 1px solid var(--line); border-radius: 24px; background: var(--panel); color: var(--text); padding: 0; }
.dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(5px); }
.dialog-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; background: var(--panel); border-bottom: 1px solid var(--line-soft); z-index: 1; }
.dialog-head h2 { margin: 0; font-size: 20px; }
.dialog-body { padding: 18px; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 18px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line-soft); }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 7px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: calc(90px + var(--safe-bottom)); transform: translate(-50%, 18px); opacity: 0; pointer-events: none; width: min(480px, calc(100% - 32px)); padding: 12px 15px; border: 1px solid var(--line); border-radius: 16px; background: #171c26; box-shadow: 0 16px 50px rgba(0,0,0,.4); transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; overflow-wrap: anywhere; }

.audit-time { white-space: nowrap; flex: 0 0 auto; font-size: 12px; }
.audit-details { min-width: 0; border: 1px solid var(--line-soft); border-radius: 14px; overflow: hidden; }
.audit-details summary { cursor: pointer; padding: 10px 12px; color: var(--muted); font-weight: 700; list-style-position: inside; }
.audit-details[open] summary { border-bottom: 1px solid var(--line-soft); }
.audit-json { margin: 0; padding: 12px; max-width: 100%; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; color: var(--muted); line-height: 1.55; }
.audit-actor { padding-top: 2px; }
@media (max-width: 540px) {
  .audit-item .item-top { display: grid; grid-template-columns: minmax(0, 1fr); }
  .audit-time { justify-self: start; }
}

@media (min-width: 720px) {
  .metric-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .app-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .item-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .filters { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .filters .filter-query, .filters .filter-reset { grid-column: auto; }
  .bottom-nav { left: 50%; right: auto; width: min(680px, 100%); transform: translateX(-50%); border: 1px solid var(--line-soft); border-bottom: 0; border-radius: 22px 22px 0 0; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
