:root {
  --bg: #f6f4ef;
  --surface: #fffdf9;
  --ink: #1f1d1a;
  --muted: #7d776d;
  --line: #dcd6cb;
  --accent: #a8402c;
  --accent-ink: #fff;
  --ok: #3d6b4a;
  --ok-bg: #e5efe7;
  --warn-bg: #f7ebe3;
  --del: #b23a2a;
  --add: #2f6a3f;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #181715;
    --surface: #211f1c;
    --ink: #ebe6dd;
    --muted: #9b9488;
    --line: #3a3631;
    --accent: #e07a62;
    --accent-ink: #1a1210;
    --ok: #8cc49a;
    --ok-bg: #22302530;
    --warn-bg: #3a262030;
    --del: #f08b78;
    --add: #8cc49a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; max-width: 1400px; margin: 0 auto;
}
h1 { font-size: 20px; margin: 0; font-weight: 600; letter-spacing: .04em; }
h2 { font-size: 16px; margin: 0; font-weight: 600; }

main {
  max-width: 1400px; margin: 0 auto; padding: 0 16px 40px;
  display: grid; gap: 12px;
}
@media (min-width: 900px) {
  main { grid-template-columns: 1fr 1fr; column-gap: 20px; }
  .actions, .status, .review { grid-column: 1 / -1; }
  main > .pane:nth-of-type(1) { grid-row: 1; grid-column: 1; }
  main > .pane:nth-of-type(2) { grid-row: 1; grid-column: 2; }
  .actions { grid-row: 2; }
  .status { grid-row: 3; }
  .review { grid-row: 4; }
}

.pane { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.pane-head { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.pane-head h2 { flex: none; }
.pane-head .meta { flex: 1; }
.meta { color: var(--muted); font-size: 14px; }

textarea {
  width: 100%;
  min-height: 42vh;
  resize: vertical;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  line-height: 1.8;
}
@media (min-width: 900px) { textarea { min-height: 60vh; } }
textarea:focus, input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

button {
  font: inherit; font-size: 16px;
  min-height: 44px; padding: 0 18px;
  border-radius: 10px; border: 1px solid transparent;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  color: var(--ink); background: none;
}
button:disabled { opacity: .45; cursor: default; }
.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.secondary { border-color: var(--line); background: var(--surface); }
.ghost { color: var(--accent); }
.ghost.icon { color: var(--ink); padding: 0 10px; }
.danger { color: var(--del); }

.actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.actions .primary { min-width: 160px; min-height: 50px; font-size: 17px; }
.progress { flex: 1; min-width: 200px; display: flex; align-items: center; gap: 12px; }
.track { flex: 1; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.fill { height: 100%; width: 0; background: var(--accent); transition: width .3s; }

.status { margin: 0; min-height: 1.6em; font-size: 15px; white-space: pre-line; }
.status.err { color: var(--del); }
.status.ok { color: var(--ok); }

.review { border-top: 1px solid var(--line); padding-top: 16px; display: grid; gap: 10px; }
.review-head { display: flex; align-items: baseline; gap: 12px; }
.hint { margin: 0; color: var(--muted); font-size: 15px; }
.hint b { color: var(--ink); font-weight: 600; }
.review-tools { display: flex; gap: 10px; flex-wrap: wrap; }

.issues, .hunks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.issues li {
  background: var(--warn-bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.issues .txt { flex: 1; min-width: 220px; font-size: 15px; }
.issues .txt b { color: var(--del); font-weight: 600; }

.hunks li {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 8px 8px 14px; display: flex; align-items: center; gap: 10px;
}
.hunks li.on { background: var(--ok-bg); border-color: var(--ok); }
.tag {
  flex: none; font-size: 12px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.tag.risk { color: var(--del); border-color: currentColor; }
.ctx { flex: 1; min-width: 0; font-size: 16px; line-height: 1.7; word-break: break-all; }
.ctx .c { color: var(--muted); }
.ctx del { color: var(--del); text-decoration: line-through; }
.ctx ins { color: var(--add); text-decoration: none; font-weight: 600; border-bottom: 2px solid currentColor; }
.ctx .empty { color: var(--muted); font-size: 13px; }
.hunks .locate { padding: 0 10px; color: var(--muted); }
.hunks .toggle { flex: none; min-width: 76px; }
.hunks li.on .toggle { border-color: var(--ok); color: var(--ok); }

dialog {
  border: none; padding: 0; border-radius: 16px; width: min(560px, calc(100vw - 32px));
  background: var(--surface); color: var(--ink); max-height: calc(100dvh - 40px);
}
dialog::backdrop { background: rgba(0, 0, 0, .35); }
.sheet { padding: 16px 20px 20px; display: grid; gap: 14px; }
.sheet-head, .sheet-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 14px; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; }
.row input { flex: 1; min-width: 0; }
input[type=text], input[type=password], input[type=url], select {
  font: inherit; font-size: 17px; min-height: 44px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); width: 100%;
}
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.warn { margin: -6px 0 0; font-size: 13px; color: var(--muted); line-height: 1.6; }
.adv summary { color: var(--muted); font-size: 14px; min-height: 32px; cursor: pointer; }
