:root {
  color-scheme: light;
  --bg: #f7f7f5;
  --surface: #fff;
  --ink: #242522;
  --muted: #787b75;
  --line: #dedfd9;
  --soft: #f0f1ec;
  --accent: #2c463b;
  --danger: #a14437;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}
* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; color: var(--ink); background: var(--bg); font-size: 14px; line-height: 1.5; }
a { color: inherit; }
button, input { font: inherit; }
button, .button, .choose-file-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 8px 13px; border: 1px solid var(--line); border-radius: 5px;
  color: var(--ink); background: var(--surface); font-size: 13px; font-weight: 550;
  line-height: 1.4; text-decoration: none; white-space: nowrap; cursor: pointer;
}
button:hover:not(:disabled), .button:hover, .choose-file-button:hover { border-color: #aaa; background: #fafaf8; }
button.primary, .button.primary { color: #fff; border-color: var(--ink); background: var(--ink); }
button.primary:hover:not(:disabled), .button.primary:hover { background: #41443e; border-color: #41443e; }
button:disabled { color: #a4a79f; background: var(--soft); border-color: var(--line); cursor: default; }
button.primary:disabled { color: #f4f5f2; background: #afb3a9; border-color: #afb3a9; }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input[type="checkbox"] { accent-color: var(--accent); }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.page-shell { width: min(1160px, calc(100% - 64px)); margin: 0 auto; }
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; height: 72px; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; gap: 10px; align-items: center; font-size: 14px; font-weight: 700; letter-spacing: -.02em; text-decoration: none; }
.brand svg { width: 20px; height: 24px; color: var(--accent); }
.site-nav { display: flex; align-items: center; gap: 4px; }
.site-nav a { padding: 6px 11px; border-radius: 4px; color: var(--muted); font-size: 12px; text-decoration: none; }
.site-nav a:hover { color: var(--ink); background: var(--soft); }
.site-nav a[aria-current="page"] { color: var(--ink); background: #e9ebe4; }
.page-main { padding: 40px 0 48px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
h1 { margin: 0; font-size: 28px; font-weight: 600; line-height: 1.25; letter-spacing: -.04em; }
h2 { margin: 0; font-size: 13px; font-weight: 600; line-height: 1.5; }
p { margin: 0; }
.tool-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.tool-link { display: flex; align-items: center; gap: 18px; min-height: 134px; padding: 28px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); text-decoration: none; }
.tool-link:hover { border-color: #a8b4a9; background: #fdfefb; }
.tool-icon { display: grid; place-items: center; width: 42px; height: 48px; flex: 0 0 auto; color: var(--accent); }
.tool-icon svg { width: 27px; height: 31px; }
.tool-link strong { font-size: 18px; font-weight: 550; letter-spacing: -.025em; }
.tool-arrow { margin-left: auto; color: var(--muted); font-size: 20px; }
.panel { border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.source-panel { padding: 22px; }
.field-label { display: block; margin-bottom: 8px; color: #64675f; font-size: 12px; font-weight: 550; }
.input-row { display: flex; gap: 10px; }
.input-row input { min-width: 0; width: 100%; min-height: 42px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); background: #fdfdfc; font-size: 13px; }
.input-row input::placeholder { color: #a3a69e; }
.input-row button { min-width: 100px; }
.status { display: flex; gap: 9px; align-items: flex-start; margin-top: 15px; font-size: 12px; }
.status[data-state="idle"] { display: none; }
.status-dot { width: 6px; height: 6px; margin-top: 6px; border-radius: 50%; flex-shrink: 0; background: var(--accent); }
.status[data-state="working"] .status-dot { animation: pulse 1s ease-in-out infinite alternate; }
.status[data-state="error"] { color: var(--danger); }
.status[data-state="error"] .status-dot { background: var(--danger); }
.status-title { font-weight: 550; }
.status-detail { margin-top: 2px; color: var(--muted); }
.status-detail:empty { display: none; }
.result-section { margin-top: 22px; overflow: hidden; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.result-actions { display: flex; align-items: center; gap: 8px; }
.viewer-frame { height: min(76vh,900px); min-height: 400px; background: #e9ebe5; }
.viewer-frame iframe { width: 100%; height: 100%; display: block; border: 0; }
.license-link { display: inline-block; margin-top: 20px; color: #8e9288; font-size: 11px; text-decoration: none; }
.license-link:hover { text-decoration: underline; }
.file-panel { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.file-picker { display: flex; align-items: center; gap: 14px; min-width: 0; }
.file-name { min-width: 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.visually-hidden:focus-visible + .choose-file-button { outline: 2px solid var(--accent); outline-offset: 3px; }
.visually-hidden:disabled + .choose-file-button { color: #a4a79f; background: var(--soft); cursor: default; }
.status-row { display: flex; align-items: center; gap: 8px; min-height: 30px; margin: 2px 2px 6px; color: var(--muted); font-size: 12px; }
.spinner { width: 12px; height: 12px; border: 1.5px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
.error { margin: 0 0 12px; padding: 10px 12px; border: 1px solid #e6cfc7; border-radius: 5px; color: var(--danger); background: #fff8f5; font-size: 12px; }
.local-workspace { display: grid; grid-template-columns: 246px minmax(0,1fr); gap: 18px; align-items: start; }
.processing-panel { overflow: hidden; }
.control-section { padding: 18px; }
.control-section + .control-section { border-top: 1px solid var(--line); }
.control-section h2 { margin-bottom: 14px; }
.processing-actions { display: flex; gap: 6px; margin-bottom: 12px; }
.processing-actions button { flex: 1; min-height: 30px; padding: 5px 8px; font-size: 11px; }
.image-list { display: grid; gap: 6px; max-height: 230px; overflow: auto; }
.image-row { display: flex; align-items: center; gap: 9px; padding: 8px; border: 1px solid var(--line); border-radius: 4px; font-size: 12px; }
.image-row input { width: 14px; height: 14px; margin: 0; }
.processing-empty { display: block; padding: 10px 0; color: #a0a397; font-size: 12px; }
.watermark-actions { display: grid; gap: 8px; }
.watermark-actions button { width: 100%; }
.watermark-state { display: block; margin: 0 0 12px; color: var(--muted); font-size: 11px; }
.watermark-active { border-color: #afc4b4; color: var(--accent); background: #eff5ed; }
.viewer-panel { min-width: 0; overflow: hidden; }
.viewer-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 58px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.viewer-title { color: var(--muted); font-size: 12px; }
.toolbar { display: flex; align-items: center; gap: 6px; }
.toolbar button { min-width: 30px; min-height: 30px; padding: 4px 8px; font-size: 12px; }
.page-tools { display: flex; align-items: center; gap: 5px; padding-right: 9px; margin-right: 3px; border-right: 1px solid var(--line); }
#pageIndicator { min-width: 67px; color: var(--muted); text-align: center; font-size: 11px; font-variant-numeric: tabular-nums; }
.zoom-value { min-width: 38px; text-align: center; font-size: 11px; font-variant-numeric: tabular-nums; }
.canvas-wrap { display: grid; place-items: start center; min-height: 440px; max-height: min(74vh,900px); overflow: auto; padding: 22px; background: #ebede7; }
#previewCanvas { display: block; max-width: none; margin: 0 auto; border: 1px solid #d4d7cd; background: #fff; }
.empty-state { display: grid; place-items: center; align-self: stretch; width: 100%; min-height: 395px; color: #b7bdae; }
.empty-state svg { width: 34px; height: 42px; }
.export-panel { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { to { opacity: .35; } }
@media (max-width: 900px) {
  .page-shell { width: calc(100% - 40px); }
  .local-workspace { grid-template-columns: 210px minmax(0,1fr); gap: 12px; }
  .control-section { padding: 14px; }
  .viewer-top { flex-wrap: wrap; }
  .viewer-top .toolbar { margin-left: auto; }
}
@media (max-width: 700px) {
  .page-shell { width: calc(100% - 32px); }
  .site-header { height: 62px; gap: 10px; }
  .site-nav { gap: 0; }
  .site-nav a { padding: 6px 8px; }
  .page-main { padding-top: 28px; }
  .page-heading { margin-bottom: 20px; }
  h1 { font-size: 25px; }
  .tool-list { grid-template-columns: 1fr; gap: 12px; }
  .tool-link { min-height: 104px; padding: 21px; }
  .tool-link strong { font-size: 17px; }
  .local-workspace { grid-template-columns: 1fr; }
  .processing-panel { display: grid; grid-template-columns: 1fr 1fr; }
  .control-section + .control-section { border-top: 0; border-left: 1px solid var(--line); }
  .control-section { padding: 13px; min-width: 0; }
  .control-section h2 { margin-bottom: 10px; }
  .watermark-actions button { padding: 7px 8px; font-size: 11px; white-space: normal; }
  .file-panel { padding: 12px; }
  .file-picker { align-items: flex-start; }
  .file-name { align-self: center; }
  .viewer-top { gap: 8px; padding: 10px; }
  .canvas-wrap { min-height: 330px; padding: 14px; }
  .empty-state { min-height: 302px; }
  .export-panel { padding: 10px; }
  .source-panel { padding: 16px; }
  .input-row { flex-wrap: wrap; }
  .input-row button { width: 100%; }
  .viewer-frame { min-height: 370px; height: 70vh; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; scroll-behavior: auto !important; }
}
