:root {
  color-scheme: light;
  --bg: #f5f2ea;
  --panel: #fffdf8;
  --panel-soft: #f1f7f4;
  --ink: #25312f;
  --muted: #687875;
  --line: #d9e2dc;
  --accent: #3f8f7c;
  --accent-strong: #2f705f;
  --warm: #d9965b;
  --danger: #bf5f5a;
  --shadow: 0 18px 48px rgba(43, 65, 58, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(63, 143, 124, 0.12), transparent 38%),
    linear-gradient(315deg, rgba(217, 150, 91, 0.13), transparent 36%),
    var(--bg);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.app-shell.is-locked {
  filter: blur(2px);
  pointer-events: none;
  user-select: none;
}

.topbar,
.reminder-band,
.control-band,
.plan-band,
.workspace {
  background: rgba(255, 253, 248, 0.88);
  border: 1px solid rgba(217, 226, 220, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px;
  border-radius: 8px;
}

.reminder-band {
  margin-top: 18px;
  padding: 22px;
  border-radius: 8px;
}

.reminder-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border-radius: 8px;
  background: linear-gradient(135deg, #f1f7f4, #fff8ef);
}

.reminder-main h2 {
  margin-bottom: 6px;
  font-size: clamp(22px, 3vw, 30px);
}

.reminder-main p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

#reminderBadge {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  white-space: nowrap;
}

.reminder-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.reminder-grid article {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.reminder-grid article > span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.reminder-list {
  display: grid;
  gap: 8px;
}

.reminder-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--panel-soft);
}

.reminder-item strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.reminder-item small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.reminder-item em {
  color: var(--accent-strong);
  font-style: normal;
  font-weight: 700;
  white-space: nowrap;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 6px;
  font-size: 20px;
}

.top-actions,
.dialog-actions,
.ratio-control,
.card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  transition: transform 0.15s ease, background 0.15s ease, border 0.15s ease;
}

.primary-button {
  padding: 0 18px;
  color: #fff;
  background: var(--accent);
}

.secondary-button {
  padding: 0 16px;
  color: #fff;
  background: var(--warm);
}

.ghost-button {
  padding: 0 16px;
  color: var(--accent-strong);
  background: #fff;
  border-color: var(--line);
}

.icon-button {
  width: 42px;
  color: var(--accent-strong);
  background: #fff;
  border-color: var(--line);
  font-size: 20px;
  line-height: 1;
}

.icon-button.danger {
  color: var(--danger);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.file-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 18px 0;
}

.summary-tile {
  min-height: 108px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(43, 65, 58, 0.08);
}

.summary-tile span {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

.summary-tile strong {
  display: block;
  margin-top: 14px;
  font-size: clamp(22px, 3vw, 30px);
  letter-spacing: 0;
}

.control-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-radius: 8px;
}

.control-band p,
.section-head p,
.empty-state p {
  margin-bottom: 0;
  color: var(--muted);
}

.ratio-control input {
  width: 86px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.mini-control {
  min-width: 150px;
}

.mini-control > span {
  margin-bottom: 6px;
}

.control-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-inline span {
  color: var(--muted);
  white-space: nowrap;
}

.workspace {
  margin-top: 18px;
  padding: 22px;
  border-radius: 8px;
}

.plan-band {
  margin-top: 18px;
  padding: 22px;
  border-radius: 8px;
}

.plan-request {
  display: flex;
  align-items: end;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.plan-request .mini-control {
  min-width: 180px;
}

.plan-status {
  flex: 1 1 240px;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.plan-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.plan-summary article,
.plan-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.plan-summary article {
  min-height: 88px;
  padding: 14px;
}

.plan-summary span,
.plan-meta span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.plan-summary strong {
  display: block;
  margin-top: 10px;
  font-size: 22px;
}

.plan-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.plan-card {
  min-width: 0;
  padding: 16px;
}

.plan-card h3 {
  margin-bottom: 4px;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.plan-card p {
  margin-bottom: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.plan-card .strategy {
  color: var(--accent-strong);
  font-weight: 700;
}

.plan-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.plan-meta div {
  min-height: 68px;
  padding: 10px;
  border-radius: 8px;
  background: #f7faf7;
}

.plan-meta strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.allocation-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.allocation-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--panel-soft);
}

.allocation-row span {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-weight: 700;
}

.allocation-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 400;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.empty-state {
  display: none;
  padding: 42px 20px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.empty-state h3 {
  margin-bottom: 8px;
}

.empty-state button {
  margin-top: 18px;
}

.card-item {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.card-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.bank {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
}

.card-item h3 {
  margin-bottom: 0;
  font-size: 20px;
  overflow-wrap: anywhere;
}

.meter {
  height: 10px;
  margin: 18px 0 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eee9;
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--warm));
}

.card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat {
  min-height: 76px;
  padding: 12px;
  border-radius: 8px;
  background: #f7faf7;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stat strong {
  display: block;
  margin-top: 8px;
  overflow-wrap: anywhere;
}

.rules-box,
.assist-box {
  margin-top: 14px;
  padding: 14px;
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  line-height: 1.65;
}

.rules-box strong,
.assist-box strong {
  color: var(--ink);
}

.warning {
  color: var(--danger);
  font-weight: 700;
}

.card-dialog {
  width: min(760px, calc(100% - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.card-dialog::backdrop {
  background: rgba(37, 49, 47, 0.36);
  backdrop-filter: blur(6px);
}

.card-dialog form {
  padding: 22px;
}

.dialog-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

label span,
.mode-panel > span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

label input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.mode-panel {
  margin-top: 16px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.segmented label {
  min-width: 0;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  margin: 0;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 700;
}

.segmented input:checked + span {
  color: #fff;
  background: var(--accent);
}

.form-error {
  min-height: 22px;
  margin: 14px 0 0;
  color: var(--danger);
  font-weight: 700;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

.license-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(37, 49, 47, 0.42);
  backdrop-filter: blur(8px);
}

.license-overlay[hidden] {
  display: none;
}

.license-panel {
  width: min(560px, 100%);
  padding: 24px;
  border: 1px solid rgba(217, 226, 220, 0.95);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.license-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.license-head h2 {
  margin: 0;
  font-size: 28px;
}

.license-copy {
  margin: 12px 0 18px;
  color: var(--muted);
}

.license-form {
  display: grid;
  gap: 12px;
}

.license-form label {
  display: grid;
  gap: 7px;
}

.license-form input {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.license-status {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  line-height: 1.6;
}

.license-status strong {
  display: block;
  margin-bottom: 4px;
  color: var(--accent-strong);
}

@media (max-width: 860px) {
  .topbar,
  .reminder-main,
  .control-band,
  .plan-request,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .ratio-control {
    flex-wrap: wrap;
  }

  .summary-grid,
  .reminder-grid,
  .plan-summary,
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 14px;
  }

  .summary-grid,
  .reminder-grid,
  .plan-summary,
  .plan-list,
  .cards-grid,
  .card-stats,
  .plan-meta,
  .form-grid,
  .segmented {
    grid-template-columns: 1fr;
  }

  .reminder-item {
    grid-template-columns: 1fr;
  }

  .top-actions > *,
  .ratio-control .secondary-button {
    flex: 1 1 auto;
  }
}
