/* loop-approve: one stylesheet, mobile first, no third-party assets. Plan §3. */
:root {
  --bg: #f4f5f7; --card: #ffffff; --text: #1b1f24; --muted: #5d6670; --line: #d6dae0;
  --accent: #1f5fbf; --accent-text: #ffffff; --warn-bg: #fff4e5; --warn: #9a4a00;
  --bad: #b3261e; --bad-bg: #fde8e7; --good: #1d7a3a; --good-bg: #e6f4ea;
  --add: #e6f4ea; --del: #fde8e7; --hunk: #eef2fb; --badge: #b3261e;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418; --card: #1b2026; --text: #e8eaed; --muted: #9aa3ad; --line: #2e353d;
    --accent: #6ea3ff; --accent-text: #0b1220; --warn-bg: #3a2a12; --warn: #ffb460;
    --bad: #ff8a80; --bad-bg: #3b1716; --good: #7ee2a0; --good-bg: #133222;
    --add: #133222; --del: #3b1716; --hunk: #1d2840; --badge: #ff5a4e;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
h2 { font-size: 1.05rem; margin: 0 0 .5rem; }
button, input { font: inherit; color: inherit; }
button { min-height: 44px; padding: .5rem 1rem; border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.big { display: block; width: 100%; min-height: 48px; margin: .5rem 0; }
button.link { min-height: 44px; border: 0; background: none; color: var(--accent); padding: 0 .25rem; text-decoration: underline; }
input[type=text] { width: 100%; min-height: 48px; padding: .5rem .75rem; border: 1px solid var(--line); border-radius: 10px; background: var(--card); letter-spacing: .05em; }

.top { position: relative; display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .5rem 1rem; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { color: var(--text); text-decoration: none; font-weight: 700; }
.menu-btn { min-width: 44px; font-size: 1.3rem; }
.menu { position: absolute; right: .5rem; top: 100%; z-index: 5; display: flex; flex-direction: column; min-width: 12rem; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .25rem; }
.menu[hidden] { display: none; }
.menu a, .menu button { display: flex; align-items: center; min-height: 44px; padding: 0 .75rem; color: var(--text); text-decoration: none; border: 0; background: none; text-align: left; }

main { max-width: 1280px; margin: 0 auto; padding: .75rem; }
.card > :first-child { margin-top: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .9rem; margin: 0 0 .75rem; }
.msg { padding: .75rem; border-radius: 10px; background: var(--bad-bg); color: var(--bad); font-weight: 600; }
.msg.ok { background: var(--good-bg); color: var(--good); }
.muted { color: var(--muted); }
.small { font-size: .85rem; overflow-wrap: anywhere; }
.note { color: var(--muted); font-size: .9rem; }
.warn { color: var(--warn); }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: .35rem 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
ul.plain li:last-child { border-bottom: 0; }
#pending a { display: block; min-height: 44px; padding: .5rem 0; color: var(--accent); }

.chip { display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-weight: 700; font-size: .85rem; background: var(--warn-bg); color: var(--warn); }
.chip.good { background: var(--good-bg); color: var(--good); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.shas { display: grid; grid-template-columns: auto 1fr; gap: .25rem .75rem; margin: .75rem 0; }
.shas dt { color: var(--muted); }
.shas dd { margin: 0; }
.sha { font-size: 1.25rem; font-weight: 700; letter-spacing: .03em; }
.sha-full { display: block; font-size: .85rem; overflow-wrap: anywhere; }
.subject { font-weight: 600; margin: .25rem 0; overflow-wrap: anywhere; }
.flags { border-color: var(--warn); }
.flags ul { margin: 0; padding-left: 1.2rem; }
.flags li { margin: .3rem 0; overflow-wrap: anywhere; }
.flags .rule { font-weight: 700; }
.plain-summary { border-color: var(--warn); }
.plain-summary h2 { font-size: 1rem; margin: .6rem 0 .3rem; }
.plain-summary h2:first-child { margin-top: 0; }
.plain-summary ul { margin: 0; padding-left: 1.2rem; }
.plain-summary li { margin: .3rem 0; overflow-wrap: anywhere; }
#plain-claim li { color: var(--muted); font-style: italic; }
.compare { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.1rem; font-weight: 700; margin: .25rem 0 .5rem; }
.result.good { border-color: var(--good); }
.result.bad { border-color: var(--bad); }
summary { min-height: 44px; padding: .6rem 0; cursor: pointer; font-weight: 600; }
.wrap-toggle { display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; }
.diff { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem; overflow-x: auto; white-space: pre; border: 1px solid var(--line); border-radius: 8px; }
.diff.wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.diff div { padding: 0 .5rem; min-height: 1.2em; }
.diff .add { background: var(--add); }
.diff .del { background: var(--del); }
.diff .hunk { background: var(--hunk); color: var(--muted); }
.diff .head { font-weight: 700; }
.raw { font-size: .8rem; overflow-x: auto; white-space: pre; margin: 0; }
.hc { display: inline-block; padding: 0 .2em; margin: 0 .1em; border-radius: 4px; background: var(--badge); color: #fff; font-weight: 700; font-size: .85em; white-space: nowrap; }

/* Mobile: one column, in the order of plan §3 (summary, flags, plan, files, diff, then Approve). */
.layout { display: flex; flex-direction: column; }
.layout[hidden] { display: none; }
.summary, .detail { display: contents; }
.summary > .card:nth-child(1) { order: 1; }
.summary > .plain-summary { order: 2; }
.summary > .flags { order: 3; }
#plan-box { order: 3; }
.detail > * { order: 4; }
#approve-box { order: 8; }
#result { order: 9; }

/* Desktop: summary card on the left (sticky), files and diff on the right, expanded. */
@media (min-width: 901px) {
  .layout { display: grid; grid-template-columns: minmax(320px, 400px) minmax(0, 1fr); gap: 1rem; align-items: start; }
  .summary, .detail { display: block; }
  .summary { position: sticky; top: .75rem; max-height: calc(100vh - 1.5rem); overflow-y: auto; }
}
