@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

/* AI Stamp ID–aligned palette */
:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-subtle: #f9fafb;
  --text: #111827;
  --heading: #000000;
  --muted: #6b7280;
  --accent: #1a56db;
  --accent-hover: #1648c0;
  --accent-light: #ebf5ff;
  --link: #2563eb;
  --border: #d1d5db;
  --border-light: #e5e7eb;
  --danger: #dc2626;
  --success: #059669;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --maxw: min(1080px, 100vw);
  --page-max: 1400px;
  --page-pad-x: 1.5rem;
  --tool-menu-w: 280px;
}

* { box-sizing: border-box; }

/* The hidden attribute always hides, even on elements whose class sets a display
   (e.g. .tool-menu-row { display: flex } kept "Choose Folder" on screen). */
[hidden] { display: none !important; }

html {
  scrollbar-gutter: stable;
}

/* The tools' layouts need a computer-width page. Phones and small tablets
   (html.small-screen, set by js/screen-gate.js) get a notice instead. */
html:not(.small-screen) {
  min-width: 640px;
}

.small-screen-notice { display: none; }
html.small-screen .small-screen-notice { display: block; }
html.small-screen .tool-page,
html.small-screen .tool-tiles { display: none; }

.small-screen-notice:not(.small-screen-notice-inline) {
  max-width: 34rem;
  margin: 2.5rem auto;
  padding: 0 1.25rem;
}

.small-screen-notice h1 { font-size: 1.5rem; margin: 0 0 0.75rem; }
.small-screen-notice p { line-height: 1.6; color: var(--text); }

.small-screen-notice-inline {
  max-width: 40rem;
  width: calc(100% - 2rem);
  margin: 1.5rem auto 0;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 8px);
  background: #f9fafb;
  line-height: 1.55;
}

body {
  margin: 0;
  font-family: Inter, system-ui, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

body > main {
  flex: 1 0 auto;
}

a { color: var(--link); }

/* —— Header —— */
header.top {
  padding: 0.75rem 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border-light);
}

.page-shell {
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding-left: var(--page-pad-x);
  padding-right: var(--page-pad-x);
}

.site-columns {
  display: grid;
  grid-template-columns: var(--tool-menu-w) minmax(0, 1fr);
  column-gap: 1rem;
}

header.top .site-columns {
  align-items: center;
}

header.top .brand {
  grid-column: 1;
}

header.top .top-nav {
  grid-column: 2;
  justify-self: end;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--heading);
  min-width: 0;
}

.brand:hover {
  color: var(--heading);
  opacity: 0.92;
}

.brand-logo {
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  object-fit: contain;
}

.brand-text {
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.0125em;
  color: var(--heading);
}

@media (min-width: 640px) {
  .brand-logo {
    width: 2.5rem;
    height: 2.5rem;
  }
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
}

.nav-link:hover {
  color: var(--text);
  background: var(--panel-subtle);
}

.nav-link-active {
  background: var(--accent);
  color: #fff;
}

.nav-link-active:hover {
  background: var(--accent-hover);
  color: #fff;
}

.nav-auth {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.35rem;
}

.nav-auth-name {
  font-size: 0.82rem;
  color: var(--muted);
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button.nav-auth-btn {
  font: inherit;
  cursor: pointer;
  border: 0;
  background: transparent;
}

.nav-auth-login {
  font-weight: 600;
}

/* —— Layout —— */
main.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.5rem var(--page-pad-x) 2.5rem;
}

main.tool-page {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 1.5rem 0 2.5rem;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--heading);
  margin-top: 0;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--heading);
  margin: 0 0 0.5rem;
}

.lead {
  color: var(--muted);
  font-size: 1rem;
  max-width: 42rem;
}

