:root {
  color-scheme: light;
  --ink: #172e27;
  --muted: #536b61;
  --line: #dae6df;
  --green: #17694e;
  --green-dark: #114e3a;
  --mint: #e9f5ee;
  --white: #fff;
  font: 16px/1.5 "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: linear-gradient(155deg, #ecf6ef 0, #f6faf7 320px, #f8faf8 650px); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--green-dark); text-underline-offset: .2em; }
button { color: inherit; }
button:disabled { opacity: .46; cursor: default; }
button:not(:disabled) { cursor: pointer; }
:focus-visible { outline: 2px solid #298761; outline-offset: 3px; }
[hidden] { display: none !important; }
.shell { width: min(1416px, calc(100% - 72px)); margin-inline: auto; }
.site-header { border-bottom: 1px solid var(--line); background: #ffffffd9; }
.topbar { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; color: var(--ink); font-size: 1.08rem; font-weight: 780; line-height: 1.1; white-space: nowrap; }
.brand small { display: block; margin-top: 5px; color: var(--muted); font-size: .68rem; letter-spacing: .13em; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--green); color: white; }
.brand-mark svg { width: 24px; height: 24px; }
nav { display: flex; align-items: center; gap: 20px; }
.guide-link { font-size: .875rem; font-weight: 650; text-decoration: none; }
.guide-link:hover { text-decoration: underline; }
.button, .icon-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 8px 13px;
  border: 1px solid var(--line); border-radius: 9px; background: white; font-size: .875rem; font-weight: 700; line-height: 1.2;
}
.button:hover:not(:disabled), .icon-button:hover:not(:disabled) { background: var(--mint); border-color: #a6c7b6; }
.button.primary { color: white; background: var(--green); border-color: var(--green); }
.button.primary:hover:not(:disabled) { background: var(--green-dark); }
.icon-button { width: 40px; padding: 0; flex: 0 0 40px; }
.icon-button.danger:hover:not(:disabled) { color: #a02d32; background: #fff0f0; border-color: #edc7c8; }
[data-icon] { display: inline-flex; align-items: center; justify-content: center; }
[data-icon].icon-button { display: inline-flex; }
svg { width: 17px; height: 17px; flex: none; vertical-align: middle; }
.intro { padding: 33px 0 24px; display: flex; align-items: end; justify-content: space-between; gap: 12px 22px; }
.intro h1 { margin: 0; font-size: clamp(1.85rem, 3.15vw, 2.8rem); line-height: 1.2; letter-spacing: -.045em; }
.intro p { margin: 9px 0 0; color: var(--muted); }
.intro .save-status { display: inline-flex; align-items: center; gap: 7px; background: #f7fcf8; border: 1px solid #d7e8dc; border-radius: 99px; padding: 7px 11px; font-size: .8125rem; flex-shrink: 0; }
.studio { display: grid; grid-template-columns: minmax(166px, 202px) minmax(0, 1fr) minmax(270px, 310px); gap: 14px; align-items: start; }
.panel { min-width: 0; border: 1px solid var(--line); background: var(--white); border-radius: 16px; box-shadow: 0 6px 22px #1b433a08; }
.panel-heading { min-height: 56px; padding: 14px 15px; display: flex; justify-content: space-between; align-items: center; gap: 10px; border-bottom: 1px solid #e9efeb; }
.panel h2 { margin: 0; font-size: 1rem; line-height: 1.25; }
.count { color: var(--green); background: var(--mint); border-radius: 99px; padding: 1px 8px; font-size: .8125rem; white-space: nowrap; }
.page-list { padding: 11px 11px 4px; max-height: 430px; overflow: auto; }
.page-item { width: 100%; display: grid; grid-template-columns: 52px minmax(0, 1fr); align-items: center; gap: 9px; text-align: left; border: 1px solid transparent; border-radius: 9px; padding: 6px; min-height: 56px; background: #fff; }
.page-item + .page-item { margin-top: 4px; }
.page-item:hover { background: #f4f9f6; }
.page-item[aria-current="page"] { background: #ecf7f0; border-color: #a9d1ba; }
.page-item canvas { display: block; width: 52px; height: 37px; border-radius: 4px; border: 1px solid #d3e2d8; object-fit: contain; background: #e1ebe5; }
.page-item strong, .page-item small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.page-item strong { font-size: .8125rem; }
.page-item small { font-size: .75rem; color: var(--muted); }
.add-page { width: calc(100% - 24px); margin: 9px 12px 12px; background: #f8fcf9; border-style: dashed; color: var(--green-dark); }
.page-actions { padding: 9px 8px; border-top: 1px solid #e9efeb; display: flex; justify-content: space-evenly; gap: 3px; }
.page-actions .icon-button { width: 31px; min-height: 35px; flex-basis: 31px; border-color: transparent; }
.preview-heading { min-height: 65px; padding-inline: 17px; }
.preview-heading p { margin: 3px 0 0; color: var(--muted); font-size: .8125rem; }
.preview-navigation { display: flex; gap: 5px; }
.preview-navigation .icon-button { width: 34px; flex-basis: 34px; min-height: 34px; }
.stage {
  display: grid; min-height: 490px; padding: 30px; place-items: center;
  background-color: #edf3ef; background-image: radial-gradient(#b7cabe 1px, transparent 1px); background-size: 15px 15px;
  transition: box-shadow .16s;
}
.stage.dragging { box-shadow: inset 0 0 0 3px #398967; }
.paper { width: min(100%, 740px); }
.paper canvas { display: block; width: 100%; height: auto; background: #fff; box-shadow: 0 10px 30px #173d3130; }
.paper.portrait { max-width: 365px; }
.paper.square { max-width: 505px; }
.preview-foot { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 45px; padding: 8px; color: var(--muted); font-size: .8125rem; }
.tabs { display: flex; gap: 0; padding: 0 14px; border-bottom: 1px solid #e9efeb; }
.tabs button { flex: 1; min-height: 44px; border: 0; border-bottom: 2px solid transparent; color: var(--muted); background: white; font-size: .875rem; }
.tabs [aria-selected="true"] { color: var(--green-dark); border-bottom-color: var(--green); font-weight: 740; }
.editor-content { padding: 13px 14px 15px; }
.editor-content label, .editor-content legend, .photos-heading { display: block; margin: 0 0 5px; font-size: .875rem; font-weight: 700; }
fieldset { border: 0; padding: 0; margin: 0 0 12px; min-width: 0; }
.layouts, .themes { display: grid; gap: 5px; }
.layouts { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.themes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice { display: grid; place-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 2px; min-height: 54px; font-size: .8125rem; background: white; }
.choice:hover { background: #f5faf7; }
.choice[aria-pressed="true"] { border-color: #5e9e7c; color: var(--green-dark); background: var(--mint); font-weight: 700; }
.choice svg { width: 23px; height: 20px; }
.swatch { width: 23px; height: 16px; border-radius: 4px; background: var(--swatch); border: 1px solid #25443332; }
input:not([type="file"], [type="range"]), textarea, select { display: block; width: 100%; margin: 0 0 11px; padding: 7px 9px; min-height: 38px; border: 1px solid #d6e3da; border-radius: 8px; background: #fbfdfb; color: var(--ink); font-size: .9rem; }
textarea { resize: vertical; }
::placeholder { color: #5f756a; }
.photos { border-top: 1px solid #e9efeb; padding-top: 9px; }
.photo-heading-row { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-bottom: 5px; }
.photos-heading { margin: 0; }
.photo-heading-row .button { min-height: 35px; padding-inline: 7px; }
.photo-row { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 6px; margin-top: 5px; }
.photo-row img, .photo-empty { display: grid; place-items: center; width: 36px; height: 32px; object-fit: cover; border-radius: 5px; background: #e9f3ed; color: var(--muted); }
.photo-row .button { padding: 6px; min-height: 34px; justify-content: flex-start; font-size: .8125rem; }
.photo-row .icon-button { width: 34px; min-height: 34px; }
.crop { padding: 1px 0 5px; margin: 4px 0 0 42px; font-size: .8125rem; }
.crop summary { color: var(--green-dark); cursor: pointer; }
.crop label { display: flex; justify-content: space-between; align-items: center; font-size: .8125rem; margin: 3px 0 0; }
.crop input { width: min(65%, 135px); accent-color: var(--green); }
.project-actions { display: grid; gap: 7px; padding-top: 11px; border-top: 1px solid #e9efeb; }
.project-actions button { justify-content: flex-start; }
.guide { padding: 40px 0 24px; scroll-margin-top: 16px; }
.guide h2 { font-size: 1.4rem; margin: 0 0 15px; }
.guide-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 13px; }
.guide article, .guide details { border: 1px solid var(--line); background: white; border-radius: 12px; padding: 14px 16px; }
.guide h3 { margin: 0 0 5px; font-size: 1rem; }
.guide p { margin: 0; color: var(--muted); }
.guide details + details { margin-top: 7px; }
.guide summary { cursor: pointer; font-weight: 650; }
.guide details p { margin-top: 8px; }
.site-footer { display: flex; gap: 12px 18px; flex-wrap: wrap; padding: 15px 0 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: .875rem; }
dialog { width: min(420px, calc(100% - 30px)); border: 1px solid var(--line); border-radius: 15px; padding: 18px; color: var(--ink); box-shadow: 0 30px 70px #0e29264a; }
dialog::backdrop { background: #173a30a0; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.dialog-heading h2 { font-size: 1.25rem; margin: 0; }
dialog p { color: var(--muted); }
dialog > .button { width: 100%; margin-top: 6px; }
#export-status:empty { display: none; }
.toast { position: fixed; z-index: 4; left: 50%; bottom: 18px; width: max-content; max-width: calc(100% - 24px); transform: translateX(-50%); padding: 10px 16px; border-radius: 9px; color: white; background: #143e31; box-shadow: 0 5px 20px #102f3333; font-size: .875rem; }
@media (max-width: 1130px) {
  .shell { width: calc(100% - 36px); }
  .studio { grid-template-columns: 155px minmax(0, 1fr) 264px; gap: 10px; }
  .stage { min-height: 405px; padding: 19px; }
}
@media (max-width: 930px) {
  .studio { grid-template-columns: minmax(0, 1fr) 264px; }
  .pages-panel { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; }
  .pages-panel .panel-heading { width: 100%; min-height: 42px; padding-block: 9px; }
  .page-list { display: flex; gap: 5px; flex: 1; padding: 6px; max-height: none; }
  .page-item { flex: 0 0 130px; }
  .page-item + .page-item { margin: 0; }
  .add-page { width: auto; margin: 5px; }
  .page-actions { border: 0; padding: 4px; }
}
@media (max-width: 650px) {
  .shell { width: calc(100% - 26px); }
  .topbar { min-height: 63px; }
  .brand { font-size: .95rem; gap: 7px; }
  .brand-mark { width: 34px; height: 34px; }
  .guide-link { display: none; }
  .intro { align-items: flex-start; flex-direction: column; padding: 23px 0 15px; gap: 5px; }
  .intro .save-status { margin-top: 3px; }
  .studio { grid-template-columns: minmax(0, 1fr); }
  .page-list { flex: 1 1 100%; }
  .page-actions { margin-inline-start: auto; }
  .stage { min-height: 0; padding: 15px; }
  .paper.portrait { max-width: 290px; }
  .guide-grid { grid-template-columns: 1fr; }
}
