:root {
  --ink: #2f3f46;
  --muted: #6e7f83;
  --page-start: #f6f8f6;
  --page-mid: #edf3f1;
  --page-end: #f1eee9;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-wash: rgba(226, 236, 233, 0.68);
  --input: rgba(251, 253, 252, 0.96);
  --line: #d7e1de;
  --accent: #526f79;
  --accent-soft: #8fa6ad;
  --sage: #9fb4aa;
  --rose: #ba7d80;
  --warning: #b18d55;
  --shadow: 0 20px 60px rgba(64, 87, 93, 0.13);
  --radius: 8px;
}

body[data-theme="blue"] {
  --ink: #2d3d48;
  --muted: #6c7d88;
  --page-start: #f5f7fa;
  --page-mid: #e8eef5;
  --page-end: #f0ece5;
  --panel-wash: rgba(229, 235, 239, 0.7);
  --line: #d5dde3;
  --accent: #4f687b;
  --accent-soft: #8fa0b4;
  --sage: #91a9b0;
}

body[data-theme="sage"] {
  --ink: #31433c;
  --muted: #70837b;
  --page-start: #f6f8f1;
  --page-mid: #e9efe6;
  --page-end: #f1eee2;
  --panel-wash: rgba(232, 238, 229, 0.72);
  --line: #d8e2d9;
  --accent: #5a7466;
  --accent-soft: #9daf9f;
  --sage: #94ae9a;
}

body[data-theme="rose"] {
  --ink: #4a3b3f;
  --muted: #876f75;
  --page-start: #fbf6f6;
  --page-mid: #f0e4e5;
  --page-end: #efe8df;
  --panel-wash: rgba(240, 228, 229, 0.72);
  --line: #ead7da;
  --accent: #815f66;
  --accent-soft: #d4929d;
  --sage: #c59ba0;
}

body[data-theme="milk"] {
  --ink: #493f38;
  --muted: #837467;
  --page-start: #faf7f1;
  --page-mid: #f1e9de;
  --page-end: #eadcc9;
  --panel-wash: rgba(241, 233, 222, 0.74);
  --line: #e3d6c7;
  --accent: #7c6959;
  --accent-soft: #ccb09a;
  --sage: #bfa98f;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 13% 8%, rgba(143, 166, 173, 0.24), transparent 28%),
    radial-gradient(circle at 92% 3%, rgba(196, 169, 156, 0.20), transparent 29%),
    linear-gradient(135deg, var(--page-start), var(--page-mid) 48%, var(--page-end));
  background-attachment: fixed;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
summary {
  cursor: pointer;
}

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

h1 {
  margin-bottom: 8px;
  font-family: "Songti SC", "STSong", Georgia, serif;
  font-size: clamp(2.2rem, 4.8vw, 4.3rem);
  line-height: 1.05;
}

h2 {
  margin-bottom: 14px;
  font-size: 1.2rem;
}

h3 {
  margin-bottom: 12px;
  color: var(--accent);
  font-size: 1rem;
}

.page-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 46px;
}

.topbar,
.section-heading,
.records-heading,
.records-tools,
.top-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar {
  align-items: end;
  margin-bottom: 18px;
}

.lead {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.7;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.panel,
.privacy-strip {
  border: 1px solid rgba(82, 111, 121, 0.16);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.privacy-strip {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
  padding: 12px 16px;
  color: var(--accent);
  background: linear-gradient(90deg, var(--panel-wash), rgba(255, 255, 255, 0.78));
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 370px;
  gap: 18px;
  align-items: start;
}

.entry-panel,
.records-panel {
  padding: 22px;
}

.side-column {
  display: grid;
  gap: 18px;
  position: sticky;
  top: 18px;
}

.side-column .panel {
  padding: 18px;
}

.status-pill,
.quota-badge {
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-wash);
  color: var(--accent);
  font-weight: 900;
  white-space: nowrap;
}

.status-pill.active {
  background: var(--sage);
  color: #fff;
}

.quota-badge.warn {
  color: var(--warning);
}

.theme-picker {
  position: relative;
}

.theme-picker summary {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  color: var(--accent);
  font-weight: 900;
  list-style: none;
}

.theme-picker summary::-webkit-details-marker {
  display: none;
}

.theme-panel {
  position: absolute;
  z-index: 30;
  right: 0;
  top: calc(100% + 10px);
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.theme-card {
  display: grid;
  gap: 7px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--input);
  color: var(--ink);
  font-weight: 800;
  text-align: left;
}

.theme-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--panel-wash);
}