.hint {
  font-size: 0.875rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

.hint code {
  background: var(--panel-subtle);
  border: 1px solid var(--border-light);
  padding: 0.12em 0.4em;
  border-radius: 4px;
  font-size: 0.88em;
  color: var(--text);
}

.callout {
  background: var(--accent-light);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  color: var(--text);
  font-size: 0.9rem;
  margin-top: 1.5rem;
}

.callout strong { color: var(--heading); }

.callout .tip-heading {
  margin: 0 0 0.35rem;
}

.callout .tip-steps {
  margin: 0;
  padding-left: 1.25rem;
}

.callout .tip-steps li {
  margin: 0.4rem 0;
}

.home-intro {
  text-align: center;
}

/* Demoted from h1 to h2 so "Color Matcher" can be the page's single h1;
   the h1 visual properties are restated here so nothing changes on screen. */
.home-intro h2 {
  max-width: 36rem;
  margin-left: auto;
  margin-right: auto;
  color: var(--accent);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.home-prose {
  max-width: 42rem;
  margin-left: auto;
  margin-right: auto;
  color: var(--text);
  text-align: center;
}

.home-prose p {
  margin: 0 0 1.15rem;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

.home-prose p.home-tagline {
  margin-bottom: 0;
  color: var(--text);
  font-weight: 500;
}

ul.actions {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 0;
}

ul.actions li {
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.95rem;
}

/* —— Buttons —— */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 500;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:hover {
  background: var(--panel-subtle);
  border-color: #9ca3af;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn.small { font-size: 0.85rem; padding: 0.35rem 0.7rem; }
.btn.disabled { opacity: 0.45; pointer-events: none; }

.flash {
  list-style: none;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  padding: 0.75rem 1rem;
  margin: 0 1rem;
  color: #92400e;
  border-radius: var(--radius-sm);
}

/* —— Forms —— */
form.stack fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--panel);
}

form.stack label { display: block; margin: 0.35rem 0; }
form.stack .sub { margin-left: 1rem; margin-top: 0.5rem; }
form.stack.tight label { margin: 0.5rem 0; }
form.stack input[type="range"] { width: 100%; max-width: 28rem; accent-color: var(--accent); }

label.file input { display: block; margin-top: 0.35rem; }

input[type="text"],
input[type="number"],
input[type="file"],
select {
  font-family: inherit;
  font-size: 0.92rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.5rem;
  background: var(--panel);
  color: var(--text);
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  outline: 2px solid var(--accent-light);
  border-color: var(--accent);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.toolbar a { color: var(--link); text-decoration: none; }
.toolbar a:hover { text-decoration: underline; }
.toolbar a.active { font-weight: 600; color: var(--accent); }
.toolbar .sep { opacity: 0.4; }

.options-panel { margin-bottom: 1rem; }

.option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.option-stack {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.option-stack label { display: block; margin: 0.2rem 0; font-size: 0.92rem; }
.option-stack .sub { margin-left: 1rem; margin-top: 0.35rem; }
.option-stack input[type="range"] { width: 100%; accent-color: var(--accent); }

.options-panel fieldset {
  border: none;
  border-radius: 0;
  padding: 0;
  margin: 0;
}

.options-panel fieldset legend {
  font-weight: 600;
  color: var(--heading);
  font-size: 0.95rem;
  padding: 0 0 0.5rem;
}

.options-panel fieldset label { display: block; margin: 0.35rem 0; }

.option-label {
  margin: 0 0 0.35rem;
  color: var(--heading);
  font-size: 0.88rem;
  font-weight: 600;
}

.toolbar-note {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

/* —— Preview —— */
.preview {
  text-align: left;
  margin: 0 0 1rem;
  max-width: 100%;
}

.preview canvas,
.preview img {
  max-width: 100%;
  max-height: min(70vh, 900px);
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.preview img {
  max-height: min(42vh, 800px);
}

/* —— Panels —— */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  margin-top: 1rem;
  box-shadow: var(--shadow);
}

nav.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

p.nav { margin: 0 0 1rem; }
p.nav a { color: var(--link); text-decoration: none; font-weight: 500; }
p.nav a:hover { text-decoration: underline; }
p.warn { color: var(--danger); }
p.hint { color: var(--muted); font-size: 0.88rem; margin: 0.5rem 0; }

ul.scan-list { font-size: 0.85rem; color: var(--muted); }
ul.scan-list li { margin: 0.35rem 0; }

span.ok { color: var(--success); margin-left: 0.35rem; }
span.bad { color: var(--danger); margin-left: 0.35rem; }

code {
  font-size: 0.9em;
  background: var(--panel-subtle);
  border: 1px solid var(--border-light);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

/* —— Tool pages (Color Matching + Extractor) —— */
.tool-layout {
  align-items: start;
}

.tool-layout.site-columns {
  grid-template-rows: auto 1fr;
  row-gap: 0.5rem;
}

.tool-page-title {
  grid-column: 1;
  grid-row: 1;
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--heading);
  letter-spacing: -0.02em;
}

.tool-layout > .tool-menu {
  grid-column: 1;
  grid-row: 2;
}

.tool-layout > .tool-canvas-wrap {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.tool-body {
  display: flex;
  flex-wrap: nowrap;
  gap: 1rem;
  align-items: flex-start;
}

.tool-menu {
  flex: 0 0 var(--tool-menu-w);
  width: var(--tool-menu-w);
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-width: 0;
  padding: 0;
  margin: 0;
  text-align: left;
  align-items: stretch;
  align-self: flex-start;
}

.tool-menu .hint {
  margin: 0;
  text-align: left;
}

.tool-main {
  flex: 1 1 auto;
  min-width: 0;
}

.tool-menu-row .btn {
  width: 100%;
}

.tool-menu-row-pair .btn {
  width: auto;
}

.tool-menu-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.tool-menu-row-stack {
  flex-direction: column;
  align-items: stretch;
}

.tool-menu-row-pair {
  flex-wrap: nowrap;
}

/* .btn sets display, which would otherwise override the hidden attribute. */
.btn[hidden] {
  display: none;
}

.tool-menu-row-pair .btn {
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
  padding-left: 0.45rem;
  padding-right: 0.45rem;
  font-size: 0.85rem;
}

.tool-menu-row-solo .btn {
  flex: 1 1 100%;
}

.tool-menu-row label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.92rem;
}

.tool-menu-row input[type="number"] {
  width: 4rem;
}

.tool-menu-section {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.tool-field-label {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  width: 100%;
  font-size: 0.92rem;
  font-weight: 500;
}

.tool-field-label input[type="text"],
.tool-field-label input[type="file"] {
  width: 100%;
}

.tool-radio {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0.35rem 0;
  padding: 0;
  font-size: 0.92rem;
  text-align: left;
}

.tool-section-label {
  margin: 0 0 0.25rem;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--heading);
}

.tool-range {
  display: block;
  margin: 0.35rem 0;
  font-size: 0.92rem;
}

.tool-range input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.tool-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  width: 100%;
}

.tool-status,
.workspace-status {
  margin: 0;
  font-size: 0.82rem;
}

.tool-menu .tool-status {
  width: 100%;
}

.tool-tip {
  margin: 0;
  font-size: 0.85rem;
}

.tool-tip .tip-steps {
  margin: 0.35rem 0 0;
  padding-left: 1.15rem;
}

.gauge-slot {
  margin: 0;
  padding: 0;
}

.palette-radio-title {
  white-space: nowrap;
}

.chart-inline-hint {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 400;
}

.chart-subtext {
  margin: 0.15rem 0 0.35rem;
  font-size: 0.82rem;
}

.match-results {
  margin: 0;
}

.match-results h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
}

.match-results p {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.tool-page input[type="file"] {
  border: none;
  padding-left: 0;
  background: transparent;
  font-size: 0.92rem;
}

.tool-canvas-wrap {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  min-height: calc(100vh - 120px);
}

.tool-canvas-wrap canvas {
  display: block;
  max-width: 100%;
  border: none;
  box-shadow: none;
}

.preview-panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  max-width: 100%;
}

.preview-canvas-stage {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
  line-height: 0;
}

.preview-canvas-pickable {
  cursor: none;
}

/* The colour overlay can be dragged (match-app.js wireOverlayDrag). */
.preview-canvas-pickable.overlay-grab {
  cursor: grab;
}

.preview-canvas-pickable.overlay-dragging {
  cursor: grabbing;
}

.pick-target-box {
  position: absolute;
  box-sizing: border-box;
  pointer-events: none;
  border: 2px solid rgba(255, 255, 255, 0.95);
  outline: 1px solid var(--accent);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  min-width: 4px;
  min-height: 4px;
}

.color-inspector {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-light);
}

.color-inspector-hint {
  margin: 0 0 0.65rem;
  font-size: 0.82rem;
}

.color-inspector-size,
.extract-pick-size,
.overlay-pos-range {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.65rem;
  font-size: 0.88rem;
}

.overlay-pos-range {
  margin: 0.35rem 0;
}

.color-inspector-size input[type="range"],
.extract-pick-size input[type="range"],
.overlay-pos-range input[type="range"] {
  flex: 1 1 auto;
  min-width: 2.5rem;
  width: auto;
}

.color-inspector-size input[type="range"],
.extract-pick-size input[type="range"] {
  max-width: 5.5rem;
}

.sample-box-label {
  flex: 0 0 auto;
  white-space: nowrap;
}

.sample-box-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 0.65rem;
}

.sample-box-row .color-inspector-size,
.sample-box-row .extract-pick-size {
  margin-bottom: 0;
  flex: 0 1 auto;
  min-width: 0;
}

.pick-box-outline-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
  padding: 0;
  font-size: 0.82rem;
  white-space: nowrap;
  cursor: pointer;
  flex: 0 0 auto;
}

