:root {
  color-scheme: light;
  --page: #eef2ee;
  --page-2: #faf7ef;
  --surface: #fffdf8;
  --surface-muted: #f5f3ec;
  --ink: #13201c;
  --muted: #68736e;
  --line: #d8ddd4;
  --line-soft: #e8ebe4;
  --teal: #0d7f69;
  --teal-deep: #075f50;
  --teal-soft: #e5f3ed;
  --gold: #c78b2c;
  --gold-soft: #fff4dc;
  --red: #ad3b2e;
  --red-soft: #fff0ed;
  --blue: #385a73;
  --shadow: 0 24px 80px rgba(31, 43, 37, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(135deg, rgba(13, 127, 105, 0.08), transparent 38%),
    linear-gradient(180deg, var(--page-2), var(--page));
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  background-image:
    linear-gradient(rgba(19, 32, 28, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(19, 32, 28, 0.025) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), transparent 78%);
}

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

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf0;
  color: var(--ink);
  cursor: pointer;
  padding: 0 15px;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

button:hover {
  border-color: rgba(13, 127, 105, 0.55);
  box-shadow: 0 8px 22px rgba(13, 127, 105, 0.12);
  transform: translateY(-1px);
}

button.primary {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
  font-weight: 800;
}

button.primary:hover {
  background: var(--teal-deep);
}

input,
textarea,
select {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
  color: var(--ink);
}

input,
select {
  height: 40px;
  padding: 0 11px;
}

textarea {
  width: 100%;
  min-height: 294px;
  resize: vertical;
  padding: 16px;
  line-height: 1.68;
}

textarea:focus,
input:focus,
select:focus {
  outline: 3px solid rgba(13, 127, 105, 0.16);
  border-color: var(--teal);
}

.app-shell {
  width: min(1500px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 30px 0 44px;
}

.app-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: end;
  margin-bottom: 22px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  color: var(--teal-deep);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
}

.eyebrow::before {
  width: 22px;
  height: 8px;
  border-radius: 999px;
  background: var(--gold);
  content: "";
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(34px, 4vw, 54px);
  line-height: 1.02;
}

h2 {
  font-size: 18px;
}

.week-panel {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 9px 12px;
  min-width: 260px;
  padding: 14px;
  border: 1px solid rgba(13, 127, 105, 0.2);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.week-panel strong {
  grid-column: 1 / -1;
  font-size: 15px;
}

.week-panel label,
.date-row label,
.copy-grid label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(390px, 0.76fr) minmax(660px, 1.24fr);
  gap: 18px;
  align-items: start;
}

.input-panel,
.result-panel {
  min-width: 0;
  border: 1px solid rgba(216, 221, 212, 0.9);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: var(--shadow);
  padding: 18px;
}

.input-panel {
  position: sticky;
  top: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  min-width: 186px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.segmented button {
  min-height: 32px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0 10px;
  font-weight: 800;
}

.segmented button.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 10px rgba(24, 34, 31, 0.12);
}

.source-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.source-tabs button {
  min-height: 44px;
  background: rgba(245, 243, 236, 0.76);
  color: var(--muted);
  font-weight: 900;
}

.source-tabs button.is-active {
  border-color: rgba(13, 127, 105, 0.55);
  background: var(--teal-soft);
  color: var(--teal-deep);
}

.date-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.image-input-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.image-input-panel.is-hidden {
  display: none;
}

.upload-card {
  display: grid;
  gap: 6px;
  min-height: 112px;
  place-items: center;
  border: 1.5px dashed rgba(13, 127, 105, 0.38);
  border-radius: 8px;
  background: rgba(229, 243, 237, 0.5);
  color: var(--teal-deep);
  cursor: pointer;
  padding: 18px;
  text-align: center;
}

.upload-card input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-title {
  font-size: 17px;
  font-weight: 950;
}

.upload-note,
.image-status {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.screenshot-preview {
  display: grid;
  min-height: 132px;
  max-height: 340px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
}

.screenshot-preview img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 340px;
  object-fit: contain;
}

.screenshot-preview.is-empty {
  color: var(--muted);
  font-size: 13px;
}

.image-status {
  margin: 0;
}

.image-status.is-ready {
  color: var(--teal-deep);
  font-weight: 800;
}

.image-status.has-warnings {
  color: #8d5d13;
  font-weight: 800;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.week-memory {
  margin-top: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(245, 243, 236, 0.7);
  padding: 12px;
}

.week-memory-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 13px;
}

.week-memory-head span {
  color: var(--muted);
  font-weight: 800;
}

.memory-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.memory-chip,
.memory-empty {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 800;
}

.memory-chip {
  background: var(--teal-soft);
  color: var(--teal-deep);
}

.memory-empty {
  background: #fffefa;
  color: var(--muted);
}

.config-box {
  margin-top: 16px;
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
}

.config-box summary {
  color: var(--teal-deep);
  cursor: pointer;
  font-weight: 900;
}

.config-box textarea {
  min-height: 220px;
  margin-top: 12px;
  font-size: 13px;
}

.status-pill {
  border-radius: 999px;
  background: #eef1ed;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  padding: 7px 12px;
}

.status-pill.has-warnings {
  background: var(--gold-soft);
  color: #8d5d13;
}

.status-pill.is-ready {
  background: var(--teal-soft);
  color: var(--teal-deep);
}

.review-panel {
  margin-bottom: 14px;
  border: 1px solid #efb6aa;
  border-radius: 8px;
  background: var(--red-soft);
  padding: 12px;
}

.review-panel.is-empty {
  display: none;
}

.review-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

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

.review-item {
  display: grid;
  grid-template-columns: 1fr 150px 150px;
  gap: 8px;
  align-items: center;
}

.review-item p {
  margin: 0;
  color: #641f16;
  font-size: 13px;
  line-height: 1.5;
}

.review-item select {
  border-color: #efb6aa;
  background: #fff;
}

.manual-panel {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 254, 250, 0.86);
  padding: 12px;
}