.swatches {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  min-height: 32px;
  overflow: hidden;
  border-radius: 6px;
}

.swatches i {
  display: block;
}

.form-section {
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.form-section:first-of-type {
  border-top: 0;
  padding-top: 0;
}

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

.wide {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--input);
  color: var(--ink);
  outline: none;
}

input,
select {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 98px;
  padding: 12px;
  line-height: 1.7;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(82, 111, 121, 0.14);
}

.draft-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent-soft);
  border-radius: var(--radius);
  background: var(--panel-wash);
  color: var(--accent);
  font-weight: 900;
}

.form-actions,
.filter-actions,
.activation-form,
.backup-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.draft-status {
  margin: 0 auto 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.primary-button,
.secondary-button,
.ghost-button,
.text-button,
.delete-button,
.import-button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 9px 15px;
  font-weight: 900;
  text-decoration: none;
}

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

.secondary-button {
  background: var(--sage);
  color: #fff;
}

.ghost-button,
.text-button,
.import-button {
  background: var(--panel-wash);
  color: var(--accent);
  border-color: rgba(82, 111, 121, 0.16);
}

.text-button {
  min-height: 30px;
  padding: 5px 9px;
}

.delete-button {
  min-height: 34px;
  background: #fff7f6;
  color: var(--rose);
  border-color: rgba(186, 125, 128, 0.3);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.activation-form {
  justify-content: stretch;
}

.activation-form input {
  flex: 1 1 220px;
}

.license-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-wash);
  line-height: 1.65;
}

.license-card strong {
  color: var(--accent);
}

.hint,
.muted {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.7;
}

.filter-stack {
  display: grid;
  gap: 13px;
}

.weekly-summary {
  line-height: 1.75;
}

.summary-line {
  display: block;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

.backup-actions {
  justify-content: stretch;
}

.import-button {
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}

.import-button input {
  display: none;
}

.records-panel {
  margin-top: 18px;
}

.records-tools {
  flex-wrap: wrap;
}

.select-all-control {
  display: flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.select-all-control input {
  width: auto;
  min-height: auto;
}

.records-list {
  display: grid;
  gap: 14px;
}

.record-card {
  border: 1px solid var(--line);
  border-left: 6px solid var(--accent-soft);
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--panel-wash), var(--panel));
}

.record-main {
  padding: 16px;
}

.record-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.record-title-wrap {
  min-width: 0;
}

.record-week,
.subtitle {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.record-card h3 {
  margin: 0;
  color: var(--ink);
  font-size: 1.08rem;
}

.record-select-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 82px;
  color: var(--accent);
}

.record-select-wrap input {
  width: auto;
  min-height: auto;
}

.record-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 14px;
}

.record-meta div {
  display: flex;
  gap: 6px;
  align-items: center;
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.62);
}

.record-meta dt {
  color: var(--accent);
  font-weight: 900;
}

.record-meta dd {
  margin: 0;
  color: var(--ink);
}

.note-block,
.detail-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.56);
}

.note-block {
  padding: 12px;
  margin-bottom: 10px;
}

.note-block strong,
.detail-block summary {
  color: var(--accent);
  font-weight: 900;
}

.note-block p,
.detail-block p {
  margin: 6px 0 0;
  line-height: 1.68;
  white-space: pre-wrap;
  word-break: break-word;
}

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

.detail-block {
  overflow: hidden;
}

.detail-block summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 10px 12px;
  list-style: none;
}

.detail-block summary::-webkit-details-marker {
  display: none;
}

.detail-block p {
  padding: 0 12px 12px;
}

.toggle-text {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.empty-state {
  display: none;
  padding: 36px 18px;
  border: 1px dashed var(--accent-soft);
  border-radius: var(--radius);
  background: var(--panel-wash);
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
}

.empty-state.show {
  display: block;
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .side-column {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .page-shell {
    width: min(100% - 22px, 760px);
  }

  .topbar,
  .privacy-strip,
  .section-heading,
  .records-heading,
  .record-header {
    align-items: stretch;
    flex-direction: column;
  }

  .side-column,
  .form-grid,
  .record-details {
    grid-template-columns: 1fr;
  }

  .entry-panel,
  .records-panel,
  .side-column .panel {
    padding: 16px;
  }

  .theme-panel {
    left: 0;
    right: auto;
    grid-template-columns: 1fr;
  }

  .draft-status {
    margin-right: 0;
    width: 100%;
  }

  .primary-button,
  .secondary-button,
  .ghost-button,
  .import-button {
    width: 100%;
    text-align: center;
  }
}
