@font-face {
  font-family: LabelCJK;
  src: url('assets/label-cjk.woff') format('woff');
  font-display: swap;
}

:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: #263b33;
  background: #eef1ed;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button {
  min-height: 36px;
  cursor: pointer;
  border: 1px solid #ced8ce;
  border-radius: 7px;
  background: #fff;
  color: #3d5144;
  padding: 8px 12px;
  font-size: 14px;
}
button:hover { background: #edf2e9; }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, input:focus-visible, textarea:focus-visible,
select:focus-visible, summary:focus-visible {
  outline: 3px solid #c5a853;
  outline-offset: 2px;
}
.primary { background: #355447; border-color: #355447; color: #fff; font-weight: 600; }
.primary:hover { background: #28483a; }
.danger { color: #945648; }
.full { width: 100%; }

header {
  height: 76px;
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid #dce3d8;
  display: flex;
  gap: 16px;
  align-items: center;
}
.brand { display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 650; flex-shrink: 0; }
.brand b {
  display: grid;
  place-items: center;
  width: 42px;
  height: 44px;
  background: #3b594b;
  border-radius: 10px;
  color: #fff;
  font-size: 28px;
}
.brand span { font-size: 13px; font-weight: 400; color: #758471; display: block; margin-top: 2px; }
.local { margin-left: auto; color: #768472; font-size: 12px; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.local + .header-actions { margin-left: 0; }
.header-actions button { white-space: nowrap; }

main { min-height: calc(100dvh - 76px); }
body.has-document main { display: grid; grid-template-columns: 320px minmax(0, 1fr); height: calc(100dvh - 76px); min-height: 0; }
aside {
  padding: 22px 20px;
  min-width: 0;
  min-height: 0;
  background: #fbfcfa;
  border-right: 1px solid #d9e1d5;
  overflow: auto;
  scrollbar-gutter: stable;
}
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0; }
.section-title span { font-size: 12px; color: #7d8976; }
.section-title button { font-size: 12px; padding: 6px 8px; }
label { display: grid; gap: 6px; font-size: 13px; color: #5a6c54; margin-bottom: 12px; }
select, input, textarea {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  border: 1px solid #cdd8c8;
  border-radius: 6px;
  color: #293f2e;
  background: #fff;
  padding: 8px 9px;
  font-size: 14px;
}
textarea { font-size: 16px; line-height: 1.5; resize: vertical; }
input[type=color] { padding: 3px; height: 36px; }
input[type=checkbox] { width: auto; min-height: 0; accent-color: #3b594b; }
.hint, details p { font-size: 12px; line-height: 1.7; color: #617158; }
details { font-size: 13px; margin-top: 12px; }
details summary { cursor: pointer; min-height: 36px; padding: 9px 0; color: #53694b; }
details[open] > summary { margin-bottom: 6px; }
.recognition { margin-top: 16px; padding-bottom: 14px; border-bottom: 1px solid #e1e7dc; }
#recognition-settings { margin-top: 0; }
body:not(.has-blocks) #recognition-settings > summary { display: none; }
.recognition-intro { margin: 0 0 10px; }
#recognition-advanced { margin: 0 0 12px; }
#cancel { margin-top: 8px; }
#status { font-size: 12px; line-height: 1.65; color: #62765b; margin: 10px 0 16px; overflow-wrap: anywhere; }
progress { width: 100%; height: 7px; margin-top: 12px; accent-color: #355447; }
#inspector > .section-title { margin-bottom: 12px; }
#confidence { display: block; font-size: 12px; color: #7d8976; margin: 6px 0; }
.font-size-field { max-width: 132px; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.two label { margin-bottom: 8px; }
.actions { margin: 12px 0; }
.actions button { padding: 8px 6px; font-size: 12px; }
#format-settings { border-top: 1px solid #e0e6da; padding-top: 3px; }
#selection-hint { margin: 0 0 14px; }
.blocks { margin-top: 18px; border-top: 1px solid #e0e6da; padding-top: 14px; }
#block-list { max-height: 260px; overflow: auto; margin-top: 10px; display: grid; gap: 6px; }
#block-list button { min-width: 0; text-align: left; padding: 8px 10px; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-color: #e0e5dc; }
#block-list button.active { background: #e0eadb; border-color: #92ac85; }
#block-list button.changed::before { content: '● '; color: #628354; }

.workspace { min-width: 0; min-height: 0; padding: 18px 24px 0; display: flex; flex-direction: column; }
body:not(.has-document) .workspace { max-width: 1040px; min-height: calc(100dvh - 76px); margin: auto; padding: 32px 24px 12px; justify-content: center; }
.topbar { display: flex; flex-shrink: 0; gap: 20px; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.topbar > div:first-child { min-width: 0; }
.eyebrow { font-size: 10px; letter-spacing: 2px; color: #88977c; }
#filename { font-size: 17px; margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toolbar { display: flex; flex-shrink: 0; gap: 12px; align-items: center; }
.toolbar label { margin: 0; font-size: 12px; }
.toolbar select { padding: 7px; font-size: 13px; }
.check { display: flex; align-items: center; white-space: nowrap; padding-top: 20px; }
#empty { min-height: 420px; border: 1px dashed #becdb4; border-radius: 12px; background: #f8faf6; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 36px 20px; }
.document-icon { font-size: 48px; color: #809577; margin-bottom: 16px; }
#empty h2 { font-size: 23px; }
#empty p { font-size: 15px; line-height: 1.9; color: #72836a; margin: 16px 0 20px; }
#empty button { min-width: 175px; margin: 5px; }
#empty small { font-size: 12px; line-height: 1.7; color: #617158; margin-top: 24px; }
#paper-scroll { flex: 1; min-height: 0; overflow: auto; background-image: radial-gradient(#c2cebd .65px, transparent .65px); background-size: 15px 15px; padding: 16px; }
#paper { position: relative; background: #fff; box-shadow: 0 8px 30px #30432422; margin: 0 auto; }
#preview { display: block; width: 100%; height: auto; }
#overlay { position: absolute; inset: 0; pointer-events: none; }
#overlay button { position: absolute; pointer-events: auto; border: 1px solid #819e6866; background: #90b16a08; border-radius: 0; padding: 0; min-width: 5px; min-height: 5px; }
#overlay button:hover { background: #729b5130; border-color: #577839; }
#overlay button.active { border: 2px solid #a88227; background: #d9b4541a; z-index: 2; }
#overlay button.changed { border-color: #4b9758; }
#overlay.hidden-boxes button { border-color: transparent; background: transparent; }
#overlay.hidden-boxes button.active { border-color: #a88227; }
footer { display: flex; flex-shrink: 0; justify-content: space-between; gap: 12px; font-size: 12px; line-height: 1.6; color: #617158; padding: 12px 0; }

#export-dialog { width: min(460px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; padding: 24px; border: 1px solid #dce3d8; border-radius: 12px; background: #fbfcfa; color: #263b33; box-shadow: 0 16px 60px #263b3333; }
#export-dialog::backdrop { background: #263b3366; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.dialog-heading h2 { font-size: 20px; }
#close-export { flex-shrink: 0; }
#export-summary { font-size: 13px; color: #62765b; line-height: 1.7; overflow-wrap: anywhere; }
.export-settings { display: grid; gap: 14px; margin-top: 18px; }
.export-settings label { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); max-width: 90vw; padding: 14px 22px; background: #2d4638; color: #fff; border-radius: 8px; font-size: 14px; display: none; z-index: 20; }
#toast.show { display: block; }
#file-warning { background: #fff1c7; color: #835e14; padding: 15px; text-align: center; font-size: 15px; }
body.busy #inspector, body.busy .blocks { pointer-events: none; opacity: .6; }

@media (max-width: 1100px) {
  header { padding: 0 20px; gap: 12px; }
  .local { display: none; }
  .local + .header-actions { margin-left: auto; }
  .workspace { padding: 16px 18px 0; }
  .topbar { gap: 12px; }
  .toolbar { gap: 8px; }
}

@media (min-width: 701px) and (max-width: 900px) {
  .topbar { align-items: flex-start; flex-direction: column; gap: 10px; }
  .toolbar { width: 100%; justify-content: space-between; }
  .header-actions button { padding: 8px; font-size: 12px; }
}

@media (max-width: 700px) {
  header { height: auto; min-height: 68px; padding: 12px 14px; gap: 10px; flex-wrap: wrap; }
  .brand { font-size: 17px; gap: 8px; }
  .brand b { width: 31px; height: 36px; font-size: 23px; border-radius: 8px; }
  .brand span { display: none; }
  .header-actions { flex-wrap: wrap; gap: 6px; max-width: 100%; }
  .header-actions button { padding: 8px; font-size: 12px; }
  body.has-document header { position: sticky; top: 0; z-index: 10; }
  body.has-document .header-actions { flex: 1 0 100%; width: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  body.has-document .header-actions button { min-width: 0; padding-inline: 4px; }
  #inspector { scroll-margin-top: 140px; }
  main, body.has-document main { display: flex; flex-direction: column; height: auto; min-height: 0; }
  aside { order: 2; height: auto; overflow: visible; border-top: 1px solid #d3dec9; border-right: 0; padding: 20px 18px; }
  .workspace { padding: 14px 12px 0; }
  body.has-document .workspace { height: max(370px, 55dvh); }
  body:not(.has-document) .workspace { width: 100%; min-height: calc(100dvh - 76px); padding: 22px 14px 12px; }
  .topbar { gap: 10px; flex-direction: column; align-items: stretch; margin-bottom: 12px; }
  .eyebrow { display: none; }
  #filename { font-size: 15px; margin: 0; }
  .toolbar { width: 100%; gap: 8px; justify-content: space-between; }
  .toolbar select { max-width: 132px; }
  #empty { min-height: 370px; padding: 30px 16px; }
  #empty h2 { font-size: 21px; }
  #empty p { font-size: 14px; }
  #paper-scroll { padding: 16px; }
  footer { font-size: 11px; gap: 8px; padding: 9px 0; flex-wrap: wrap; }
  #block-list { max-height: 320px; }
  #export-dialog { padding: 20px; }
}

