:root {
  color-scheme: light;
  --ink: #18212b;
  --muted: #66717d;
  --line: #d8dde3;
  --surface: #ffffff;
  --soft: #f4f6f8;
  --accent: #176b4d;
  --accent-hover: #0f553c;
  --warning: #8a5a00;
  --error: #b42318;
  font-family: "Microsoft YaHei UI", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--soft); font-size: 14px; }
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button, .button-link {
  min-height: 36px; border: 1px solid #b9c1c9; border-radius: 5px; background: #fff; color: var(--ink);
  padding: 7px 13px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
button:hover, .button-link:hover { border-color: #7d8995; background: #f7f8f9; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-hover); }
.full { width: 100%; }
.small { min-height: 30px; padding: 4px 10px; }
.text-button { border: 0; background: transparent; min-height: auto; padding: 0; color: inherit; }
a { color: #155f9a; }
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }

.app-header {
  min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 10px 24px; background: #fff; border-bottom: 1px solid var(--line);
}
.app-header > div { display: flex; align-items: baseline; gap: 14px; }
.app-header span, .section-title span { color: var(--muted); }
.app-header nav { display: flex; align-items: center; gap: 18px; }
.app-header nav a, .app-header nav button { color: #33414e; text-decoration: none; }
.app-header nav form { margin: 0; }

.workspace { display: grid; grid-template-columns: minmax(330px, 410px) minmax(580px, 1fr); min-height: calc(100vh - 62px); }
.input-pane, .result-pane { padding: 22px 24px 30px; }
.input-pane { background: #fff; border-right: 1px solid var(--line); }
.result-pane { min-width: 0; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.stack { display: grid; gap: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
label { display: grid; gap: 6px; color: #354250; font-weight: 600; }
input, textarea, select {
  width: 100%; border: 1px solid #bfc7cf; border-radius: 4px; background: #fff; color: var(--ink); padding: 9px 10px;
}
textarea { resize: vertical; min-height: 170px; line-height: 1.55; }
input:focus, textarea:focus, select:focus { outline: 2px solid #b8d8cc; border-color: var(--accent); }
input[type="file"] { padding: 7px; font-weight: 400; }
input[type="color"] { height: 38px; padding: 3px; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid #bfc7cf; border-radius: 5px; overflow: hidden; }
.segmented label { display: block; position: relative; font-weight: 500; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; text-align: center; padding: 9px; background: #fff; }
.segmented label + label span { border-left: 1px solid #bfc7cf; }
.segmented input:checked + span { background: #e7f1ed; color: #0f553c; font-weight: 700; }

.message { min-height: 20px; margin: 10px 0 0; color: var(--muted); line-height: 1.45; }
.message.success { color: #267a3e; }
.message.warning { color: var(--warning); }
.message.error { color: var(--error); }
.muted { color: var(--muted); }

.history-section { border-top: 1px solid var(--line); margin-top: 24px; padding-top: 20px; }
.table-scroll { overflow: auto; border: 1px solid var(--line); background: #fff; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { border-bottom: 1px solid #e3e7eb; padding: 9px 10px; text-align: center; height: 40px; }
th { position: sticky; top: 0; background: #eef1f3; z-index: 1; font-weight: 700; color: #33414e; }
tbody tr:hover { background: #f7f9fa; }
tfoot td { font-weight: 700; background: #f3f5f6; }
.empty-row td { color: var(--muted); padding: 30px; }
.compact { max-height: 300px; }
.compact th, .compact td { height: 35px; padding: 6px 8px; }
.result-table-wrap { max-height: 630px; }
.editable { cursor: text; background: #fbfcfc; font-variant-numeric: tabular-nums; }
.editable:hover { box-shadow: inset 0 0 0 1px #7bad99; }
.cell-editor { min-width: 88px; padding: 5px 7px; text-align: right; }
.result-actions > div { display: flex; align-items: baseline; gap: 12px; }
.result-actions #export-actions { gap: 8px; }

.style-panel { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.style-panel summary { cursor: pointer; font-weight: 700; font-size: 15px; }
.style-panel form { margin-top: 14px; }
.style-grid { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 12px; margin-bottom: 12px; }
.style-grid .wide { grid-column: span 2; }
.style-grid .check { align-content: end; grid-template-columns: auto 1fr; align-items: center; justify-content: start; }
.style-grid .check input { width: 18px; height: 18px; }
#png-preview { display: block; max-width: 100%; margin: 18px auto 0; border: 1px solid var(--line); background: #fff; }

.admin-workspace { padding: 24px; display: grid; gap: 26px; }
.admin-workspace section { min-width: 0; }

.auth-page { min-height: 100vh; display: grid; place-items: center; background: #edf1f3; }
.auth-panel { width: min(390px, calc(100vw - 32px)); padding: 28px; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.auth-panel h1 { margin-bottom: 22px; }

[hidden] { display: none !important; }

@media (max-width: 940px) {
  .workspace { grid-template-columns: 1fr; }
  .input-pane { border-right: 0; border-bottom: 1px solid var(--line); }
  .style-grid { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
}

@media (max-width: 600px) {
  body { font-size: 13px; }
  .app-header { align-items: flex-start; padding: 12px 14px; }
  .app-header > div { display: block; }
  .app-header > div span { display: none; }
  .app-header nav { gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
  .input-pane, .result-pane, .admin-workspace { padding: 16px 12px 24px; }
  .field-row { grid-template-columns: 1fr; }
  .style-grid { grid-template-columns: 1fr 1fr; }
  .style-grid .wide { grid-column: 1 / -1; }
  th, td { padding: 8px; height: 38px; }
  .result-table-wrap { max-height: 70vh; }
}
