/* Private PDF Toolkit — ToolNest design tokens (day1/design/design-spec.md) */

:root {
  --bg: #F7F5F0;
  --surface: #FFFFFF;
  --surface-muted: #EFF2EE;
  --ink: #17211D;
  --muted: #4E5D55;
  --border: #D8DFD9;
  --primary: #0B6B57;
  --primary-dark: #084E3F;
  --primary-soft: #E2EFEA;
  --accent: #F2A93B;
  --success: #177245;
  --success-bg: #E5F3EA;
  --danger: #B3261E;
  --danger-bg: #FBEAE8;
  --warning: #8A5A00;
  --warning-bg: #FFF3DC;
  --stage: #1C2420;
  --focus: #0B6B57;
  --radius-card: 16px;
  --radius-control: 10px;
  --shadow-card: 0 1px 2px rgba(23, 33, 29, .06), 0 4px 16px rgba(23, 33, 29, .06);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.icon { width: 20px; height: 20px; flex: none; }

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  padding-bottom: 10px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { flex: none; }
.brand-name { font-weight: 700; font-size: 19px; letter-spacing: -0.01em; }
.brand-tool { color: var(--muted); font-size: 15px; }
.header-help {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  padding: 10px 8px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.header-help:hover { text-decoration: underline; }

/* Hero */
.hero { padding: 24px 0 8px; }
.hero h1 {
  font-size: 28px;
  line-height: 1.2;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}
.hero-sub { margin: 0 0 12px; color: var(--muted); max-width: 56ch; }
.privacy-line {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 0;
  font-weight: 600;
  color: var(--primary-dark);
}
.privacy-line .icon { margin-top: 2px; }
.shortcuts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 16px;
  margin-top: 16px;
}
.step-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 16px; }
.step-chip {
  flex: none;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #FFFFFF;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}
.step-head h2 { font-size: 19px; line-height: 1.3; margin: 0; }
.step-purpose { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
h3 { font-size: 16px; }

/* Buttons */
.btn {
  font: inherit;
  font-weight: 600;
  border-radius: var(--radius-control);
  border: 1.5px solid transparent;
  min-height: 48px;
  padding: 10px 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color .12s ease, border-color .12s ease, opacity .12s ease;
}
.btn-primary { background: var(--primary); color: #FFFFFF; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-primary:active:not(:disabled) { transform: scale(.99); }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--ink); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-muted); }
.btn-danger-quiet { background: var(--surface); border-color: var(--border); color: var(--danger); }
.btn-danger-quiet:hover:not(:disabled) { background: var(--danger-bg); }
.btn-block { width: 100%; }
.btn-small { min-height: 44px; padding: 8px 14px; font-size: 15px; }
.btn:disabled {
  background: var(--surface-muted);
  border-color: var(--border);
  color: var(--muted);
  cursor: not-allowed;
}
.spinner {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255, 255, 255, .35);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--primary);
  background: var(--primary-soft);
  border-radius: var(--radius-card);
  padding: 24px 16px;
  text-align: center;
  transition: background-color .12s ease, border-color .12s ease;
}
.drop-zone.drag-over {
  border-style: solid;
  background: #CDE6DC;
}
.drop-icon { width: 44px; height: 44px; color: var(--primary); }
.drop-text { font-weight: 700; font-size: 18px; margin: 8px 0 12px; }
.hint { color: var(--muted); font-size: 14px; margin: 8px 0 0; }
.drop-zone .hint { margin-top: 12px; }

.privacy-statement {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 14px;
  color: var(--muted);
  margin: 16px 0 0;
}
.privacy-statement .icon { margin-top: 1px; color: var(--primary); }

/* Banners */
.banner {
  border-radius: var(--radius-control);
  padding: 12px 14px;
  margin-top: 12px;
  font-size: 15px;
}
.banner p { margin: 0; }
.banner-error { background: var(--danger-bg); color: var(--ink); border: 1px solid #EFC4C0; }
.banner-warning { background: var(--warning-bg); color: var(--ink); border: 1px solid #EDD9AC; }
.banner-success { background: var(--success-bg); color: var(--ink); border: 1px solid #BFE0CC; }
.banner-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.banner .btn { margin-top: 10px; }
.banner-actions .btn { margin-top: 0; }

.file-errors { margin-top: 12px; display: grid; gap: 8px; }
.file-error-item {
  background: var(--danger-bg);
  border: 1px solid #EFC4C0;
  border-radius: var(--radius-control);
  padding: 10px 12px;
  font-size: 15px;
}
.file-error-item .file-error-name { font-weight: 600; overflow-wrap: anywhere; }

/* File list */
.file-list { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; }
.file-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  padding: 12px;
  min-width: 0;
}
.file-icon { flex: none; width: 28px; height: 28px; color: var(--primary); margin-top: 2px; }
.file-meta { flex: 1 1 160px; min-width: 0; }
.file-name { font-weight: 600; margin: 0; overflow-wrap: anywhere; }
.file-detail { color: var(--muted); font-size: 14px; margin: 2px 0 0; overflow-wrap: anywhere; }
.file-thumb {
  width: 56px; height: 56px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  flex: none;
}
.add-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* Forms */
.field { margin-bottom: 16px; }
.field label, .group legend {
  display: block;
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 6px;
  padding: 0;
}
.input {
  font: inherit;
  font-size: 16px;
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--ink);
}
.input:focus { border-color: var(--primary); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 14px; margin: 6px 0 0; }

.group { border: 0; margin: 0 0 20px; padding: 0; min-width: 0; }
.group legend { margin-bottom: 8px; }
.radio-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.radio-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 15px;
  background: var(--surface);
}
.radio-pill input { width: 18px; height: 18px; accent-color: var(--primary); margin: 0; flex: none; }
.radio-pill:has(input:checked) {
  background: var(--primary-soft);
  border-color: var(--primary);
  font-weight: 600;
}
.radio-pill:has(input:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.range-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: stretch; }
.range-row .input { min-width: 0; }

/* Toolbar & readouts */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.readout {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  margin: 0 0 12px;
}
.crop-empty {
  background: var(--surface-muted);
  border-radius: var(--radius-control);
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
  margin: 0;
}

/* Page tiles */
.tile-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}
.tile {
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--surface);
  min-width: 0;
}
.tile.is-selected { border-color: var(--primary); background: var(--primary-soft); }
.tile.drag-over { border-color: var(--primary); border-style: dashed; }
.tile-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.tile-position {
  flex: none;
  min-width: 32px; height: 32px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--primary);
  color: #FFFFFF;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}
