:root {
  color-scheme: light;
  --paper: #f4f1e9;
  --panel: #fffdf8;
  --ink: #20251f;
  --muted: #687168;
  --line: #d8d8ce;
  --green: #315b4a;
  --green-dark: #234437;
  --gold: #a8702a;
  --danger: #a33b32;
  --shadow: 0 12px 32px rgba(32, 37, 31, .08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); min-height: 100vh; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.topbar {
  padding: max(22px, env(safe-area-inset-top)) 20px 22px;
  color: white;
  background: linear-gradient(135deg, #234437, #416d58);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.topbar h1 { margin: 4px 0 6px; font-family: Georgia, "Songti SC", serif; font-size: clamp(28px, 8vw, 42px); }
.subtitle { margin: 0; opacity: .86; line-height: 1.5; }
.eyebrow { margin: 0; font-size: 11px; letter-spacing: .16em; font-weight: 800; color: var(--gold); }
.topbar .eyebrow { color: #ead2a9; }
.badge { white-space: nowrap; border: 1px solid rgba(255,255,255,.4); border-radius: 999px; padding: 7px 10px; font-size: 12px; }

main { width: min(760px, 100%); margin: 0 auto; padding: 16px 14px calc(30px + env(safe-area-inset-bottom)); }
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin: 2px 0 16px; }
.tab { border: 1px solid var(--line); background: rgba(255,255,255,.65); border-radius: 12px; padding: 11px 5px; color: var(--muted); }
.tab.active { background: var(--green); border-color: var(--green); color: white; font-weight: 700; }

.view, .device-panel { display: none; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 18px; }
.view.active { display: block; }
.device-panel { display: block; margin-top: 16px; box-shadow: none; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
h2 { margin: 4px 0 0; font-size: 21px; }

.field { margin-bottom: 15px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
label, legend { display: block; margin-bottom: 7px; font-size: 14px; font-weight: 700; }
label strong { color: var(--danger); }
input:not([type="checkbox"]):not([type="file"]), textarea {
  width: 100%; border: 1px solid #c9cbc1; border-radius: 11px; background: white; color: var(--ink); padding: 12px 13px; outline: none;
}
textarea { resize: vertical; line-height: 1.55; }
input:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(49,91,74,.13); }
.counter { display: block; margin-top: 4px; text-align: right; color: var(--muted); font-size: 12px; }
.helper { color: var(--muted); font-size: 13px; line-height: 1.55; }

.cover-field { margin: 18px 0; border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
#coverInput { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.file-button { display: inline-block; margin: 0; border: 1px solid var(--green); color: var(--green); border-radius: 10px; padding: 10px 13px; }
.cover-preview { display: flex; gap: 14px; align-items: center; margin-top: 14px; }
.cover-preview img { width: 92px; height: 126px; object-fit: cover; background: #eee; border-radius: 8px; }

.actions { display: flex; gap: 10px; }
.actions button { flex: 1; }
.sticky-actions { position: sticky; bottom: max(8px, env(safe-area-inset-bottom)); background: rgba(255,253,248,.94); padding: 10px 0 0; backdrop-filter: blur(10px); }
button.primary, button.secondary { border-radius: 11px; padding: 11px 14px; font-weight: 700; }
button.primary { border: 1px solid var(--green); background: var(--green); color: white; }
button.primary:hover { background: var(--green-dark); }
button.secondary { border: 1px solid var(--line); background: white; color: var(--ink); }
button:disabled { opacity: .45; cursor: default; }
.link { border: 0; background: none; padding: 4px 0; text-decoration: underline; }
.danger-text { color: var(--danger); }

.notice { border-radius: 12px; padding: 12px 13px; margin-bottom: 13px; line-height: 1.5; font-size: 14px; }
.notice.warning { background: #fff3cd; border: 1px solid #e5c56f; }
.notice.danger { background: #fde8e5; border: 1px solid #dc9a93; color: #74231c; }
.notice.info { background: #e9f2ed; border: 1px solid #a9c2b4; }

.card-list { display: grid; gap: 10px; }
.card { border: 1px solid var(--line); background: white; border-radius: 13px; padding: 13px; }
.card-row { display: flex; gap: 12px; align-items: flex-start; }
.card-main { min-width: 0; flex: 1; }
.card h3 { margin: 0 0 5px; font-size: 17px; overflow-wrap: anywhere; }
.card p { margin: 4px 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.card-actions button { border: 1px solid var(--line); background: #fafaf7; border-radius: 8px; padding: 7px 9px; font-size: 13px; }
.state-pill { display: inline-block; border-radius: 999px; padding: 4px 8px; background: #eef2ed; color: var(--green); font-size: 12px; font-weight: 700; }
.operation-check { width: 20px; height: 20px; accent-color: var(--green); }
.selection-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); padding: 10px 0 13px; margin-bottom: 12px; }
.selection-bar label { margin: 0; }
.empty { text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 13px; padding: 28px 14px; }
.empty p { margin-bottom: 0; }

.device-panel dl { margin: 12px 0; }
.device-panel dl div { display: grid; grid-template-columns: 100px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid #ecece5; }
.device-panel dt { color: var(--muted); }
.device-panel dd { margin: 0; overflow-wrap: anywhere; }
details { margin-top: 14px; color: var(--muted); line-height: 1.55; }
summary { color: var(--ink); font-weight: 700; cursor: pointer; }

@media (max-width: 560px) {
  .field-grid { grid-template-columns: 1fr; }
  .tabs { gap: 4px; }
  .tab { font-size: 13px; padding-inline: 2px; }
  .topbar { display: block; }
  .topbar .badge { display: inline-block; margin-top: 12px; }
}
