:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --panel: #fffdfa;
  --ink: #17211b;
  --muted: #5f6b63;
  --line: #d7d2c8;
  --accent: #176b5b;
  --accent-strong: #0d4f44;
  --warn: #9b2f20;
  --soft: #e9f2ee;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
}
body.menu-open { overflow: hidden; }
a { color: var(--accent-strong); }
.site-header, .site-footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(18px, 4vw, 48px);
  align-items: center;
}
.site-header { position: sticky; top: 0; z-index: 5; padding: 12px clamp(16px, 3vw, 32px); background: rgba(246, 244, 239, .94); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; font-size: 1.25rem; color: var(--ink); text-decoration: none; }
.brand img { width: 28px; height: 28px; flex: 0 0 auto; border-radius: 7px; }
.site-header nav { gap: 10px; }
.menu-toggle { display: none; }
.nav-cta { border: 1px solid var(--accent); border-radius: 6px; padding: 8px 10px; color: var(--accent-strong); background: white; }
nav a[aria-current="page"] { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 5px; }
nav { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
nav a { color: var(--ink); text-decoration: none; font-weight: 650; font-size: .94rem; }
main { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.hero { min-height: 56vh; display: grid; align-content: center; padding: 64px 0 36px; }
.hero.compact { min-height: auto; padding: 32px 0 10px; }
.home-hero { min-height: auto; padding: 32px 0 8px; }
.home-hero h1 { margin-bottom: 12px; }
.home-hero p { margin-top: 0; margin-bottom: 0; }
.xray-hero { min-height: auto; padding: 32px 0 10px; }
.xray-hero h1 { margin-bottom: 12px; }
.xray-hero p { margin-top: 0; margin-bottom: 0; }
.hero.compact h1 { margin-bottom: 12px; }
.hero.compact p { margin-top: 0; margin-bottom: 0; }
.xray-panel { margin-top: 12px; }
.eyebrow { color: var(--accent-strong); font-weight: 800; text-transform: uppercase; font-size: .78rem; letter-spacing: 0; }
h1 { font-size: clamp(2.2rem, 7vw, 5.2rem); line-height: .98; max-width: 980px; margin: 0 0 20px; letter-spacing: 0; }
.article h1 { font-size: clamp(2rem, 5vw, 3.8rem); }
h2 { font-size: 1.35rem; margin: 0 0 12px; }
p { max-width: 760px; }
.lead, .hero p { font-size: 1.16rem; color: var(--muted); }
.meta { color: var(--muted); font-size: .94rem; }
.tool-cards, .content-grid, .link-grid, .guide-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 28px 0; }
.tool-card, .content-grid > div, .link-grid > div, .guide-card, .tool-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}
.tool-card { text-decoration: none; color: var(--ink); min-height: 170px; display: grid; align-content: start; gap: 10px; }
.tool-card-featured { grid-column: 1 / -1; min-height: 145px; }
.tool-card em { color: var(--accent-strong); font-style: normal; font-weight: 800; }
.tool-icon { width: 56px; height: 56px; border-radius: 8px; display: block; }
.tool-card strong { display: block; font-size: 1.22rem; margin-bottom: 8px; }
.tool-panel { margin: 20px 0 34px; }
.empty-state { padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: #fffdfa; margin-bottom: 14px; }
.dropzone {
  display: grid;
  place-items: center;
  min-height: 150px;
  border: 2px dashed #9bb6ad;
  border-radius: 8px;
  background: var(--soft);
  padding: 24px;
  cursor: pointer;
  font-weight: 800;
}
.dropzone input { margin-top: 12px; max-width: 100%; }
.toolbar, .options-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; align-items: center; }
button, .button {
  appearance: none;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  border-radius: 6px;
  padding: 10px 14px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}