.pick-box-outline-toggle input {
  accent-color: var(--accent);
}

.color-inspector-size-label {
  flex: 0 0 auto;
  min-width: 2.25rem;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  color: var(--heading);
}

.color-inspector-picked {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 0;
}

.inspector-match-row {
  --inspector-swatch-box: 5rem;
  display: flex;
  align-items: flex-start;
  gap: 0;
  margin-bottom: 0.85rem;
}

.inspector-pick-col {
  flex: 0 1 auto;
  min-width: 0;
}

.inspector-match-separator {
  flex: 0 0 1px;
  width: 1px;
  align-self: stretch;
  margin: 0 0.45rem;
  background: var(--border-light);
}

.inspector-match-col {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 0.5rem;
  min-width: 0;
}

.match-preview-box-row {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
}

.match-preview-meta {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.match-preview-rgb,
.match-preview-distance {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.35;
  white-space: nowrap;
  color: var(--heading);
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
}

.match-overlay-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 var(--inspector-swatch-box);
  width: var(--inspector-swatch-box);
  height: var(--inspector-swatch-box);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-subtle);
  overflow: hidden;
}

.match-overlay-preview canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.match-preview-rgb-label {
  font-family: var(--font, inherit);
  font-weight: 600;
  color: var(--muted);
  font-size: 0.78rem;
}