.tile-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
}
.tile-check input { width: 22px; height: 22px; accent-color: var(--primary); margin: 0; flex: none; }
.tile-drag-hint { margin-left: auto; color: var(--muted); font-size: 13px; }
.tile-preview {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  background: var(--stage);
  border-radius: 8px;
  margin-bottom: 8px;
}
.tile-origin { font-weight: 600; margin: 0; overflow-wrap: anywhere; }
.tile-detail { color: var(--muted); font-size: 14px; margin: 2px 0 0; overflow-wrap: anywhere; }
.tile-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.tile-btn {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tile-btn:hover:not(:disabled) { background: var(--surface-muted); }
.tile-btn:disabled { color: var(--muted); background: var(--surface-muted); cursor: not-allowed; }
.tile-btn .icon { width: 16px; height: 16px; }
.tile-btn-danger { color: var(--danger); }
.tile-btn-danger:hover:not(:disabled) { background: var(--danger-bg); }

/* Create / output */
.create-actions { display: grid; gap: 8px; }
.output-title { margin: 20px 0 8px; }
.output-summary { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 6px; }
.output-summary li {
  background: var(--surface-muted);
  border-radius: var(--radius-control);
  padding: 10px 12px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.output-summary .summary-label { font-weight: 600; }

/* Help */
.help-card { margin-top: 16px; }
.help-card h2 { font-size: 19px; margin: 0 0 8px; }
.help-card details { border-top: 1px solid var(--border); }
.help-card summary {
  font-weight: 600;
  padding: 14px 4px;
  cursor: pointer;
  min-height: 44px;
}
.help-card details p { margin: 0 4px 16px; color: var(--ink); max-width: 68ch; }

.site-footer {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  padding: 24px 0 32px;
}

/* Tablet */
@media (min-width: 720px) {
  .hero h1 { font-size: 32px; }
  .card { padding: 24px; }
  .tile-list { grid-template-columns: 1fr 1fr; }
  .create-actions { grid-template-columns: 1fr 1fr; }
}

/* Desktop */
@media (min-width: 1024px) {
  .wrap { max-width: 1080px; }
  .tile-list { grid-template-columns: 1fr 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  .btn, .drop-zone { transition: none; }
}
