:root {
  --bg: #f1f1f4; --card: #fff; --text: #16161a; --hint: #7d7d86; --line: #e3e3e8;
  --accent: #2f7cf6; --on-accent: #fff; --danger: #d43d3d; --ok: #1f9d55; --warn: #b26a00;
  --add: #e6f6ea; --add-ink: #14532d; --del: #fdeaea; --del-ink: #7f1d1d; --hunk: #eef2ff; --hunk-ink: #4c5a9a;
  --safe-bottom: 0px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #17181c; --card: #212329; --text: #ececf0; --hint: #9a9aa6; --line: #33353d;
  --accent: #5b9dff; --on-accent: #0b1220; --danger: #ff7b7b; --ok: #4cc38a; --warn: #f0b24d;
  --add: #16321f; --add-ink: #b6efc6; --del: #3a1c1c; --del-ink: #ffc9c9; --hunk: #22283f; --hunk-ink: #a9b6ee;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-text-size-adjust: 100%; overscroll-behavior: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
#app { max-width: 720px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }

.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 10px 14px 8px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--line); border-radius: 12px; padding: 3px; }
.tabs button { min-height: 38px; border-radius: 9px; font-weight: 600; color: var(--hint); }
.tabs button[aria-selected="true"] { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 10px; background: var(--accent); color: var(--on-accent); font-size: 12px; line-height: 20px; }
.count:empty { display: none; }

main, #detail { padding: 4px 14px calc(24px + var(--safe-bottom)); flex: 1; }
#detail { padding-bottom: calc(96px + var(--safe-bottom)); }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--hint); margin: 18px 4px 8px; font-weight: 600; }
.card { display: block; width: 100%; text-align: left; background: var(--card); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; }
button.card:active { opacity: .7; }
.row1 { display: flex; align-items: baseline; gap: 8px; }
.repo { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.when { color: var(--hint); font-size: 12px; white-space: nowrap; }
.title { margin-top: 2px; overflow-wrap: anywhere; }
.meta { margin-top: 6px; color: var(--hint); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.badge { display: inline-block; border-radius: 6px; padding: 1px 7px; font-size: 12px; font-weight: 600; }
.badge.auto { background: var(--hunk); color: var(--hunk-ink); }
.badge.sev-critical { background: #7f1d1d; color: #fff; }
.badge.sev-high { background: #c2410c; color: #fff; }
.badge.sev-medium { background: #b58900; color: #fff; }
.badge.sev-low { background: #2563eb; color: #fff; }
.empty { text-align: center; color: var(--hint); padding: 28px 16px; background: var(--card); border-radius: 14px; }
.note { background: var(--card); border-radius: 14px; padding: 10px 14px; margin-bottom: 8px; color: var(--hint); font-size: 13px; }
.note b { color: var(--text); font-weight: 600; }
.note.warn { color: var(--warn); }
.inline { display: flex; gap: 8px; margin-top: 10px; }
.btn { min-height: 44px; padding: 0 14px; border-radius: 11px; background: var(--line); font-weight: 600; flex: 1; text-align: center; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; }
.link { color: var(--accent); }

.dhead { padding: 6px 4px 0; }
.back { color: var(--accent); min-height: 40px; font-weight: 600; }
.dtitle { font-size: 19px; font-weight: 700; line-height: 1.25; margin: 2px 0 4px; overflow-wrap: anywhere; }
.sec { background: var(--card); border-radius: 14px; padding: 12px 14px; margin-top: 10px; }
.sec h3 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--hint); font-weight: 600; }
.text { white-space: pre-wrap; overflow-wrap: anywhere; }
.text .h { font-weight: 700; display: block; margin-top: 8px; }
.quote { border-left: 3px solid var(--line); padding-left: 10px; color: var(--text); }
.clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 5; line-clamp: 5; overflow: hidden; cursor: pointer; }
.quote { margin-top: 8px; }
ul.plain { margin: 6px 0 0; padding-left: 20px; }
pre.code { margin: 8px 0; padding: 10px; background: var(--bg); border-radius: 10px; overflow-x: auto; font: 12.5px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; white-space: pre; }

.file { margin-top: 10px; background: var(--card); border-radius: 14px; overflow: hidden; }
.file > button { display: flex; width: 100%; gap: 8px; align-items: baseline; padding: 10px 14px; text-align: left; }
.fname { flex: 1; min-width: 0; font: 600 13px/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace; overflow-wrap: anywhere; }
.fstat { font-size: 12px; white-space: nowrap; }
.fstat .a { color: var(--ok); } .fstat .d { color: var(--danger); }
.diff { overflow-x: auto; border-top: 1px solid var(--line); font: 12.5px/1.55 ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.diff > div { min-width: max-content; }
.ln { white-space: pre; padding: 0 12px; }
.ln.add { background: var(--add); color: var(--add-ink); }
.ln.del { background: var(--del); color: var(--del-ink); }
.ln.hunk { background: var(--hunk); color: var(--hunk-ink); padding-top: 2px; padding-bottom: 2px; }

.bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--bg); border-top: 1px solid var(--line); padding: 10px 14px calc(10px + var(--safe-bottom)); }
.bar > div { max-width: 692px; margin: 0 auto; display: flex; gap: 8px; flex-wrap: wrap; }
.bar .btn { flex: 1 1 30%; }
.bar .btn.wide { flex-basis: 100%; }

.sheet { position: fixed; inset: 0; z-index: 10; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet > form { width: 100%; max-width: 720px; background: var(--card); border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + var(--safe-bottom)); }
.sheet h3 { margin: 0 0 4px; font-size: 17px; }
.sheet p { margin: 0 0 10px; color: var(--hint); font-size: 14px; }
.sheet textarea { width: 100%; min-height: 96px; border: 1px solid var(--line); border-radius: 11px; padding: 10px; background: var(--bg); color: var(--text); font: inherit; font-size: 16px; resize: vertical; }
#toast { position: fixed; left: 14px; right: 14px; bottom: calc(86px + var(--safe-bottom)); margin: 0 auto; max-width: 480px; z-index: 12; padding: 11px 14px; border-radius: 12px; background: var(--text); color: var(--bg); font-size: 14px; text-align: center; opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .18s, transform .18s; }
#toast.show { opacity: .97; transform: none; }
.block { position: fixed; inset: 0; z-index: 20; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 32px; text-align: center; color: var(--hint); }
.skel { height: 74px; border-radius: 14px; background: var(--card); margin-bottom: 8px; opacity: .6; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