.match-preview-name {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.35;
  text-align: left;
  white-space: nowrap;
  color: var(--heading);
  font-weight: 600;
}

.color-swatch-lg {
  flex: 0 0 var(--inspector-swatch-box, 5rem);
  width: var(--inspector-swatch-box, 5rem);
  height: var(--inspector-swatch-box, 5rem);
  min-height: var(--inspector-swatch-box, 5rem);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel-subtle);
}

.color-inspector-codes {
  flex: 1 1 auto;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.88rem;
}

.color-code-row {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
}

.color-inspector-codes dt {
  flex: 0 0 2.25rem;
  margin: 0;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.78rem;
}

.color-inspector-codes dd {
  margin: 0;
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
  font-size: 0.85rem;
  color: var(--heading);
  user-select: all;
}

.color-palette-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.color-palette-chip {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.color-palette-chip:hover {
  transform: scale(1.06);
}

.color-palette-chip-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.preview-controls {
  margin-top: 0.85rem;
}

.overlay-mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  align-items: center;
}

.overlay-mode-row .tool-radio {
  margin: 0;
}

.tool-skip-link {
  display: none;
  margin: 0 0 0.5rem;
  font-size: 0.92rem;
}

.tool-skip-link:not([hidden]) {
  display: inline-block;
}

#preview-canvas {
  max-width: 100%;
}

#extract-canvas {
  background: var(--bg);
  max-width: 100%;
  max-height: calc(100vh - 160px);
  touch-action: none;
  cursor: crosshair;
  display: block;
}

#match-controls {
  width: 100%;
  padding: 0;
  margin: 0;
}

#match-controls:not([hidden]),
.preview-controls:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

#match-controls .tool-menu-row {
  width: 100%;
}