.manual-panel.is-empty {
  display: none;
}

.manual-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.manual-head div {
  display: grid;
  gap: 2px;
}

.manual-head span {
  color: var(--muted);
  font-size: 13px;
}

.manual-grid {
  overflow: auto;
}

.manual-grid table {
  width: 100%;
  min-width: 700px;
  border-collapse: collapse;
  table-layout: fixed;
}

.manual-grid th,
.manual-grid td {
  height: 36px;
  border: 1px solid var(--line-soft);
  text-align: center;
}

.manual-grid th {
  background: #eef5ef;
  color: #25342f;
  font-size: 13px;
  font-weight: 900;
}

.manual-grid tbody th {
  width: 90px;
  background: #fffefa;
}

.manual-cell {
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--teal-deep);
  font-size: 20px;
  font-weight: 950;
  padding: 0;
}

.manual-cell:hover {
  background: rgba(13, 127, 105, 0.08);
  box-shadow: none;
  transform: none;
}

.manual-cell.is-on {
  background: var(--teal-soft);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
}

#resultTable {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  table-layout: fixed;
  background: #fffefa;
}

#resultTable caption {
  padding: 16px 12px 8px;
  color: var(--ink);
  font-size: 24px;
  font-weight: 950;
}

#resultTable .date-caption {
  display: block;
  margin-top: 5px;
  color: var(--teal-deep);
  font-size: 16px;
  font-weight: 850;
}

#resultTable th,
#resultTable td {
  height: 40px;
  border: 1px solid var(--line-soft);
  text-align: center;
  vertical-align: middle;
}

#resultTable th {
  background: #eef5ef;
  color: #25342f;
  font-weight: 900;
}

#resultTable tbody tr:nth-child(even) td {
  background: #fbfaf5;
}

#resultTable td.check {
  background: var(--teal-soft);
  color: var(--teal-deep);
  font-size: 22px;
  font-weight: 950;
}

#resultCanvas {
  display: block;
  width: 100%;
  max-height: 540px;
  margin: 14px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

.export-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
}

.copy-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.copy-grid label {
  display: grid;
  gap: 6px;
}

.copy-grid textarea {
  min-height: 148px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

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

  .input-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100vw - 20px, 720px);
    padding-top: 18px;
  }

  .app-header,
  .panel-head,
  .date-row {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .week-panel,
  .source-tabs,
  .export-grid,
  .copy-grid,
  .review-item {
    grid-template-columns: 1fr;
  }

  button,
  input,
  select {
    min-height: 44px;
  }

  .upload-card {
    min-height: 136px;
  }

  .manual-head {
    align-items: stretch;
    flex-direction: column;
  }

  .manual-grid table {
    min-width: 620px;
  }

  textarea {
    min-height: 220px;
  }
}