button:disabled { opacity: .45; cursor: not-allowed; }
button.secondary { color: var(--accent-strong); background: white; }
.rotate-icon-button {
  width: var(--page-action-size, 46px);
  height: var(--page-action-size, 46px);
  min-width: var(--page-action-size, 46px);
  padding: 0;
  overflow: hidden;
  text-indent: -999px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 28px 28px;
}
.rotate-icon-button.rotate-left {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M10.85 32A21.15 21.15 0 1 0 32 10.85A22.91 22.91 0 0 0 16.16 17.29L10.85 22.6M10.85 10.85v11.75H22.6' fill='none' stroke='%23fffdfa' stroke-width='6' stroke-linecap='round' stroke-linejoin='round'/%3E%3Crect x='22' y='19' width='20' height='26' rx='3' fill='%23fffdfa'/%3E%3Cpath d='M37 19l5 5h-5z' fill='%239fd3c7'/%3E%3Cpath d='M27 30h10M27 36h8' stroke='%23176b5b' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
}
.rotate-icon-button.rotate-right {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M53.15 32A21.15 21.15 0 1 1 32 10.85A22.91 22.91 0 0 1 47.84 17.29L53.15 22.6M53.15 10.85v11.75H41.4' fill='none' stroke='%23fffdfa' stroke-width='6' stroke-linecap='round' stroke-linejoin='round'/%3E%3Crect x='22' y='19' width='20' height='26' rx='3' fill='%23fffdfa'/%3E%3Cpath d='M37 19l5 5h-5z' fill='%239fd3c7'/%3E%3Cpath d='M27 30h10M27 36h8' stroke='%23176b5b' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
}
button.secondary.rotate-icon-button.rotate-left,
button.secondary.rotate-icon-button.rotate-right {
  background-color: white;
  border-color: var(--line);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 28px 28px;
}
button.secondary.rotate-icon-button.rotate-left {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M10.85 32A21.15 21.15 0 1 0 32 10.85A22.91 22.91 0 0 0 16.16 17.29L10.85 22.6M10.85 10.85v11.75H22.6' fill='none' stroke='%23176b5b' stroke-width='6' stroke-linecap='round' stroke-linejoin='round'/%3E%3Crect x='22' y='19' width='20' height='26' rx='3' fill='%23fffdfa' stroke='%23176b5b' stroke-width='3'/%3E%3Cpath d='M37 19l5 5h-5z' fill='%239fd3c7'/%3E%3Cpath d='M27 30h10M27 36h8' stroke='%23176b5b' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
}
button.secondary.rotate-icon-button.rotate-right {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M53.15 32A21.15 21.15 0 1 1 32 10.85A22.91 22.91 0 0 1 47.84 17.29L53.15 22.6M53.15 10.85v11.75H41.4' fill='none' stroke='%23176b5b' stroke-width='6' stroke-linecap='round' stroke-linejoin='round'/%3E%3Crect x='22' y='19' width='20' height='26' rx='3' fill='%23fffdfa' stroke='%23176b5b' stroke-width='3'/%3E%3Cpath d='M37 19l5 5h-5z' fill='%239fd3c7'/%3E%3Cpath d='M27 30h10M27 36h8' stroke='%23176b5b' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
}
.move-icon-button {
  width: var(--page-action-size, 46px);
  height: var(--page-action-size, 46px);
  min-width: var(--page-action-size, 46px);
  padding: 0;
  overflow: hidden;
  text-indent: -999px;
  background-color: white;
  border-color: var(--line);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 28px 28px;
}
.move-icon-button.move-earlier {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M28 16L12 32l16 16' fill='none' stroke='%23176b5b' stroke-width='7' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M14 32h38' fill='none' stroke='%23176b5b' stroke-width='7' stroke-linecap='round'/%3E%3C/svg%3E");
}
.move-icon-button.move-later {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M36 16l16 16-16 16' fill='none' stroke='%23176b5b' stroke-width='7' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M12 32h38' fill='none' stroke='%23176b5b' stroke-width='7' stroke-linecap='round'/%3E%3C/svg%3E");
}
.remove-icon-button {
  width: var(--page-action-size, 42px);
  height: var(--page-action-size, 42px);
  min-width: var(--page-action-size, 42px);
  padding: 0;
  overflow: hidden;
  text-indent: -999px;
  background-color: white;
  border-color: var(--line);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 28px 28px;
}
.keep-icon-button {
  width: var(--page-action-size, 42px);
  height: var(--page-action-size, 42px);
  min-width: var(--page-action-size, 42px);
  padding: 0;
  overflow: hidden;
  text-indent: -999px;
  background-color: white;
  border-color: var(--line);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 28px 28px;
}
button.secondary.remove-icon-button {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M22 25h20l-2 25H24z' fill='none' stroke='%239b2f20' stroke-width='5' stroke-linejoin='round'/%3E%3Cpath d='M18 22h28' fill='none' stroke='%239b2f20' stroke-width='5' stroke-linecap='round'/%3E%3Cpath d='M27 21v-5h10v5' fill='none' stroke='%239b2f20' stroke-width='5' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M29 31v12M35 31v12' fill='none' stroke='%239b2f20' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E");
}
button.secondary.keep-icon-button {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M22 25h20l-2 25H24z' fill='none' stroke='%23176b5b' stroke-width='5' stroke-linejoin='round'/%3E%3Cg transform='rotate(-22.5 32 17)'%3E%3Cpath d='M18 17h28' fill='none' stroke='%23176b5b' stroke-width='5' stroke-linecap='round'/%3E%3Cpath d='M27 16v-5h10v5' fill='none' stroke='%23176b5b' stroke-width='5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/g%3E%3Cpath d='M29 31v12M35 31v12' fill='none' stroke='%23176b5b' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E");
}
.status { padding: 10px 12px; background: #f3efe6; border-left: 4px solid var(--accent); color: var(--muted); max-width: none; }
.status.is-error { border-color: var(--warn); color: var(--warn); }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 16px 0; }
.summary-grid span { padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.field { display: grid; gap: 6px; max-width: 420px; font-weight: 800; }
input[type="text"], select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 11px 12px; font: inherit; background: white; color: var(--ink); }
.export-summary { background: white; border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin: 18px 0; }
.page-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.page-card, .list-row {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-width: 0;
}
.page-card { --page-action-size: clamp(30px, 24cqw, 46px); container-type: inline-size; display: flex; flex-direction: column; }
.page-card.removed { opacity: .65; }
.page-card.blank { border-color: var(--warn); }
.page-card.selected { outline: 3px solid var(--accent); outline-offset: 2px; }
.page-card h3 { margin: 8px 0 6px; font-size: .95rem; line-height: 1.25; overflow-wrap: anywhere; }
.flag-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.flag-list:empty { display: none; }
.flag-list span { display: inline-block; max-width: 100%; padding: 3px 7px; border-radius: 999px; background: var(--soft); color: var(--accent-strong); font-size: .78rem; font-weight: 800; line-height: 1.2; overflow-wrap: anywhere; }
.flag-list .warn { background: #f3efe6; color: var(--warn); }
.thumb-frame { width: 100%; aspect-ratio: var(--thumb-aspect, 3 / 4); position: relative; overflow: hidden; background: #f7f7f7; border: 1px solid var(--line); border-radius: 6px; }
.thumb { display: block; position: absolute; left: 50%; top: 50%; width: var(--thumb-width, 100%); height: var(--thumb-height, 100%); object-fit: fill; transform: translate(-50%, -50%) rotate(var(--page-rotation, 0deg)); transform-origin: center; transition: transform .16s ease; }
.list-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; margin-bottom: 10px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-start; }
.move-actions { margin-top: auto; padding-top: 8px; justify-content: flex-end; flex-wrap: nowrap; }
.page-actions { display: flex; gap: 8px; flex-wrap: nowrap; padding-top: 8px; align-items: center; justify-content: space-between; }
.rotate-actions { display: flex; gap: 8px; flex-wrap: nowrap; justify-content: flex-end; }
.article { padding: 46px 0; }
.article section { margin: 30px 0; }
.guide-visual {
  max-width: 760px;
  margin: 24px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.guide-visual svg { display: block; width: 100%; height: auto; }
.guide-visual figcaption { color: var(--muted); font-size: .94rem; margin-top: 8px; }
.site-footer { border-top: 1px solid var(--line); margin-top: 60px; align-items: flex-start; }
.site-footer p { margin: 6px 0 0; color: var(--muted); }
.viewer-shell { min-height: calc(100dvh - 72px); padding: 24px 0; display: grid; align-items: center; }
.viewer-empty { width: min(720px, 100%); margin: 0 auto; }
.viewer-dropzone { margin-top: 18px; }
.viewer-workspace { min-height: calc(100dvh - 120px); display: grid; grid-template-rows: auto auto 1fr; gap: 10px; }
.viewer-toolbar { position: sticky; top: 58px; z-index: 4; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255, 253, 250, .96); }
.viewer-toolbar button, .viewer-toolbar .button { min-height: 44px; }
.viewer-file-name { min-width: 0; flex: 1 1 auto; max-width: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; }
.viewer-meter { min-width: 64px; text-align: center; font-weight: 800; }
.viewer-canvas-wrap { min-height: 0; min-width: 0; height: min(78dvh, 820px); border: 1px solid var(--line); border-radius: 8px; overflow: auto; background: #d9d6ce; padding: 14px; display: grid; align-items: start; justify-items: center; }
.viewer-canvas-wrap canvas { display: block; max-width: 100%; height: auto; background: white; box-shadow: 0 1px 8px rgba(23, 33, 27, .16); }
@media (max-width: 760px) {
  .site-header { display: grid; grid-template-columns: 1fr auto; }
  .site-footer { display: block; }
  .menu-toggle { display: inline-flex; min-height: 44px; align-items: center; }
  .site-header nav { display: none; grid-column: 1 / -1; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
  .site-header.is-menu-open nav { display: flex; }
  .site-footer nav { margin-top: 12px; }
  .tool-cards, .content-grid, .link-grid, .guide-grid { grid-template-columns: 1fr; }
  .page-grid { gap: 8px; }
  .page-card { padding: 6px; }
  .page-card h3 { font-size: .72rem; line-height: 1.2; }
  .flag-list { gap: 4px; margin: 6px 0; }
  .flag-list span { padding: 2px 5px; font-size: .66rem; }
  .move-actions, .page-actions { gap: 6px; }
  .rotate-actions { gap: 6px; justify-content: flex-start; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .viewer-toolbar { top: 57px; }
  .viewer-file-name { flex-basis: 100%; order: 3; }
  .viewer-canvas-wrap { height: 72dvh; padding: 8px; }
  .viewer-meter { min-width: 54px; }
  h1 { font-size: 2.45rem; }
}
@media (max-width: 560px) {
  .page-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}