:root {
  --ink: #20242c; --muted: #747c8b; --line: #e1e5ec;
  --blue: #3158d4; --blue-dark: #2448bb; --blue-soft: #f0f4ff;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: #f7f8fa; font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, p { margin: 0; }
button, input, select { font: inherit; }
button, select, label { cursor: pointer; }
button:disabled { opacity: .5; cursor: wait; }
:focus-visible { outline: 3px solid #a9bdf9; outline-offset: 3px; }
svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
.appbar { height: 64px; padding: 0 max(24px, calc((100vw - 1120px) / 2)); display: flex; align-items: center; justify-content: space-between; gap: 20px; background: white; border-bottom: 1px solid var(--line); }
.brand { color: var(--blue); text-decoration: none; font-size: clamp(20px, 2vw, 24px); font-weight: 700; letter-spacing: -.4px; }
.developer-credit { font-size: 12px; color: var(--muted); text-align: right; }
main { width: min(980px, calc(100% - 40px)); margin: 32px auto; background: white; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 32px #20242c06; overflow: hidden; }
.workspace-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 22px 26px; border-bottom: 1px solid var(--line); }
h1 { font-size: 21px; font-weight: 650; letter-spacing: -.5px; }
#pageDescription { font-size: 13px; color: var(--muted); margin-top: 4px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 28px; padding: 24px; min-height: 0; }
.canvas-panel { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-width: 0; min-height: 0; }
.canvas-content { position: relative; display: grid; min-height: 0; background: #f2f4f7; border-radius: 10px; }
.canvas-content.dragging { outline: 2px dashed var(--blue); outline-offset: -4px; background: var(--blue-soft); }
.canvas-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding-top: 12px; color: var(--muted); font-size: 10px; }
.file-caption { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.canvas-footer > :last-child { flex-shrink: 0; }
.upload-view { min-height: 280px; padding: 30px 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; border: 1.5px dashed #d4dae4; border-radius: 10px; background: #fcfcfd; }
.upload-icon { width: 28px; height: 28px; color: var(--blue); margin-bottom: 18px; }
.upload-view h2 { font-size: 17px; font-weight: 600; }
.upload-view p { margin: 5px 0 18px; font-size: 13px; color: var(--muted); }
.upload-formats { margin-top: 12px; font-size: 11px; color: var(--muted); }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 42px; padding: 0 16px; border: 1px solid transparent; border-radius: 7px; font-size: 12px; font-weight: 600; text-decoration: none; white-space: nowrap; transition: background .15s; }
.button svg { width: 16px; height: 16px; }
.primary { background: var(--blue); color: white; }
.primary:hover:not(:disabled) { background: var(--blue-dark); }
.quiet, .tool { background: white; border-color: var(--line); color: var(--ink); }
.quiet:hover, .tool:hover { background: #f5f7fb; }
.quiet { min-height: 36px; font-weight: 500; }
.full { width: 100%; }
.inspector { display: flex; flex-direction: column; min-height: 0; }
.inspector-content { display: flex; flex-direction: column; gap: 22px; overflow: auto; min-height: 0; padding: 2px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { margin-bottom: 10px; padding: 0; font-size: 12px; font-weight: 600; }
.size-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.size-option { position: relative; }
.size-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.size-card { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 7px; }
.size-card strong { font-size: 12px; font-weight: 600; }
.size-number { font-size: 12px; color: var(--muted); }
.size-number small { font-size: inherit; }
.size-option input:checked + .size-card { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }
.size-option input:checked + .size-card .size-number { color: var(--blue); }
.size-option input:focus-visible + .size-card { outline: 3px solid #a9bdf9; outline-offset: 3px; }
.field-hint { margin-top: 8px; font-size: 11px; color: var(--muted); }
.scan-settings select { display: block; width: 100%; min-height: 38px; padding: 0 8px; background: white; border: 1px solid var(--line); border-radius: 7px; font-size: 12px; color: var(--ink); }
.detection-note { display: block; color: var(--blue); font-size: 11px; margin-bottom: 10px; }
.tool-row { display: flex; gap: 8px; margin-top: 10px; }
.tool-row > * { flex: 1; }
.enhance-option { display: flex; align-items: center; gap: 8px; font-size: 12px; margin-top: 14px; }
.enhance-option input { accent-color: var(--blue); margin: 0; width: 14px; height: 14px; }
.inspector-actions { padding-top: 20px; margin-top: auto; }
.action-hint { text-align: center; font-size: 10px; color: var(--muted); margin-top: 8px; }
.status { font-size: 12px; color: #b42335; padding: 0 24px 14px; }
.status:empty { display: none; }
.crop-view { display: grid; min-height: 0; padding: 16px; }
#cropEditor { width: 100%; height: 100%; min-height: 0; touch-action: none; user-select: none; }
.crop-handle { fill: white; stroke: var(--blue); cursor: grab; }
.crop-handle:focus { fill: #b9cdff; outline: none; }
.crop-handle.fold { stroke: #c28a31; }
.result-view { display: flex; align-items: center; justify-content: center; min-height: 0; padding: 20px; }
.result-view img { max-width: 100%; max-height: 100%; width: auto; height: auto; display: block; box-shadow: 0 8px 24px #20242c18; }
.export-details dl { margin: 0 0 18px; font-size: 12px; }
.export-details dl div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
dt { color: var(--muted); } dd { margin: 0; font-weight: 500; }
.print-tip { font-size: 11px; color: var(--muted); }
.app-footer { display: flex; justify-content: space-between; gap: 20px; padding: 14px 24px; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); }
.busy-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 10px; background: #f2f4f7ef; border-radius: 10px; font-size: 12px; z-index: 1; }
.spinner { width: 18px; height: 18px; border: 2px solid #ced9f9; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
body[data-phase="empty"] main { max-width: 760px; }
body[data-phase="empty"] .workspace { grid-template-columns: 1fr; }
body[data-phase="empty"] .canvas-footer { display: none; }
@media screen and (min-width: 761px) and (min-height: 620px) {
  body:not([data-phase="empty"]) main { height: calc(100dvh - 104px); margin: 20px auto; display: flex; flex-direction: column; }
  body:not([data-phase="empty"]) .workspace { flex: 1; overflow: hidden; }
  .workspace-heading, .app-footer { flex-shrink: 0; }
}
@media screen and (min-width: 761px) and (max-height: 760px) {
  .workspace { padding: 18px; gap: 20px; }
  .workspace-heading { padding: 16px 22px; }
  .inspector-content { gap: 10px; }
  .enhance-option { margin-top: 10px; }
  .inspector-actions { padding-top: 12px; }
  .tool { min-height: 36px; }
  .app-footer { padding: 10px 22px; }
  body[data-phase="empty"] main { margin: 20px auto; }
  .upload-view { min-height: 240px; }
}
@media (max-width: 760px) {
  main { width: calc(100% - 24px); margin: 20px auto; }
  .workspace { grid-template-columns: 1fr; padding: 16px; gap: 22px; }
  .workspace-heading { padding: 18px; align-items: flex-start; }
  h1 { font-size: 19px; }
  .canvas-content { min-height: 340px; height: 45vh; }
  .inspector-content { overflow: visible; }
  .button { min-height: 44px; }
  .app-footer { padding: 12px 16px; font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media print {
  @page { size: A4 portrait; margin: 0; }
  body, main, .workspace, .canvas-panel, .canvas-content, .result-view { display: block; width: 210mm; height: 297mm; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; border-radius: 0; background: white; box-shadow: none; overflow: visible; }
  .appbar, .workspace-heading, .canvas-footer, .inspector, .app-footer, .upload-view, .crop-view, .busy-overlay, .status { display: none !important; }
  .result-view img { width: 210mm; height: 297mm; max-width: none; max-height: none; object-fit: contain; box-shadow: none; }
}
