:root {
  color-scheme: light;
  --ink: #172a31;
  --muted: #62737c;
  --line: #dbe5e7;
  --accent: #087f70;
  --tint: #e6f5f1;
  font-family: system-ui, "Microsoft YaHei", "PingFang SC", sans-serif;
  color: var(--ink);
  background: #eef3f4;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, textarea { font: inherit; }
button { cursor: pointer; color: inherit; }
button:disabled { cursor: default; opacity: .44; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 25px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; font-size: 24px; background: var(--ink); color: #bdf1d5; }
h1, h2, p { margin: 0; }
h1 { font-size: 19px; letter-spacing: .05em; }
.brand p, .library-head p { color: var(--muted); font-size: 12px; margin-top: 2px; }
.primary { display: flex; gap: 16px; align-items: center; border: 0; border-radius: 10px; padding: 11px 16px; color: #fff; background: var(--accent); font-weight: 700; }
.primary:hover:not(:disabled) { background: #07685c; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 335px; min-height: calc(100vh - 66px); max-width: 1670px; margin: auto; }
.editor { min-width: 0; }
.tools { background: #f9fbfb; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.tool-row, .group { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.group { gap: 7px; }
.tool-row strong { color: #27444a; font-size: 14px; padding-right: 4px; }
.caption, .limit, .library-options, .hint, .results-top, .page-note { color: var(--muted); font-size: 12px; }
.segmented { display: inline-flex; align-items: center; padding: 3px; gap: 2px; border: 1px solid var(--line); background: #fff; border-radius: 9px; }
.segmented button, .pages button { border: 0; background: transparent; padding: 5px 8px; border-radius: 6px; min-width: 29px; font-size: 12px; }
.segmented button:hover:not(:disabled), .tool-button:hover:not(:disabled), .pages button:hover:not(:disabled) { background: #edf5f4; }
button[aria-pressed="true"] { color: #086c60; background: var(--tint); font-weight: 700; }
#rows { border: 0; width: 32px; text-align: center; background: #fff; appearance: textfield; font-size: 13px; }
#rows::-webkit-inner-spin-button, #rows::-webkit-outer-spin-button { appearance: none; }
.selection { margin-top: 10px; gap: 7px; }
.selection-label { min-width: 89px; color: var(--accent); font-weight: 700; font-size: 12px; }
.tool-button { background: #fff; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; padding: 6px 9px; white-space: nowrap; }
.paper-area { max-width: 760px; padding: 16px clamp(14px, 4vw, 38px) 36px; margin: 0 auto; }
.page-note { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0 0 10px; }
.page-note span:first-child { font-weight: 700; color: #334e55; }
.paper { position: relative; width: 100%; aspect-ratio: 210 / 297; background: white; border: 1px solid #dce5e7; box-shadow: 0 12px 35px #142d361c; }
.paper-area[data-page-orientation="landscape"] { max-width: 1040px; }
.paper-area[data-page-orientation="landscape"] .paper { aspect-ratio: 297 / 210; }
canvas { display: block; width: 100%; height: 100%; }
.slots { position: absolute; inset: 0; }
.slot { position: absolute; border-radius: 4px; }
.slot.selected { background: #087f7009; box-shadow: 0 0 0 1.5px #139788; }
.slot.drop { background: #b0eada80; box-shadow: 0 0 0 2px #139788; }
.gift-target, .text-input { position: absolute; border: 1px dashed #c9d9dc; border-radius: 4px; background: transparent; }
.gift-target { display: grid; place-items: center; color: #58767a; padding: 0; }
.gift-target:hover { background: #e6f5f13b; }
.gift-target .empty { font-size: clamp(11px, 1.4vw, 17px); }
.text-input { padding: 2px 4px; font-size: clamp(9px, 1.15vw, 14px); resize: none; color: transparent; line-height: 1.2; caret-color: #203037; }
.text-input::placeholder { color: #859399; }
.text-input:focus { color: var(--ink); background: #fff; border-style: solid; border-color: var(--accent); z-index: 1; }
.library { background: #fff; border-left: 1px solid var(--line); padding: 17px 15px; position: sticky; top: 65px; height: calc(100vh - 65px); overflow: auto; }
.library-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.library h2 { font-size: 17px; }
.contact { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 11px; padding: 7px 8px; border-radius: 8px; background: #edf6f4; color: #355951; font-size: 12px; }
.contact strong { font-variant-numeric: tabular-nums; }
.contact .tool-button { padding: 3px 6px; }
.search { margin-top: 13px; display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 9px; padding: 0 9px; background: #f8fafb; }
.search span { font-size: 22px; color: var(--accent); }
.search input { min-width: 0; width: 100%; border: 0; padding: 8px 0; background: transparent; color: var(--ink); font-size: 13px; }
.library-options { display: flex; align-items: center; justify-content: space-between; margin-top: 9px; }
.hint { line-height: 1.5; padding: 9px 0; }
.results-top { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding: 5px 0; }
.pages { display: inline-flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
.pages button { font-size: 16px; }
.results { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 6px; }
.gift-card { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px; height: 92px; min-width: 0; padding: 5px; border: 1px solid var(--line); border-radius: 9px; background: #fcfdfd; cursor: grab; user-select: none; }
.gift-card:hover { border-color: #63b8a8; background: #eefaf7; }
.drag-ghost { position: fixed; z-index: 30; width: 92px; height: 80px; pointer-events: none; transform: translate(-50%, -50%); opacity: .88; box-shadow: 0 5px 18px #163e4466; }
.gift-card img { width: 49px; height: 49px; object-fit: contain; pointer-events: none; }
.gift-card span { font-size: 11px; line-height: 1.1; max-width: 100%; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.no-results { grid-column: 1 / -1; color: var(--muted); padding: 12px; font-size: 13px; }
.toast { position: fixed; z-index: 20; right: 18px; bottom: 18px; background: #143d38; color: #fff; box-shadow: 0 6px 30px #162d3660; border-radius: 9px; padding: 10px 14px; font-size: 13px; max-width: min(360px, 90vw); }
@media (max-width: 810px) { .workspace { grid-template-columns: minmax(0,1fr) 255px; } .tools { padding: 9px; } .library { padding: 11px 9px; } .paper-area { padding-inline: 10px; } .gift-card { height: 77px; } .gift-card img { width: 39px; height: 39px; } }
@media (max-width: 580px) { .workspace { display: block; } .library { position: static; height: auto; } .topbar { padding-inline: 12px; } .paper-area { max-width: 480px; } }

.header-actions, .save-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.header-actions { justify-content: flex-end; }
.license-panel { min-width: 0; }
.license-panel .caption { line-height: 1.4; }
.license-row { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 7px; margin: 3px 0; }
.license-row code { font-size: 12px; overflow-wrap: anywhere; }
.license-row .tool-button { padding: 3px 7px; }
.license-dialog { width: min(420px, calc(100% - 32px)); padding: 22px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); }
.license-dialog::backdrop { background: #10202a80; }
.license-dialog h2 { font-size: 18px; }
.license-dialog p { margin-top: 10px; font-size: 14px; line-height: 1.55; }
.license-dialog-field { margin-top: 14px; }
.license-dialog-field label { display: block; margin-bottom: 5px; font-size: 13px; }
.license-dialog-field input { width: 100%; padding: 9px; border: 1px solid var(--line); border-radius: 7px; }
.license-dialog-error { color: #a22638; }
.license-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
@media (max-width: 700px) {
  .topbar { position: static; flex-wrap: wrap; gap: 10px; }
  .header-actions { justify-content: space-between; width: 100%; }
}
.save-row { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.save-row .caption { max-width: min(380px, 75vw); overflow-wrap: anywhere; }

.login-page {
  color-scheme: dark;
  color: #f7f7fa;
  background: #09090b;
  --login-muted: #b7b7c1;
  --login-focus: #25f4ee;
}
.login-wrap {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: clamp(16px, 5vw, 32px);
  background:
    radial-gradient(ellipse at 25% 28%, #25f4ee17, transparent 47%),
    radial-gradient(ellipse at 77% 72%, #fe2c551f, transparent 49%),
    #09090b;
}
.login-background {
  position: absolute;
  z-index: -1;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: .48;
  pointer-events: none;
}
.login-card {
  width: min(100%, 450px);
  padding: clamp(22px, 6vw, 34px);
  background: #121216bd;
  border: 1px solid #ffffff2b;
  border-radius: 24px;
  box-shadow: 0 24px 72px #000a, inset 0 1px #ffffff0d;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}
.login-card .brand-icon {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  box-shadow: 0 0 0 1px #ffffff22;
}
.login-card .brand h1 { font-size: clamp(17px, 4vw, 21px); letter-spacing: .015em; }
.login-card .brand p { color: var(--login-muted); }
.login-form { display: grid; gap: 10px; margin: 30px 0 20px; }
.login-form label { font-size: 14px; font-weight: 650; }
.login-form input {
  width: 100%;
  min-width: 0;
  padding: 12px 14px;
  color: inherit;
  background: #09090bc9;
  border: 1px solid #ffffff3d;
  border-radius: 10px;
}
.login-form input::placeholder { color: #aaaab5; }
.login-form .primary { justify-content: center; margin-top: 4px; background: #d91542; }
.login-form .primary:hover:not(:disabled) { background: #c8133d; }
.login-form :is(input, button):focus-visible { outline-color: var(--login-focus); }
.login-help { color: var(--login-muted); font-size: 13px; line-height: 1.65; margin-top: 8px; }
.login-help strong { color: #f0f0f5; }
.login-status { color: #ffadb9; font-size: 13px; line-height: 1.5; }
.login-status[data-success="true"] { color: #8ff1e2; }
