:root {
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #392c41;
  background: #faf6fa;
  font-synthesis: none;
  --subtle: #6e5b74;
  --line: #ebdfec;
  --accent: #6a4374;
  --paper: #fffdfd;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
a { color: var(--accent); text-underline-offset: .22em; }
button, input, select, textarea { font: inherit; color: inherit; }
button, input, select, textarea { border: 1px solid #d9c9dc; border-radius: 9px; }
button { min-height: 39px; padding: .52rem .8rem; background: #fff; font-size: .88rem; font-weight: 650; cursor: pointer; }
button:hover { border-color: var(--accent); background: #faf4fc; }
button:disabled, input:disabled { cursor: default; opacity: .6; }
input, select, textarea { min-width: 0; padding: .52rem .54rem; width: 100%; background: #fff; }
textarea { resize: vertical; }
:focus-visible { outline: 3px solid #a46cbc; outline-offset: 3px; }
.primary { background: var(--accent); border-color: var(--accent); color: white; }
.primary:hover { background: #54335d; color: white; }

.topbar { background: #fffafd; border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1420px; min-height: 61px; margin: auto; padding: 0 clamp(1rem, 3vw, 2.8rem); display: flex; align-items: center; justify-content: space-between; }
.topbar a { text-decoration: none; font-size: .9rem; }
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 760; }
main { max-width: 1420px; margin: auto; padding: clamp(1rem, 3vw, 2.8rem); }
.page-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem 1rem; margin-bottom: 1rem; }
h1 { margin: 0; font-size: clamp(1.6rem, 3.8vw, 2.7rem); letter-spacing: -.04em; }
.page-heading p { margin: .4rem 0 0; font-size: .92rem; color: var(--subtle); }
.page-heading .public-status { margin: 0; padding: .48rem .8rem; border-radius: 999px; background: #f1e7f4; color: #63416b; }
.public-status:empty { display: none; }
.status { margin: .35rem 0 1rem; color: var(--subtle); line-height: 1.45; }
.status:empty { margin: 0; }
.status[data-error="true"] { padding: .65rem .85rem; background: #fdeff0; color: #9f3750; border-radius: 10px; }
.workbench { display: grid; grid-template-columns: minmax(400px, .84fr) minmax(0, 1fr); align-items: start; gap: 1.15rem; }
.card { padding: clamp(.9rem, 2vw, 1.5rem); border: 1px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: 0 5px 20px #6a437407; }
.card-heading { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .85rem; }
h2 { margin: 0; font-size: 1.13rem; }
.preview { grid-column: 2; grid-row: 1; position: sticky; top: 1rem; }
.preview .card-heading span { color: var(--subtle); font-size: .8rem; }
.preview-frame { display: grid; place-items: center; width: 100%; aspect-ratio: 16/9; overflow: hidden; border-radius: 10px; border: 1px solid #eee3ed; background: #f9f0f7; }
.preview-frame p { font-size: .88rem; color: var(--subtle); padding: .8rem; text-align: center; }
.preview-frame canvas, .preview-frame img { display: block; width: 100%; height: 100%; object-fit: contain; }
.preview-actions { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .9rem; }
.alternate { margin-top: 1rem; }
summary { color: var(--accent); font-size: .86rem; font-weight: 650; cursor: pointer; }
.alternate p, .warning { font-size: .85rem; }
.warning, .review { color: #8a4c32; }
.file-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.file-row input { flex: 1 0 min(100%, 180px); }
.editor { grid-column: 1; grid-row: 1; }
label { display: grid; align-content: start; gap: .3rem; font-size: .81rem; font-weight: 600; }
label input, label textarea, label select { font-weight: 400; font-size: .89rem; }
.week-fields { display: grid; grid-template-columns: minmax(110px, .8fr) minmax(0, 1.2fr); gap: .65rem; }
.date-note { font-size: .82rem; color: var(--subtle); margin: .55rem 0 1rem; }
.paste { padding: .75rem; margin-bottom: .9rem; border: 1px solid var(--line); border-radius: 10px; background: #fdf8fc; }
.paste textarea { margin: .65rem 0 .45rem; }
.review ul { padding-left: 1.2rem; font-size: .83rem; line-height: 1.55; }
.day { display: grid; grid-template-columns: 106px minmax(0, 1fr); gap: .45rem .55rem; margin: 0 0 .7rem; padding: .65rem .7rem .7rem; border: 1px solid #efdfeb; border-radius: 12px; background: #fdf6fa; }
.day legend { padding: 0 .25rem; font-size: .85rem; font-weight: 730; color: #6f5275; }
.day[data-kind="special"] { border-color: #dbba80; background: #fff7e9; }
.day[data-kind="dd"] { border-color: #a0c2d5; background: #f0f7fb; }
.day[data-kind="rest"] { border-color: #d4c5df; background: #f5eff9; }
.day-activity { grid-column: 2 / -1; }
.day-type { grid-column: 1 / 2; }
.day-copy { grid-column: 2 / -1; }
.day-copy textarea { min-height: 37px; }
.notes { display: grid; gap: .65rem; margin-top: 1rem; }
.example { margin-top: .8rem; }
.history { margin-top: 1.15rem; }
.history p { margin: .6rem 0; color: var(--subtle); font-size: .88rem; }
.history ul { list-style: none; padding: 0; margin: 0; }
.history li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .55rem; padding: .7rem 0; border-top: 1px solid var(--line); }
.history small { display: block; margin-top: .2rem; color: var(--subtle); }
.history #more-history { margin-top: .7rem; }
dialog { width: min(92vw, 450px); border: 1px solid var(--line); border-radius: 16px; padding: 1.4rem; color: inherit; }
dialog::backdrop { background: #30213672; }
dialog p { line-height: 1.55; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; }

@media (max-height: 670px) { .preview { position: static; } }
@media (max-width: 860px) {
  .workbench { display: flex; flex-direction: column; }
  .workbench > * { width: 100%; }
  .preview { position: static; }
}
@media (max-width: 420px) {
  .week-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .preview-actions button { flex: 1 0 auto; }
  input, select, textarea, label input, label select, label textarea { font-size: 16px; }
}