.tool-nav .btn {
  flex: 1 1 0;
  min-width: 0;
}

@media (max-width: 900px) {
  .tool-layout.site-columns {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  .tool-page-title {
    grid-column: 1;
    grid-row: 1;
  }

  .tool-layout > .tool-menu {
    grid-column: 1;
    grid-row: 2;
    width: 100%;
    max-width: none;
  }

  .tool-layout > .tool-canvas-wrap {
    grid-column: 1;
    grid-row: 3;
  }

  .tool-body {
    flex-wrap: wrap;
    flex-direction: column;
  }

  .tool-menu {
    flex: 1 1 100%;
    width: 100%;
  }

  .tool-canvas-wrap {
    min-height: 0;
    width: 100%;
  }
}

@media (max-width: 860px) {
  header.top .site-columns {
    grid-template-columns: 1fr;
    row-gap: 0.75rem;
  }

  header.top .brand,
  header.top .top-nav {
    grid-column: 1;
    justify-self: start;
  }
}

/* —— Site footer (mirrors the app's /stamp footer: DashboardFooter + GlobalFooter) —— */
.site-color-attribution {
  margin: 2rem 0 0;
  padding: 0 1rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
}

.site-color-attribution a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.site-color-attribution a:hover {
  color: var(--accent);
}

.site-footer {
  flex-shrink: 0;
  width: 100%;
  margin-top: 1.25rem;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
  color: #6b7280;
}

.site-footer p {
  margin: 0;
}

.site-social {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.site-social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2rem;
  padding: 0.5rem;
  border-radius: 0.375rem;
  color: #6b7280;
  text-decoration: none;
  transition: color 0.15s ease, background 0.15s ease;
}

.site-social-link:hover {
  background: #f3f4f6;
}

.site-social-facebook:hover { color: #2563eb; }
.site-social-instagram:hover { color: #db2777; }
.site-social-linkedin:hover { color: #1d4ed8; }
.site-social-youtube:hover { color: #dc2626; }

.site-social-link svg {
  width: 1.25rem;
  height: 1.25rem;
}

.site-footer-mail {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.site-footer-mail svg {
  width: 1rem;
  height: 1rem;
}

.site-footer-mail a {
  color: #6b7280;
  text-decoration: none;
  transition: color 0.15s ease;
}

.site-footer-mail a:hover {
  color: #374151;
}

.site-footer-version {
  font-size: 0.875rem;
}

.site-footer-copy {
  flex-shrink: 0;
  width: 100%;
  border-top: 1px solid #f3f4f6;
  background: #fff;
  padding: 1rem;
  text-align: center;
  font-size: 0.75rem;
  color: #6b7280;
}

.site-footer-copy p {
  margin: 0;
}

ter-copy {
    font-size: 0.75rem;
  }
}

/* —— Login (mirrors www.aistampid.com/login) —— */
html.login-page {
  min-width: 0;
}

body.login-page {
  background: #f3f4f6;
  min-height: 100vh;
}

.login-shell {
  min-height: calc(100vh - 56px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 448px;
  background: #fff;
  border: 0;
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
  padding: 1.5rem;
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.2rem;
}

.login-brand-logo {
  width: 220px;
  height: auto;
  max-width: 100%;
  object-fit: contain;
}

.login-title {
  margin: 0 0 0.25rem;
  text-align: center;
  font-size: 1.125rem;
  font-weight: 700;
  color: #111827;
}

.login-version {
  margin: 0 0 1rem;
  text-align: center;
  font-size: 0.875rem;
  color: #6b7280;
}

.login-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #111827;
  margin: 0 0 0.35rem;
}

.login-label + .login-input,
.login-password-wrap {
  margin-bottom: 0.75rem;
}

.login-label .req {
  color: #dc2626;
}

.login-input {
  width: 100%;
  height: 2.25rem;
  padding: 0.25rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font: inherit;
  font-size: 1rem;
  line-height: 1.5rem;
  background: #fff;
}

.login-input:focus {
  outline: 3px solid rgba(37, 99, 235, 0.22);
  outline-offset: 0;
  border-color: #2563eb;
}

.login-password-wrap {
  position: relative;
}

.login-password-wrap .login-input {
  margin: 0;
  padding-right: 2.5rem;
}

.login-eye {
  position: absolute;
  right: 0.4rem;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  padding: 0.25rem;
}

.login-forgot-row {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 0.9rem;
}

.login-text-btn {
  border: 0;
  background: none;
  color: #2563eb;
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  padding: 0;
}

.login-text-btn:hover,
.login-signup a:hover {
  text-decoration: underline;
}

.login-error,
.login-ok {
  margin: 0 0 0.65rem;
  font-size: 0.88rem;
}

.login-error {
  color: #dc2626;
}

.login-ok {
  color: #059669;
}

.login-submit {
  width: 100%;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(90deg, #2f47c7 0%, #3f2ba8 100%);
  color: #fff;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.login-submit:hover {
  filter: brightness(0.95);
}

.login-submit:disabled {
  opacity: 0.7;
  cursor: wait;
}

.login-submit svg {
  width: 1rem;
  height: 1rem;
}

.login-signup {
  text-align: center;
  margin: 0.9rem 0 0;
  font-size: 0.875rem;
  color: #111827;
}

.login-signup a {
  color: #2563eb;
  text-decoration: none;
}

#login-oauth {
  margin-top: 1.1rem;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 0.9rem;
  color: #6b7280;
  font-size: 0.875rem;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e5e7eb;
}

.login-social {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.login-apple,
.login-google {
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.login-apple {
  background: #000;
  color: #fff;
  border: 0;
}

.login-google {
  background: #fff;
  color: #3c4043;
  border: 1px solid #dadce0;
}

.login-forgot-copy {
  margin: 0 0 0.6rem;
  font-size: 0.9rem;
  color: #4b5563;
}

.login-footer-copy {
  text-align: center;
  padding: 0 1rem 1.5rem;
  color: #6b7280;
}

/* ===================================================================
   Home tool tiles - values copied verbatim from the /stamp scan panels
   (computed styles off the live page). Left panel: blue-900 -> black
   gradient, 2px dashed #e5e7eb, rounded on the outer edge only. Right
   panel: solid black, no border, no radius - the dashed seam between
   them is the left panel's right border, exactly as on /stamp.
   =================================================================== */
/* Section heading above the tiles - matches the "Stamp Scanner" heading
   on /stamp (30px/700/36px over a 16px muted subtitle, both centred). */
.tool-tiles-heading {
  max-width: 670px;
  margin: 0 auto 24px;
  text-align: center;
}

.tool-tiles-heading h1 {
  font-size: 30px;
  font-weight: 700;
  line-height: 36px;
  color: lab(2.75381 0 0);
  letter-spacing: normal;
  margin: 0 0 16px;
}

.tool-tiles-heading p {
  font-size: 16px;
  font-weight: 400;
  line-height: 24px;
  color: lab(48.496 0 0);
  margin: 0;
}

/* body is display:flex, so this must claim full width before max-width caps it. */
.tool-tiles-wrap {
  width: 100%;
  padding: 1.75rem var(--page-pad-x, 1.5rem) 0;
}

/* 670px = the /stamp grid width exactly (2 x 335px panels, no gap). */
.tool-tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  max-width: 670px;
  margin: 0 auto;
}

a.tool-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  height: min(60vh, 420px);
  min-height: 260px;
  text-align: center;
  text-decoration: none;
  color: #fff;
  font-size: 16px;
  font-weight: 400;
  line-height: 24px;
  cursor: pointer;
  transition:
    color 0.15s cubic-bezier(0.4, 0, 0.2, 1),
    background-color 0.15s cubic-bezier(0.4, 0, 0.2, 1),
    border-color 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Left: matches the drag-and-drop panel. */
a.tool-tile:first-child {
  padding: 24px;
  border: 2px dashed #e5e7eb;
  border-radius: 10px 0 0 10px;
  background-image: linear-gradient(to right bottom, #1e3a8a 0%, #000 100%);
}

/* Right: matches the camera panel - solid black, borderless, square. */
a.tool-tile:last-child {
  padding: 0 24px;
  border: 0;
  border-radius: 0;
  background-color: #000;
}

.tool-tile-icon {
  width: 64px;
  height: 64px;
  stroke: #fff;
  stroke-width: 2;
  flex-shrink: 0;
}

.tool-tile-label { color: #fff; }

a.tool-tile:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* /stamp stacks to one column below md and hides the camera panel below sm. */
@media (max-width: 767px) {
  .tool-tiles { grid-template-columns: 1fr; }
}

/* ===================================================================
   App navbar for the static colour pages - mirrors DashboardNavbar.tsx
   (Scan / Collection / Color Match / About) so these pages keep the
   main app's shell. Values taken from the live /stamp navbar.
   Absolute hrefs, so <base href="/color/"> does not rewrite them.
   =================================================================== */
.app-nav {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
}

.app-nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.app-nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  flex-shrink: 0;
}

.app-nav-brand span {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0000af;
  white-space: nowrap;
}

.app-nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.app-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 120ms ease;
}

.app-nav-link:hover { background: #f3f4f6; }

.app-nav-link svg { width: 16px; height: 16px; flex-shrink: 0; }

.app-nav-link-active,
.app-nav-link-active:hover {
  color: #fff;
  background: linear-gradient(
    90deg,
    oklch(0.4 0.3 240) 0%,
    color-mix(in srgb, oklch(0.4 0.3 240), black 20%) 100%
  );
}

.app-nav-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Settings menu - mirrors the gear + DropdownMenu in DashboardNavbar.tsx.
   #nav-auth is mounted inside the panel by auth-header.js, so the Log In /
   Log Out control lives where the app puts Logout. */
.app-nav-menu { position: relative; display: flex; align-items: center; justify-content: flex-end; width: 150px; }

.app-nav-menu-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: #374151;
}

.app-nav-menu-trigger svg { width: 24px; height: 24px; }

.app-nav-menu-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.app-nav-menu-panel {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 12rem;
  padding: 0.25rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 6px);
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  z-index: 50;
}

.app-nav-menu-item,
.app-nav-menu-panel .nav-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 0;
  border-radius: 4px;
  background: none;
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.app-nav-menu-item:hover,
.app-nav-menu-panel .nav-link:hover { background: #f3f4f6; }

.app-nav-menu-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.app-nav-menu-sep { height: 1px; margin: 0.25rem 0; background: var(--border-light); }

/* Signed-in name sits above the actions, like the app's menu header. */
.app-nav-menu-panel .nav-auth {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.15rem;
}

.app-nav-menu-panel .nav-auth-name {
  padding: 0.4rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

/* The app shell is desktop-only, matching DashboardNavbar's `hidden md:flex`
   and the colour tools' own "designed for use on a computer" notice. */
@media (max-width: 767px) {
  .app-nav-links { display: none; }
  /* Brand + settings must fit a 360px phone. */
  .app-nav-menu { width: auto; }
  .app-nav-brand span { font-size: 1.25rem; }
}

/* ===================================================================
   Match a Stamp: "From My Collection" picker (js/collection-picker.js)
   =================================================================== */
.collection-dialog {
  width: min(56rem, calc(100vw - 2rem));
  max-height: calc(100vh - 3rem);
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 40px rgb(0 0 0 / 0.18);
  color: var(--text);
}

.collection-dialog::backdrop { background: rgb(17 24 39 / 0.45); }

.collection-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.collection-head h2 { margin: 0; font-size: 1.25rem; }

.collection-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.5rem;
  margin-top: 1rem;
}

#collection-search {
  flex: 1 1 16rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
}

.collection-source {
  display: flex;
  gap: 1rem;
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 0.92rem;
}

.collection-source legend { float: left; margin-right: 0.25rem; font-weight: 600; }

.collection-note { margin: 0.75rem 0 0; }

.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.collection-tile {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.5rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--panel-subtle);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.collection-tile:hover,
.collection-tile:focus-visible { border-color: var(--accent); background: var(--accent-light); outline: none; }

.collection-tile:disabled { cursor: progress; opacity: 0.6; }

.collection-tile-loading { opacity: 1 !important; border-color: var(--accent); }

.collection-tile img,
.collection-tile-missing {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #fff;
  border-radius: 4px;
}

.collection-tile-missing {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.8rem;
}

.collection-tile-name {
  font-size: 0.82rem;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collection-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
}
