:root,
:root[data-theme="dark"] {
  --bg: #1a1a1a;
  --bg-soft: #222222;
  --bg-gradient-top: #1f1f1f;
  --panel: #2d2d2d;
  --panel-strong: #343434;
  --chip-bg: #202020;
  --line: #3d3d3d;
  --line-soft: #4b4b4b;
  --ink: #d4d4d4;
  --ink-strong: #f3f0ea;
  --muted: #a3a3a3;
  --muted-soft: #747474;
  --accent: #5d7a66;
  --accent-strong: #7a9a82;
  --accent-ink: #f7fbf4;
  --cream: #f4efe6;
  --good: #43d17a;
  --warn: #ffce4d;
  --bad: #ff6b6b;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  --overlay-veil: rgba(26, 26, 26, .82);
  --field-bg: rgba(45, 45, 45, 0.94);
  --card-bg: rgba(45, 45, 45, 0.88);
  --card-bg-hover: #303030;
  --preview-bg: #242424;
  --surface-faint: rgba(45, 45, 45, 0.42);
  --track-bg: #232323;
  --divider-faint: #252525;
  --inset-highlight: rgba(255, 255, 255, 0.04);
  --card-shadow-top: rgba(255, 255, 255, 0.02);
  --soft-shadow: rgba(0, 0, 0, 0.12);
  --scrollbar-track: #1f1f1f;
  --scrollbar-thumb: #4b4b4b;
  --scrollbar-thumb-hover: #5d5d5d;
}
:root[data-theme="light"] {
  --bg: #f4f2ee;
  --bg-soft: #ffffff;
  --bg-gradient-top: #ffffff;
  --panel: #ffffff;
  --panel-strong: #f1efea;
  --chip-bg: #eceae4;
  --line: #d9d5cd;
  --line-soft: #c5c0b6;
  --ink: #2c2c2c;
  --ink-strong: #1a1a1a;
  --muted: #6b6b6b;
  --muted-soft: #9a9a9a;
  --accent: #5d7a66;
  --accent-strong: #45624e;
  --accent-ink: #f7fbf4;
  --cream: #f4efe6;
  --good: #1f9d57;
  --warn: #c98a00;
  --bad: #d6453f;
  --shadow: 0 24px 70px rgba(60, 60, 60, 0.16);
  --overlay-veil: rgba(244, 242, 238, .82);
  --field-bg: #ffffff;
  --card-bg: #ffffff;
  --card-bg-hover: #fbfaf7;
  --preview-bg: #e7e4dd;
  --surface-faint: rgba(255, 255, 255, 0.6);
  --track-bg: #ddd9d0;
  --divider-faint: #e7e4dd;
  --inset-highlight: rgba(255, 255, 255, 0.6);
  --card-shadow-top: rgba(0, 0, 0, 0.02);
  --soft-shadow: rgba(60, 60, 60, 0.12);
  --scrollbar-track: #e7e4dd;
  --scrollbar-thumb: #c5c0b6;
  --scrollbar-thumb-hover: #aba596;
}
* { box-sizing: border-box; }

/* Scrollbars — themed */
* { scrollbar-width: thin; scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track); }
*::-webkit-scrollbar { width: 12px; height: 12px; }
*::-webkit-scrollbar-track { background: var(--scrollbar-track); }
*::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border: 3px solid var(--scrollbar-track); border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }
*::-webkit-scrollbar-corner { background: var(--scrollbar-track); }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink); font: 14px/1.45 Manrope, Inter, ui-sans-serif, system-ui, Segoe UI, sans-serif;
  display: flex; flex-direction: column;
}
header {
  min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 18px;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
header .brand { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.brand-home {
  appearance: none; margin: 0; padding: 4px 6px; border: 0; border-radius: 10px;
  background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.brand-home:hover { background: rgba(93, 122, 102, 0.14); }
.brand-home:hover h1 { color: var(--accent-strong); }
.brand-home:focus-visible { outline: 0; box-shadow: 0 0 0 3px rgba(122, 154, 130, .28); }
header h1 { font-size: 16px; margin: 0; font-weight: 650; color: var(--ink-strong); white-space: nowrap; }
header .tag { color: var(--muted); font-size: 12px; }
.header-actions { display: flex; align-items: center; gap: 10px; min-width: 0; }
.back-button {
  background: rgba(93, 122, 102, 0.14); color: var(--accent-strong); border: 1px solid rgba(122, 154, 130, 0.24);
  border-radius: 999px; padding: 7px 12px; font-size: 12px; font-weight: 650; cursor: pointer; transition: .15s;
}
.back-button:hover { background: rgba(93, 122, 102, 0.24); color: var(--accent-ink); }
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
  background: var(--chip-bg); color: var(--muted); border: 1px solid var(--line); border-radius: 999px;
  cursor: pointer; transition: .15s; flex: 0 0 auto;
}
.theme-toggle:hover { color: var(--ink-strong); border-color: var(--line-soft); }
.theme-toggle-icon { position: relative; width: 16px; height: 16px; display: block; }
/* Moon (shown in dark mode) */
.theme-toggle-icon::before {
  content: ""; position: absolute; inset: 1px; border-radius: 50%;
  box-shadow: inset -4px -2px 0 0 currentColor;
}
/* Sun (shown in light mode) */
.theme-toggle-icon::after {
  content: ""; position: absolute; inset: 3px; border-radius: 50%;
  background: currentColor; opacity: 0;
}
:root[data-theme="light"] .theme-toggle-icon::before { opacity: 0; }
:root[data-theme="light"] .theme-toggle-icon::after { opacity: 1; box-shadow: 0 0 0 2px var(--panel), 0 -7px 0 -3px currentColor, 0 7px 0 -3px currentColor, -7px 0 0 -3px currentColor, 7px 0 0 -3px currentColor; }
.project-chip {
  appearance: none; cursor: pointer; font: inherit;
  max-width: min(42vw, 360px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--ink); background: var(--chip-bg); border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 12px; font-size: 12px; transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.project-chip:hover { background: rgba(93, 122, 102, 0.16); border-color: rgba(122, 154, 130, 0.44); color: var(--ink-strong); }
.project-chip:focus-visible { outline: 0; box-shadow: 0 0 0 3px rgba(122, 154, 130, .28); border-color: var(--accent-strong); }
.is-hidden { display: none !important; }

#app { flex: 1; display: flex; min-height: 0; }

.gallery {
  flex: 1; overflow: auto; background:
    radial-gradient(circle at 24% 0%, rgba(122, 154, 130, 0.12), transparent 30%),
    linear-gradient(180deg, var(--bg-gradient-top) 0%, var(--bg) 54%);
}
.gallery-shell {
  width: min(1440px, calc(100% - 48px)); margin: 0 auto; padding: 34px 0 44px;
}
.gallery-header {
  display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 10px;
}
.eyebrow {
  margin: 0 0 6px; color: var(--accent-strong); font-size: 11px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase;
}
.gallery h2 {
  margin: 0; color: var(--ink-strong); font-size: clamp(30px, 4vw, 46px); line-height: 1; font-weight: 680; letter-spacing: 0;
}
.gallery-meta {
  display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin-bottom: 24px;
}
.gallery-meta span + span::before { content: ""; display: inline-block; width: 4px; height: 4px; border-radius: 50%; background: var(--muted-soft); margin: 0 10px 2px 0; }
.gallery-actions {
  display: flex; align-items: center; gap: 10px;
}
.project-search {
  width: min(340px, 42vw); height: 40px; display: flex; align-items: center; gap: 9px; padding: 0 13px;
  background: var(--field-bg); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px var(--soft-shadow);
}
.project-search .search-icon { width: 16px; height: 16px; flex: 0 0 auto; color: var(--muted-soft); display: block; }
.project-search input {
  width: 100%; min-width: 0; background: transparent; color: var(--ink); border: 0; outline: 0; font: inherit; font-size: 13px;
}
.project-search input::placeholder { color: var(--muted-soft); }
.new-project-button,
.new-project-actions button {
  height: 40px; border: 1px solid rgba(122, 154, 130, 0.34); border-radius: 12px; padding: 0 15px;
  background: #5d7a66; color: white; font: inherit; font-size: 13px; font-weight: 680; cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.new-project-button:hover,
.new-project-actions button:hover { background: #6f8b76; border-color: rgba(122, 154, 130, 0.62); }
.new-project-button:active,
.new-project-actions button:active { transform: translateY(1px); }
.project-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px;
}
.project-card {
  appearance: none; border: 1px solid var(--line); padding: 0; text-align: left; color: inherit; cursor: pointer;
  background: var(--card-bg); border-radius: 16px; overflow: hidden; box-shadow: 0 1px 0 var(--card-shadow-top);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.project-card:hover, .project-card:focus-visible {
  transform: translateY(-3px); border-color: rgba(122, 154, 130, 0.72); background: var(--card-bg-hover); box-shadow: var(--shadow); outline: 0;
}
.project-card:focus-visible { box-shadow: 0 0 0 3px rgba(122, 154, 130, .28), var(--shadow); }
.project-preview {
  position: relative; aspect-ratio: 1.34; background: var(--preview-bg); overflow: hidden; border-bottom: 1px solid var(--line);
}
.project-preview img {
  display: block; width: 100%; height: 100%; object-fit: cover; transform: scale(1.002); transition: transform .22s ease, filter .22s ease;
}
.project-card:hover .project-preview img { transform: scale(1.035); filter: saturate(1.05); }
.project-status {
  position: absolute; top: 12px; right: 12px; z-index: 2; border-radius: 999px; padding: 5px 9px;
  background: rgba(26, 26, 26, 0.74); border: 1px solid rgba(255,255,255,.12); color: #f3f0ea;
  font-size: 10px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; backdrop-filter: blur(10px);
}
.project-body { padding: 14px 15px 15px; }
.project-name {
  margin: 0; color: var(--ink-strong); font-size: 16px; line-height: 1.25; font-weight: 680; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.project-detail {
  display: flex; align-items: center; gap: 8px; margin-top: 6px; color: var(--muted); font-size: 12px; min-width: 0;
}
.project-detail span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-detail span + span::before { content: ""; display: inline-block; width: 4px; height: 4px; border-radius: 50%; background: var(--muted-soft); margin-right: 8px; vertical-align: 2px; }
.empty-projects {
  min-height: 260px; display: flex; align-items: center; justify-content: center; color: var(--muted);
  border: 1px dashed var(--line-soft); border-radius: 16px; background: var(--surface-faint);
}

/* ---- Photo guide page --------------------------------------------------- */
.guide-button {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 13px;
  background: var(--chip-bg); color: var(--muted); border: 1px solid var(--line); border-radius: 999px;
  font: inherit; font-size: 12px; font-weight: 650; cursor: pointer; flex: 0 0 auto;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.guide-button:hover { color: var(--ink-strong); border-color: var(--line-soft); background: rgba(93, 122, 102, 0.16); }
.guide-button-icon { width: 16px; height: 16px; flex: 0 0 auto; display: block; }
.font-gallery-link { text-decoration: none; }
.font-gallery-link::before { content: "Aa"; font-size: 12px; font-weight: 800; letter-spacing: -.06em; }

.guide-modal {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px;
  overflow-y: auto;
}
.guide-modal-scrim {
  position: fixed; inset: 0; background: rgba(10, 10, 10, .64); backdrop-filter: blur(8px);
}
.guide-shell {
  position: relative; z-index: 1; width: min(760px, 100%); margin: auto;
}
.guide-card {
  position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 26px;
  padding: clamp(22px, 4vw, 40px); box-shadow: var(--shadow);
}
.guide-close {
  position: absolute; top: 16px; right: 16px; width: 38px; height: 38px; display: grid; place-items: center;
  background: var(--panel-strong); color: var(--ink-strong); border: 1px solid var(--line-soft); border-radius: 999px;
  cursor: pointer; z-index: 2; transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}
.guide-close:hover { color: var(--accent-ink); border-color: var(--accent-strong); background: var(--accent); transform: rotate(90deg); }
.guide-close svg { width: 20px; height: 20px; display: block; }
.guide-eyebrow {
  margin: 0 0 16px; color: var(--accent-strong); font-size: 13px; font-weight: 780; letter-spacing: .12em; text-transform: uppercase;
}
.guide-intro {
  margin: 0 0 14px; color: var(--ink); font-size: clamp(15px, 1.8vw, 18px); line-height: 1.55; max-width: 60ch;
}
.guide-intro strong { color: var(--ink-strong); font-weight: 720; }
.guide-important {
  margin: 0 0 26px; padding: 12px 14px; max-width: 60ch; border: 1px solid rgba(223, 199, 128, .52);
  border-radius: 12px; background: rgba(223, 199, 128, .1); color: var(--ink); font-size: 14px; line-height: 1.5;
}
.guide-important strong { color: var(--ink-strong); font-weight: 800; }
.thumb-method {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  gap: clamp(18px, 4vw, 34px);
  align-items: center;
  margin: 0 0 28px;
  padding: clamp(14px, 2.5vw, 22px);
  border: 1px solid rgba(122,154,130,.42);
  border-radius: 20px;
  background: rgba(93,122,102,.09);
}
.thumb-method-photo { position: relative; margin: 0; overflow: hidden; border-radius: 15px; background: var(--preview-bg); }
.thumb-method-photo img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; }
.thumb-method-photo figcaption {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 5px 9px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 999px;
  background: rgba(16,20,17,.78);
  color: #f4f1eb;
  font-size: 10px;
  font-weight: 760;
  letter-spacing: .08em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
}
.thumb-method-eyebrow {
  margin: 0 0 7px;
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.thumb-method-copy h2 { margin: 0 0 10px; color: var(--ink-strong); font-size: clamp(20px, 3vw, 27px); line-height: 1.12; }
.thumb-method-copy > p:not(.thumb-method-eyebrow) { margin: 0 0 12px; color: var(--ink); line-height: 1.55; }
.thumb-method-copy ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.thumb-method-copy li { position: relative; padding-left: 22px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.thumb-method-copy li::before {
  content: "";
  position: absolute;
  left: 1px;
  top: .43em;
  width: 9px;
  height: 5px;
  border-left: 2px solid var(--accent-strong);
  border-bottom: 2px solid var(--accent-strong);
  transform: rotate(-45deg);
}
.guide-example-section { margin-top: 30px; }
.guide-example-section + .guide-example-section {
  margin-top: 36px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}
.guide-example-section-heading { margin: 0 0 16px; }
.guide-example-section-heading p {
  margin: 0 0 5px;
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.guide-example-section-avoid .guide-example-section-heading p { color: var(--bad); }
.guide-example-section-heading h2 {
  margin: 0;
  color: var(--ink-strong);
  font-size: clamp(19px, 3vw, 25px);
  line-height: 1.2;
}
.guide-examples {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(16px, 3vw, 30px);
}
.guide-example {
  margin: 0; display: flex; flex-direction: column; gap: 12px;
  border: 1px solid var(--line); border-radius: 18px; padding: 16px; background: var(--card-bg);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.guide-example-media {
  display: grid; grid-template-columns: 1fr; overflow: hidden;
  border-radius: 12px; aspect-ratio: 3 / 2; background: var(--preview-bg);
  border: 1px solid var(--line); background-image:
    repeating-linear-gradient(135deg, transparent, transparent 11px, rgba(122,154,130,.10) 11px, rgba(122,154,130,.10) 12px);
}
.guide-example-media img { display: block; width: 100%; height: 100%; min-width: 0; object-fit: contain; }
.guide-example-media.is-single { aspect-ratio: 3 / 4; }
.guide-example-media.is-single img { object-fit: cover; }
.guide-example-mark {
  display: grid; place-items: center; flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid currentColor; background: var(--panel);
}
.guide-example-mark svg { width: 62%; height: 62%; display: block; }
.guide-example.is-correct .guide-example-mark { color: var(--good); }
.guide-example.is-incorrect .guide-example-mark { color: var(--bad); }
.guide-example figcaption { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.guide-example-badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; border: 1px solid transparent;
}
.guide-example-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.guide-example-label { color: var(--ink-strong); font-size: 14px; font-weight: 650; }
.guide-example.is-correct .guide-example-badge { color: var(--good); border-color: var(--good); background: rgba(67, 209, 122, .12); }
.guide-example.is-incorrect .guide-example-badge { color: var(--bad); border-color: var(--bad); background: rgba(255, 107, 107, .12); }
.guide-example.is-correct { border-color: rgba(67, 209, 122, .4); }
.guide-example.is-incorrect { border-color: rgba(255, 107, 107, .34); }

#panel {
  width: 300px; flex-shrink: 0; border-right: 1px solid var(--line);
  background: var(--panel); padding: 16px; overflow-y: auto;
}
.step-panel {
  display: flex; flex-direction: column; gap: 14px;
}
.step-guide { margin: 0; }
.step-nav {
  margin-bottom: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-faint);
}
.step-nav-status { min-width: 0; text-align: left; }
.step-nav-kicker {
  display: block; color: var(--accent-strong); font-size: 10px; font-weight: 780; letter-spacing: .11em; text-transform: uppercase;
}
.step-nav-label {
  display: block; overflow: hidden; color: var(--ink-strong); text-overflow: ellipsis; white-space: nowrap;
  font-size: 14px; font-weight: 720; line-height: 1.25;
}
/* Step panel: keep measurement readouts hidden, while font matches can appear. */
#stepEyebrow, #stepTitle, #trust, #readout, #chips, #letters { display: none !important; }
.step-eyebrow {
  margin: 0 0 6px; color: var(--accent-strong); font-size: 11px; font-weight: 780; letter-spacing: .12em; text-transform: uppercase;
}
.step-guide h2 {
  margin: 0 0 14px; color: var(--ink-strong); font-size: 22px; line-height: 1.1; font-weight: 700; letter-spacing: 0;
}
.step-copy {
  margin: 12px 0 12px; color: var(--muted); font-size: 13px;
}
.step-actions { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 12px 0; }
.step-action {
  appearance: none; min-height: 42px; width: 100%; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--chip-bg); color: var(--ink); cursor: pointer;
  font: inherit; font-size: 12px; font-weight: 680; line-height: 1.3; text-align: left; white-space: normal;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}
.step-action:hover {
  background: rgba(93, 122, 102, 0.18); border-color: rgba(122, 154, 130, 0.54); color: var(--ink-strong);
}
.step-action:active { transform: translateY(1px); }
.step-action:focus-visible { outline: 0; box-shadow: 0 0 0 3px rgba(122, 154, 130, .28); }
.step-action-redo {
  border-color: rgba(122, 154, 130, .42); background: rgba(93, 122, 102, .13); color: var(--accent-strong);
}
.step { margin-bottom: 20px; }
.step h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 0 0 8px; }
.hint, .note { color: var(--muted); font-size: 12px; }
.note { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 12px; }

.btn, .tool, label.btn {
  display: inline-block; background: var(--panel-strong); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 12px; cursor: pointer; font-size: 13px; width: 100%;
  text-align: center; transition: .12s;
}
.btn:hover, .tool:hover { border-color: var(--accent-strong); }
.tools { display: flex; gap: 8px; }
.tool { padding: 10px 6px; }
.tool.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.tool:disabled { opacity: .4; cursor: not-allowed; }

/* manual-card toggle */
.switch { margin-top: 12px; display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted); cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track { width: 34px; height: 18px; border-radius: 10px; background: var(--track-bg);
  border: 1px solid var(--line); position: relative; transition: .15s; flex-shrink: 0; }
.switch .thumb { position: absolute; top: 1px; left: 1px; width: 14px; height: 14px;
  border-radius: 50%; background: var(--muted); transition: .15s; }
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track .thumb { left: 17px; background: var(--accent-ink); }

.trust { font-size: 12px; padding: 8px 10px; border-radius: 8px; background: var(--panel-strong);
  border: 1px solid var(--line); margin-bottom: 10px; }
.trust.good { border-color: var(--good); color: var(--good); }
.trust.warn { border-color: var(--warn); color: var(--warn); }
.trust.bad { border-color: var(--bad); color: var(--bad); }

.readout { font-size: 30px; font-weight: 700; letter-spacing: -.02em; min-height: 38px; }
.readout small { font-size: 14px; color: var(--muted); font-weight: 400; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
.chips .chip { font-size: 11px; padding: 4px 8px; border-radius: 6px;
  background: var(--panel-strong); border: 1px solid var(--line); color: var(--muted); }
.chips .chip b { color: var(--ink); font-weight: 600; }

.letters { list-style: none; padding: 0; margin: 10px 0 0; font-size: 12px;
  max-height: 220px; overflow-y: auto; }
.letters li { display: flex; align-items: center; gap: 8px; padding: 3px 0;
  border-bottom: 1px solid var(--divider-faint); }
.letters .ch { display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 5px; flex-shrink: 0;
  background: rgba(93, 122, 102, .2); color: var(--accent-strong); font-weight: 700; }
.letters .dim { color: var(--muted); }
.letters b { color: var(--ink); font-weight: 600; }
.font-recognition-options {
  margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel-strong);
}
.font-option-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.font-option-heading > div { display: grid; gap: 3px; }
.font-option-heading strong { color: var(--ink-strong); font-size: 11px; font-weight: 760; }
.font-option-heading small { color: var(--muted); font-size: 9px; line-height: 1.35; }
.font-dev-toggle { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 9px; white-space: nowrap; cursor: pointer; }
.font-dev-toggle input { accent-color: var(--accent-strong); }
.font-top-k { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 11px; color: var(--muted); font-size: 10px; }
.font-top-k output { min-width: 27px; padding: 2px 7px; border-radius: 999px; background: var(--chip-bg); color: var(--accent-strong); font-weight: 800; text-align: center; }
.font-top-k-slider { width: 100%; margin: 8px 0 0; accent-color: var(--accent-strong); cursor: pointer; }
.font-top-k-scale { display: flex; justify-content: space-between; color: var(--muted); font-size: 8px; }
.font-results {
  margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px;
}
.font-results h3 {
  margin: 0 0 8px; color: var(--ink-strong); font-size: 12px; font-weight: 760; letter-spacing: .08em; text-transform: uppercase;
}
.font-results .font-warning {
  margin: 0 0 8px; color: var(--warn); font-size: 11px;
}
.font-match-groups { display: grid; gap: 12px; }
.font-match-group { min-width: 0; }
.font-match-group-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 7px; }
.font-match-group-heading h4 { margin: 0; color: var(--ink-strong); font-size: 11px; font-weight: 760; }
.font-match-group-heading span { min-width: 22px; padding: 2px 7px; border-radius: 999px; background: var(--chip-bg); color: var(--accent-strong); font-size: 10px; font-weight: 800; text-align: center; }
.font-group-empty { margin: 0; padding: 9px; border: 1px dashed var(--line); border-radius: 9px; color: var(--muted); font-size: 10px; }
.font-results ol {
  list-style: none; margin: 0; padding: 0; display: grid; gap: 7px;
}
.font-results li {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: start;
  min-height: 62px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-strong); padding: 9px;
}
.font-results .rank {
  display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%;
  background: rgba(93,122,102,.22); color: var(--accent-strong); font-size: 11px; font-weight: 800;
}
.font-results a,
.font-results .font-title {
  overflow: hidden; color: var(--ink-strong); text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 720; text-decoration: none;
}
.font-results .font-target-case { color: var(--accent-strong); font-size: 9px; font-weight: 780; letter-spacing: .08em; text-transform: uppercase; }
.font-results .font-option { min-width: 0; display: grid; gap: 5px; }
.font-results .font-sample {
  min-height: 29px;
  overflow: hidden;
  color: var(--ink-strong);
  font-size: 22px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.font-results .font-meta {
  overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 11px;
}
.font-results .font-evidence-thumb { width: 100%; max-height: 74px; object-fit: contain; border: 1px solid var(--line); border-radius: 7px; background: white; }
.font-rendered-preview { overflow: hidden; margin: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.font-rendered-preview img { display: block; width: 100%; height: 68px; object-fit: contain; background: white; }
.font-rendered-preview figcaption { padding: 4px 6px; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 8px; }
.font-developer-trace { min-width: 0; }
.font-developer-trace h3 { margin: 0 0 8px; color: var(--accent-strong); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.font-trace-stage { margin-top: 8px; padding: 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-strong); }
.font-trace-stage header { min-height: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0; border: 0; background: transparent; }
.font-trace-stage h4 { margin: 0; color: var(--ink-strong); font-size: 10px; }
.font-trace-status { padding: 2px 6px; border-radius: 999px; background: rgba(93,122,102,.18); color: var(--accent-strong); font-size: 8px; font-weight: 800; }
.font-trace-meta { margin: 6px 0 0; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 8px; line-height: 1.45; overflow-wrap: anywhere; }
.font-trace-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 8px; }
.font-trace-figure { overflow: hidden; margin: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.font-trace-figure img { display: block; width: 100%; height: 82px; object-fit: contain; background: white; }
.font-trace-figure figcaption { padding: 6px; color: var(--muted); font-size: 8px; line-height: 1.35; }
.font-trace-match { min-width: 0; display: grid; gap: 7px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.font-trace-match > div { min-width: 0; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.font-trace-match strong { min-width: 0; overflow-wrap: anywhere; color: var(--ink-strong); font-size: 10px; }
.font-trace-match span { flex: 0 0 auto; color: var(--accent-strong); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 8px; }
.font-trace-ocr { margin: 8px 0 0; overflow-wrap: anywhere; color: var(--ink-strong); font-family: Georgia, serif; font-size: 22px; }

#stage { flex: 1; position: relative; display: flex; flex-direction: column;
  align-items: center; justify-content: center; min-width: 0; padding: 16px; }
.start-step {
  width: min(520px, calc(100% - 32px)); min-height: min(420px, calc(100dvh - 180px));
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
}
.photo-actions { width: min(420px, 100%); display: grid; gap: 12px; }
.start-step .detector-summary { width: min(420px, 100%); margin: 0; }
.primary-photo-button {
  width: 100%; min-height: 138px; border: 1px solid rgba(122,154,130,.48); border-radius: 22px;
  background: linear-gradient(180deg, #6f8d76, #4f6e58); color: white; cursor: pointer;
  box-shadow: 0 28px 80px rgba(0,0,0,.32), inset 0 1px 0 rgba(255,255,255,.18);
  font: inherit; font-size: clamp(24px, 4vw, 34px); font-weight: 760; letter-spacing: 0;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.primary-photo-button:hover {
  transform: translateY(-2px); border-color: rgba(165,195,171,.78);
  box-shadow: 0 36px 96px rgba(0,0,0,.38), inset 0 1px 0 rgba(255,255,255,.2);
}
.primary-photo-button:active { transform: translateY(0); }
.primary-photo-button.is-loading { cursor: wait; opacity: .88; }
.primary-photo-button.is-loading svg { display: none; }
.primary-photo-button.is-loading::before {
  content: "";
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  border: 2px solid rgba(255,255,255,.38);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .72s linear infinite;
}
.primary-photo-button:disabled, .paste-photo-button:disabled { pointer-events: none; }
.paste-photo-button {
  width: 100%; padding: 12px 18px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg-soft); color: var(--text); cursor: pointer; font: inherit; font-weight: 680;
}
.paste-photo-button:hover { border-color: rgba(122,154,130,.72); background: var(--bg-elev); }
.analyze-full-photo {
  width: 100%; margin: 0 0 12px; padding: 10px 14px; border: 1px solid rgba(122,154,130,.58);
  border-radius: 10px; background: rgba(111,141,118,.14); color: var(--text); cursor: pointer;
  font: inherit; font-size: 12px; font-weight: 720;
}
.analyze-full-photo:hover { background: rgba(111,141,118,.22); }
.hintbar { position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: var(--bg-soft); border: 1px solid var(--line); padding: 6px 14px; border-radius: 20px;
  font-size: 12px; color: var(--muted); z-index: 5; }
#canvasWrap { position: relative; max-width: 100%; max-height: 100%; box-shadow: 0 8px 40px #0008; border-radius: 8px; overflow: hidden; }
#view { display: block; width: 100%; height: 100%; max-width: none; max-height: none; }
#overlay { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }

.spinner { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px;
  align-items: center; justify-content: center; background: var(--overlay-veil); z-index: 10; font-size: 13px; }
.spinner.hidden { display: none; }
.spinner div { width: 32px; height: 32px; border: 3px solid var(--line);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.dragging #overlay { cursor: crosshair; }
.panning #overlay { cursor: grabbing !important; }
.ruling #overlay { cursor: move !important; }
.text-selection-transforming #overlay { cursor: grabbing !important; }

.new-project-dialog {
  position: fixed;
  inset: 0;
  z-index: 82;
  display: grid;
  place-items: center;
  padding: 18px;
}
.new-project-dialog-scrim {
  position: absolute;
  inset: 0;
  background: rgba(5, 9, 7, .72);
  backdrop-filter: blur(10px);
}
.new-project-dialog-card {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 32px 90px rgba(0, 0, 0, .42);
}
.new-project-dialog-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--chip-bg);
  color: var(--muted);
  cursor: pointer;
}
.new-project-dialog-close svg { width: 19px; height: 19px; }
.new-project-dialog-eyebrow {
  margin: 0 0 7px;
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.new-project-dialog-card h2 {
  max-width: calc(100% - 54px);
  margin: 0;
  color: var(--ink-strong);
  font-size: clamp(25px, 5vw, 34px);
  line-height: 1.1;
  letter-spacing: -.04em;
}
#newProjectDialogCopy {
  max-width: 470px;
  margin: 12px 0 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
.new-project-flow-option {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 15px;
  align-items: start;
  padding: 18px;
  border: 1px solid rgba(166, 195, 173, .48);
  border-radius: 17px;
  background: linear-gradient(145deg, rgba(120, 149, 127, .19), rgba(120, 149, 127, .07));
  color: var(--ink);
  text-decoration: none;
  transition: border-color .16s ease, background .16s ease, transform .16s ease, box-shadow .16s ease;
}
.new-project-flow-option:hover,
.new-project-flow-option:focus-visible {
  border-color: var(--accent-strong);
  background: linear-gradient(145deg, rgba(120, 149, 127, .27), rgba(120, 149, 127, .11));
  box-shadow: 0 0 0 3px rgba(120, 149, 127, .12);
  transform: translateY(-1px);
  outline: 0;
}
.new-project-flow-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(166, 195, 173, .35);
  border-radius: 15px;
  background: rgba(120, 149, 127, .16);
  color: var(--accent-strong);
}
.new-project-flow-icon svg { width: 27px; height: 27px; }
.new-project-flow-copy { min-width: 0; }
.new-project-flow-copy strong,
.new-project-flow-copy small,
.new-project-flow-copy > span { display: block; }
.new-project-flow-copy strong { color: var(--ink-strong); font-size: 16px; line-height: 1.3; }
.new-project-flow-copy small { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.new-project-flow-copy > span { margin-top: 12px; color: var(--accent-strong); font-size: 12px; font-weight: 760; }

.name-dialog {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 18px;
}
.name-dialog-scrim {
  position: absolute; inset: 0; background: rgba(10, 10, 10, .64); backdrop-filter: blur(8px);
}
.name-dialog-card {
  position: relative; width: min(420px, 100%); margin: 0; padding: 20px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
}
.name-dialog-card h2 {
  margin: 0 0 14px; color: var(--ink-strong); font-size: 22px; line-height: 1.15; letter-spacing: 0;
}
.name-dialog-card label {
  display: block; margin-bottom: 7px; color: var(--muted); font-size: 12px; font-weight: 650;
}
.name-dialog-card input {
  width: 100%; height: 46px; border: 1px solid var(--line-soft); border-radius: 10px; outline: 0;
  background: var(--chip-bg); color: var(--ink-strong); padding: 0 12px; font: inherit; font-size: 15px;
}
.name-dialog-card input:focus {
  border-color: var(--accent-strong); box-shadow: 0 0 0 3px rgba(122, 154, 130, .2);
}
.name-dialog-actions {
  display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px;
}
.name-dialog-actions button {
  min-width: 96px; height: 40px; border-radius: 10px; padding: 0 14px; font: inherit; font-size: 13px; font-weight: 680;
  cursor: pointer; transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.name-dialog-actions button:active { transform: translateY(1px); }
.secondary-dialog-button {
  color: var(--ink); background: var(--panel-strong); border: 1px solid var(--line-soft);
}
.secondary-dialog-button:hover { border-color: rgba(122, 154, 130, 0.4); color: var(--ink-strong); }
.primary-dialog-button {
  color: white; background: var(--accent); border: 1px solid rgba(122, 154, 130, 0.48);
}
.primary-dialog-button:hover { background: #6f8b76; border-color: rgba(122, 154, 130, 0.72); }

@media (max-width: 760px) {
  header { min-height: 52px; align-items: flex-start; flex-direction: column; padding: 10px 14px; gap: 9px; }
  header .brand { width: 100%; justify-content: space-between; gap: 10px; }
  header h1 { font-size: 15px; }
  header .tag { display: none; }
  .header-actions { width: 100%; justify-content: space-between; }
  .project-chip { max-width: calc(100vw - 118px); }
  .gallery-shell { width: min(100% - 24px, 1440px); padding-top: 18px; padding-bottom: 24px; }
  .gallery-header { align-items: stretch; flex-direction: column; gap: 12px; margin-bottom: 8px; }
  .eyebrow { display: none; }
  .gallery h2 { font-size: 28px; line-height: 1.05; }
  .gallery-actions { align-items: stretch; flex-direction: column; gap: 9px; }
  .gallery-meta { margin-bottom: 14px; }
  .gallery-meta span + span { display: none; }
  .project-search { width: 100%; }
  .new-project-button { width: 100%; }
  .new-project-dialog { place-items: end center; padding: 12px; }
  .new-project-dialog-card { padding: 24px 18px max(20px, env(safe-area-inset-bottom)); border-radius: 22px; }
  .new-project-flow-option { grid-template-columns: 44px minmax(0, 1fr); gap: 12px; padding: 15px; }
  .new-project-flow-icon { width: 44px; height: 44px; border-radius: 13px; }
  .project-grid { grid-template-columns: 1fr; gap: 10px; }
  .project-card {
    display: grid; grid-template-columns: 112px minmax(0, 1fr); min-height: 112px; border-radius: 12px;
  }
  .project-card:hover, .project-card:focus-visible { transform: none; }
  .project-preview { aspect-ratio: auto; height: 100%; min-height: 112px; border-bottom: 0; border-right: 1px solid var(--line); }
  .project-status { top: 8px; right: 8px; padding: 4px 7px; font-size: 9px; max-width: calc(100% - 16px); overflow: hidden; text-overflow: ellipsis; }
  .project-body { min-width: 0; padding: 14px 13px; align-self: center; }
  .project-name { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: 15px; }
  .project-detail { display: block; margin-top: 8px; line-height: 1.5; }
  .project-detail span { display: block; white-space: nowrap; }
  .project-detail span + span::before { display: none; }
  .guide-button span { display: none; }
  .guide-button { padding: 0 9px; }
  .step-nav { margin-bottom: 10px; }
  .step-nav-label { font-size: 13px; }
  .step-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .step-action { min-height: 40px; padding: 8px 9px; text-align: center; }
  .guide-modal { padding: 12px; }
  .guide-card { border-radius: 18px; }
  .guide-examples { grid-template-columns: 1fr; }
  #app { flex-direction: column; }
  #panel { width: 100%; max-height: 34vh; padding: 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .step-guide h2 { margin-bottom: 10px; font-size: 18px; }
  .step-copy { margin: 9px 0; font-size: 12px; }
  .step { margin-bottom: 12px; }
  .step h2 { margin-bottom: 7px; }
  .hint, .note, .switch { display: none; }
  .tools { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tool { padding: 9px 4px; font-size: 12px; }
  .trust { margin-bottom: 8px; }
  .readout { font-size: 25px; min-height: 32px; }
  .start-step { min-height: calc(100dvh - 120px); }
  .primary-photo-button { min-height: 116px; border-radius: 18px; }
  .name-dialog { place-items: end center; padding: 12px; }
  .name-dialog-card { padding: 16px; border-radius: 14px; }
  .name-dialog-card h2 { font-size: 20px; }
  .name-dialog-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .name-dialog-actions button { min-width: 0; }
}

/* ---- validated card detector --------------------------------------------- */
.detector-summary {
  margin: 13px 0 12px; padding: 12px; border: 1px solid rgba(122, 154, 130, .36);
  border-radius: 13px; background: linear-gradient(145deg, rgba(93, 122, 102, .16), rgba(93, 122, 102, .055));
  box-shadow: inset 0 1px 0 var(--inset-highlight);
}
.detector-summary-head { display: flex; align-items: center; gap: 9px; min-width: 0; }
.detector-summary-head > div { min-width: 0; }
.detector-summary-icon {
  width: 32px; height: 32px; flex: 0 0 auto; display: grid; place-items: center;
  border-radius: 9px; color: var(--accent-strong); background: rgba(122, 154, 130, .16);
}
.detector-summary-icon svg { width: 20px; height: 20px; }
.detector-summary-kicker {
  display: block; color: var(--muted); font-size: 9px; font-weight: 750;
  letter-spacing: .1em; line-height: 1.2; text-transform: uppercase;
}
.detector-summary-head strong {
  display: block; overflow: hidden; color: var(--ink-strong); font-size: 12.5px;
  line-height: 1.35; text-overflow: ellipsis; white-space: nowrap;
}
.detector-summary-badge {
  margin-left: auto; flex: 0 0 auto; padding: 3px 7px; border-radius: 999px;
  background: rgba(67, 209, 122, .14); color: var(--good); font-size: 9px; font-weight: 750;
}
.detector-summary-badge.is-alternative { background: var(--chip-bg); color: var(--muted); }
.detector-summary p { margin: 9px 0 0; color: var(--muted); font-size: 10.5px; line-height: 1.45; }
.detector-runtime {
  display: flex; align-items: center; gap: 6px; margin-top: 9px; color: var(--muted);
  font-size: 9.5px; line-height: 1.35;
}
.detector-runtime-dot {
  width: 6px; height: 6px; flex: 0 0 auto; border-radius: 50%; background: var(--muted);
  box-shadow: 0 0 0 3px rgba(122, 154, 130, .08);
}
.detector-runtime.is-loading .detector-runtime-dot {
  background: var(--warn); animation: detector-runtime-pulse 1.1s ease-in-out infinite;
}
.detector-runtime.is-ready { color: var(--good); }
.detector-runtime.is-ready .detector-runtime-dot { background: var(--good); }
.detector-runtime.is-fallback { color: var(--warn); }
.detector-runtime.is-fallback .detector-runtime-dot { background: var(--warn); }
@keyframes detector-runtime-pulse {
  0%, 100% { opacity: .42; transform: scale(.8); }
  50% { opacity: 1; transform: scale(1.12); }
}
.detector-summary-metrics { display: flex; gap: 7px; margin-top: 9px; }
.detector-summary-metrics span {
  flex: 1 1 0; padding: 6px 7px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface-faint); color: var(--muted); font-size: 9.5px; text-align: center;
}
.detector-summary-metrics strong { color: var(--ink-strong); font-size: 11px; }
.detector-summary:not(.has-validation) .detector-summary-metrics { display: none; }

/* ---- debug & model switch ------------------------------------------------ */
.debug-tools {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
  padding: 8px 12px;
  font-size: 12px;
}
.debug-tools > summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: .02em;
  list-style: none;
  user-select: none;
}
.debug-tools > summary::-webkit-details-marker { display: none; }
.debug-tools[open] > summary { color: var(--ink-strong); margin-bottom: 10px; }
.debug-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0; }
.debug-row > span { color: var(--muted); }
.debug-row select {
  flex: 1 1 auto; max-width: 62%;
  background: var(--panel); color: var(--ink-strong);
  border: 1px solid var(--line-soft); border-radius: 8px;
  padding: 5px 8px; font-size: 12px;
}
.detector-picker {
  min-height: 48px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid rgba(166,195,173,.42);
  border-radius: 11px;
  background: rgba(120,149,127,.1);
}
.detector-picker > span { color: var(--ink-strong); font-weight: 700; }
.detector-picker select { min-height: 32px; }
.debug-switch { margin: 6px 0 2px; font-size: 12px; }
.debug-panel { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.debug-panel.is-hidden { display: none; }
.detector-tools { display: grid; gap: 9px; }
#panel:not([data-step="card"]) .detector-tools { display: none; }
.dbg-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dbg-head b { color: var(--ink-strong); font-size: 13px; }
.dbg-verdict { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.dbg-verdict.good { background: rgba(67, 209, 122, .16); color: var(--good); }
.dbg-verdict.weak { background: rgba(255, 206, 77, .16); color: var(--warn); }
.dbg-verdict.poor { background: rgba(255, 107, 107, .16); color: var(--bad); }
.dbg-explain, .dbg-res { color: var(--muted); font-size: 11.5px; line-height: 1.45; }
.dbg-res { color: var(--ink); }
.dbg-note { color: var(--muted-soft); font-size: 11px; font-style: italic; line-height: 1.4; }
.dbg-margin { margin-top: 6px; color: var(--ink); font-weight: 600; font-size: 11.5px; }
.dbg-cands { display: flex; gap: 8px; flex-wrap: wrap; }
.dbg-cand {
  flex: 1 1 calc(33% - 8px); min-width: 92px;
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  background: var(--chip-bg);
}
.dbg-cand.chosen { border-color: var(--good); box-shadow: 0 0 0 1px var(--good) inset; }
.dbg-cand.rej { opacity: .72; }
.dbg-cand img { display: block; width: 100%; height: auto; background: #000; }
.dbg-cmeta { padding: 5px 7px; font-size: 10.5px; color: var(--muted); line-height: 1.4; }
.dbg-cmeta b { color: var(--ink-strong); }
.dbg-kv { color: var(--ink); }
.dbg-cand.chosen .dbg-cmeta b { color: var(--good); }
.dbg-why { color: var(--bad); font-style: italic; }

/* ---- product application shell ----------------------------------------- */
:root,
:root[data-theme="dark"] {
  --bg: #111715;
  --bg-soft: #18201d;
  --bg-gradient-top: #1b2420;
  --panel: #1d2522;
  --panel-strong: #27312d;
  --chip-bg: #202a26;
  --line: #33413b;
  --line-soft: #46574f;
  --ink: #d8dfdb;
  --ink-strong: #f7f5ef;
  --muted: #9aa7a1;
  --muted-soft: #74827c;
  --accent: #78957f;
  --accent-strong: #a6c3ad;
  --accent-ink: #102016;
  --field-bg: rgba(29, 37, 34, .94);
  --card-bg: rgba(29, 37, 34, .88);
  --card-bg-hover: #232e29;
  --preview-bg: #1b2320;
  --surface-faint: rgba(120, 149, 127, .07);
  --track-bg: #17201c;
  --divider-faint: #2b3732;
  --focus: rgba(166, 195, 173, .32);
  --stage-bg: #0c100f;
  --header-height: 64px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f2f3ef;
  --bg-soft: #fafbf8;
  --bg-gradient-top: #fdfdfb;
  --panel: #ffffff;
  --panel-strong: #f3f5f1;
  --chip-bg: #eef1ec;
  --line: #d9dfd9;
  --line-soft: #c1ccc3;
  --ink: #344039;
  --ink-strong: #17221c;
  --muted: #66736c;
  --muted-soft: #89958e;
  --accent: #587563;
  --accent-strong: #3e604b;
  --accent-ink: #ffffff;
  --field-bg: rgba(255, 255, 255, .96);
  --card-bg: rgba(255, 255, 255, .92);
  --card-bg-hover: #ffffff;
  --preview-bg: #e7ece6;
  --surface-faint: rgba(88, 117, 99, .055);
  --track-bg: #dce3dd;
  --divider-faint: #e6ebe6;
  --focus: rgba(62, 96, 75, .2);
  --stage-bg: #e7ebe7;
  color-scheme: light;
}

html { font-size: 16px; }
body {
  overflow: hidden;
  min-width: 320px;
  font-family: Manrope, Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -.006em;
}
button, input { font-family: inherit; }
button:focus-visible, input:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--focus);
}

header {
  position: relative;
  z-index: 30;
  min-height: var(--header-height);
  height: var(--header-height);
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-color: var(--line);
  box-shadow: 0 1px 0 rgba(255,255,255,.025), 0 8px 28px rgba(0,0,0,.08);
}
header .brand { min-width: 0; flex: 1 1 auto; align-items: center; gap: 10px; overflow: hidden; }
.brand-home { min-width: 0; flex: 1 1 auto; overflow: hidden; padding: 3px; border-radius: 12px; }
.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid rgba(166,195,173,.24);
  border-radius: 11px;
  background: linear-gradient(145deg, rgba(120,149,127,.25), rgba(120,149,127,.09));
  color: var(--accent-strong);
}
.brand-mark svg { width: 25px; height: 25px; }
.brand-copy { min-width: 0; flex: 1 1 auto; display: block; overflow: hidden; }
header h1 { overflow: hidden; font-size: 14px; font-weight: 750; letter-spacing: -.025em; text-overflow: ellipsis; }
header .tag { display: none; }
.header-actions { width: auto; flex: 0 0 auto; justify-content: flex-end; gap: 7px; margin-left: auto; }
.guide-button, .theme-toggle {
  width: 42px;
  height: 42px;
  min-height: 42px;
  justify-content: center;
  padding: 0;
  border-radius: 12px;
}
.guide-button span { display: none; }
.guide-button-icon { width: 18px; height: 18px; }
.project-chip {
  max-width: min(34vw, 220px);
  min-height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 650;
}

#app {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--stage-bg);
}
#stage {
  order: 1;
  min-height: 240px;
  flex: 1 1 auto;
  padding: 12px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 22%, rgba(120,149,127,.10), transparent 35%),
    var(--stage-bg);
}
#panel {
  order: 2;
  position: relative;
  z-index: 12;
  width: 100%;
  max-height: min(47dvh, 440px);
  flex: 0 1 auto;
  padding: 11px 16px max(16px, env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  box-shadow: 0 -18px 55px rgba(0,0,0,.22);
  backdrop-filter: blur(18px);
  --sheet-offset: 0px;
  transform: translateY(var(--sheet-offset));
  margin-top: calc(-1 * var(--sheet-offset));
  transition: transform .24s cubic-bezier(.2,.8,.2,1), margin-top .24s cubic-bezier(.2,.8,.2,1);
}
.sheet-handle {
  width: 100%;
  height: 30px;
  min-height: 30px;
  display: grid;
  place-items: start center;
  margin: -3px 0 3px;
  padding: 3px 0 0;
  border: 0;
  background: transparent;
  color: var(--line-soft);
  cursor: grab;
  touch-action: none;
}
.sheet-handle span {
  width: 40px;
  height: 4px;
  border-radius: 99px;
  background: currentColor;
}
.sheet-handle:active { cursor: grabbing; }
#panel.is-sheet-dragging { transition: none; user-select: none; }
#panel.is-sheet-collapsed .sheet-handle { color: var(--accent-strong); }
#panel.is-sheet-collapsed .sheet-handle span { width: 48px; }
@media (prefers-reduced-motion: reduce) {
  #panel { transition: none; }
}
.step-guide { display: grid; gap: 11px; }

.workflow-progress { margin: 0 0 2px; }
.workflow-progress ol {
  display: grid;
  grid-template-columns: repeat(var(--workflow-step-count, 3), minmax(0, 1fr));
  margin: 0;
  padding: 0;
  list-style: none;
}
.workflow-progress li {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  color: var(--muted-soft);
  font-size: 10px;
  font-weight: 700;
}
.workflow-progress li::after {
  content: "";
  position: absolute;
  z-index: -1;
  top: 14px;
  left: calc(50% + 14px);
  width: calc(100% - 28px);
  height: 1px;
  background: var(--line);
}
.workflow-progress li:last-child::after { display: none; }
.progress-number {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 11px;
}
.workflow-progress li.is-active { color: var(--ink-strong); }
.workflow-progress li.is-active .progress-number {
  border-color: var(--accent-strong);
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 0 0 4px rgba(120,149,127,.12);
}
.workflow-progress li.is-complete { color: var(--accent-strong); }
.workflow-progress li.is-complete .progress-number {
  border-color: rgba(166,195,173,.42);
  background: rgba(120,149,127,.16);
  color: var(--accent-strong);
}
.workflow-progress li.is-complete .progress-number { font-size: 0; }
.workflow-progress li.is-complete .progress-number::after {
  content: "✓";
  display: block;
  font-size: 12px;
  line-height: 1;
  transform: none;
}
.workflow-progress li.is-complete::after { background: rgba(166,195,173,.48); }

#stepEyebrow { display: block !important; }
#stepTitle { display: block !important; }
#trust, #readout, #chips, #letters { display: none !important; }
.step-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.step-eyebrow {
  margin: 0 0 3px;
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.step-guide h2 {
  margin: 0;
  color: var(--ink-strong);
  font-size: clamp(20px, 5.7vw, 25px);
  line-height: 1.14;
  font-weight: 750;
  letter-spacing: -.035em;
}
.step-help {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--chip-bg);
  color: var(--muted);
  cursor: pointer;
}
.step-help:hover { border-color: var(--accent); color: var(--ink-strong); }
.step-help svg { width: 19px; height: 19px; }
.step-copy { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }

.step-actions { display: grid; grid-template-columns: 1fr; gap: 9px; margin: 1px 0 0; }
.step-action, .analyze-full-photo {
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--chip-bg);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.step-action svg, .analyze-full-photo svg { width: 21px; height: 21px; flex: 0 0 auto; color: var(--accent-strong); }
.step-action span, .analyze-full-photo span { min-width: 0; display: block; }
.step-action strong, .step-action small,
.analyze-full-photo strong, .analyze-full-photo small { display: block; }
.step-action strong, .analyze-full-photo strong { color: var(--ink-strong); font-size: 12px; font-weight: 720; line-height: 1.35; }
.step-action small, .analyze-full-photo small { margin-top: 2px; color: var(--muted); font-size: 10px; font-weight: 550; line-height: 1.35; }
.step-action:hover, .analyze-full-photo:hover {
  border-color: rgba(166,195,173,.6);
  background: rgba(120,149,127,.13);
}
.step-action-redo { border-color: rgba(166,195,173,.38); background: rgba(120,149,127,.1); }
.analyze-full-photo { width: 100%; margin: 0; }

#canvasWrap {
  max-width: 100%;
  max-height: 100%;
  border: 0;
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.07), 0 22px 65px rgba(0,0,0,.35);
}
#overlay { touch-action: none; }
.font-selection-actions,
.card-review-actions {
  position: absolute;
  z-index: 9;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  width: min(430px, calc(100% - 28px));
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  padding: 7px;
  border: 1px solid rgba(166,195,173,.35);
  border-radius: 17px;
  background: color-mix(in srgb, var(--panel-strong) 92%, transparent);
  box-shadow: 0 18px 50px rgba(0,0,0,.34);
  backdrop-filter: blur(16px);
  animation: font-selection-actions-enter .24s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes font-selection-actions-enter {
  from { opacity: 0; transform: translate(-50%, 10px) scale(.97); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
.font-selection-actions button,
.card-review-actions button {
  min-height: 46px;
  border-radius: 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}
.font-selection-redraw {
  padding: 0 15px;
  border: 1px solid var(--line);
  background: var(--chip-bg);
  color: var(--ink);
}
.font-selection-confirm {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 16px;
  border: 1px solid rgba(166,195,173,.48);
  background: var(--accent);
  color: var(--accent-ink);
}
.font-selection-confirm svg { width: 20px; height: 20px; flex: 0 0 auto; }
.font-selection-actions button:disabled { opacity: .55; cursor: wait; }
.card-review-actions button:disabled { opacity: .55; cursor: wait; }
.card-review-edit,
.card-review-confirm {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 14px;
}
.card-review-edit {
  border: 1px solid var(--line);
  background: var(--chip-bg);
  color: var(--ink);
}
.card-review-edit.is-active {
  border-color: rgba(255, 218, 99, .72);
  background: rgba(255, 218, 99, .14);
  color: #ffda63;
}
.card-review-confirm {
  border: 1px solid rgba(166,195,173,.48);
  background: var(--accent);
  color: var(--accent-ink);
}
.card-review-actions svg { width: 20px; height: 20px; flex: 0 0 auto; }
.card-review-actions { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.card-corner-editing #overlay { cursor: grab; }
.dragging-card-corner #overlay { cursor: grabbing; }
.spinner { border-radius: inherit; font-size: 13px; font-weight: 650; backdrop-filter: blur(6px); }
.spinner div { width: 38px; height: 38px; border-width: 3px; }

.start-step {
  width: min(560px, 100%);
  min-height: 0;
  gap: 18px;
  padding: 20px 4px max(22px, env(safe-area-inset-bottom));
  text-align: center;
}
.upload-intro { max-width: 470px; }
.upload-icon {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  border: 1px solid rgba(166,195,173,.28);
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(120,149,127,.22), rgba(120,149,127,.07));
  color: var(--accent-strong);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
.upload-icon svg { width: 40px; height: 40px; }
.upload-eyebrow {
  margin: 0 0 7px;
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.upload-intro h2 {
  margin: 0;
  color: var(--ink-strong);
  font-size: clamp(27px, 8vw, 42px);
  line-height: 1.07;
  font-weight: 760;
  letter-spacing: -.045em;
}
.upload-intro > p:last-child { margin: 12px auto 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.workflow-mode {
  width: min(430px, 100%);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin: 0;
  padding: 0;
  border: 0;
  text-align: left;
}
.workflow-mode-single { grid-template-columns: minmax(0, 1fr); }
.workflow-mode legend {
  width: 100%;
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
  letter-spacing: .07em;
  text-align: center;
  text-transform: uppercase;
}
.workflow-mode-option {
  position: relative;
  min-width: 0;
  cursor: pointer;
}
.workflow-mode-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.workflow-mode-option > span {
  min-height: 86px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--chip-bg);
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease, transform .16s ease;
}
.workflow-mode-option:hover > span {
  border-color: rgba(166,195,173,.58);
  transform: translateY(-1px);
}
.workflow-mode-option input:checked + span {
  border-color: var(--accent-strong);
  background: rgba(120,149,127,.16);
  box-shadow: 0 0 0 3px rgba(120,149,127,.12);
}
.workflow-mode-option input:focus-visible + span {
  outline: 0;
  box-shadow: 0 0 0 3px rgba(122,154,130,.28);
}
.workflow-mode-option strong {
  color: var(--ink-strong);
  font-size: 12px;
  font-weight: 760;
  line-height: 1.3;
}
.workflow-mode-option small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}
.photo-actions { width: min(390px, 100%); grid-template-columns: 1fr; gap: 10px; }
.primary-photo-button, .paste-photo-button {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 720;
}
.primary-photo-button {
  border: 1px solid rgba(166,195,173,.46);
  background: linear-gradient(180deg, #78957f, #587563);
  color: #fff;
  box-shadow: 0 16px 38px rgba(37,63,47,.26), inset 0 1px 0 rgba(255,255,255,.2);
}
.primary-photo-button svg, .paste-photo-button svg { width: 21px; height: 21px; }
.paste-photo-button { padding: 0 18px; color: var(--ink); background: var(--bg-soft); }
.start-guide-link {
  min-height: 44px;
  padding: 4px 10px;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}

.gallery { overflow-y: auto; }
.gallery-shell { width: min(100% - 28px, 1440px); padding: 24px 0 36px; }
.gallery-header { align-items: stretch; flex-direction: column; gap: 16px; }
.gallery h2 { font-size: clamp(29px, 8vw, 48px); line-height: 1.05; letter-spacing: -.045em; }
.gallery-actions { align-items: stretch; flex-direction: column; }
.project-search { width: 100%; height: 48px; border-radius: 14px; }
.new-project-button { width: 100%; height: 48px; border-radius: 14px; }
.new-project-button > span { margin-right: 5px; font-size: 18px; font-weight: 500; }
.project-grid { grid-template-columns: 1fr; gap: 12px; }
.project-card { display: block; min-height: 0; border-radius: 16px; }
.project-card.is-entering {
  animation: project-card-enter .42s cubic-bezier(.2,.75,.25,1) both;
  animation-delay: calc(var(--project-enter-index, 0) * 55ms);
}
@keyframes project-card-enter {
  from { opacity: 0; translate: 0 14px; }
  to { opacity: 1; translate: 0 0; }
}
.project-load-sentinel {
  grid-column: 1 / -1;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}
.project-load-sentinel::before {
  content: "";
  width: 17px;
  height: 17px;
  border: 2px solid var(--line-soft);
  border-top-color: var(--accent-strong);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.project-card:hover, .project-card:focus-visible { transform: none; }
.project-preview { width: 100%; height: auto; min-height: 190px; aspect-ratio: 1.45; border: 0; border-bottom: 1px solid var(--line); }
.project-preview img { object-fit: cover; }
.project-body { min-width: 0; align-self: center; }
.project-name { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: 14px; }
.project-detail { display: block; line-height: 1.6; }
.project-detail span { display: block; }
.project-detail span + span::before { display: none; }

@media (max-width: 359px) {
  header { padding-inline: 8px; }
  .brand-mark { width: 34px; height: 34px; }
  header .brand { gap: 7px; }
  header h1 { max-width: 92px; }
  .header-actions { gap: 5px; }
  .guide-button, .theme-toggle { width: 38px; height: 38px; min-height: 38px; }
}

@media (max-width: 699px) {
  .project-chip { display: none !important; }
  .font-selection-actions, .card-review-actions { bottom: 10px; }
}

.step-guide-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: end center;
  padding: 12px;
}
.step-guide-scrim { position: absolute; inset: 0; background: rgba(5,9,7,.7); backdrop-filter: blur(10px); }
.step-guide-card {
  position: relative;
  z-index: 1;
  width: min(460px, 100%);
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  padding: 24px 20px max(20px, env(safe-area-inset-bottom));
  border: 1px solid var(--line-soft);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 30px 90px rgba(0,0,0,.42);
}
.step-guide-modal:not(.is-hidden) .step-guide-scrim { animation: step-guide-scrim-in .28s ease-out both; }
.step-guide-modal:not(.is-hidden) .step-guide-card { animation: step-guide-card-in .48s cubic-bezier(.16,.82,.25,1) both; }
.step-guide-modal.is-closing .step-guide-scrim { animation: step-guide-scrim-out .2s ease-in both; }
.step-guide-modal.is-closing .step-guide-card { animation: step-guide-card-out .22s ease-in both; }
@keyframes step-guide-scrim-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes step-guide-scrim-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes step-guide-card-in {
  from { opacity: 0; transform: translateY(42px) scale(.94); }
  65% { opacity: 1; transform: translateY(-4px) scale(1.008); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes step-guide-card-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(24px) scale(.97); }
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--chip-bg);
  color: var(--muted);
  cursor: pointer;
}
.modal-close svg { width: 19px; height: 19px; }
.step-guide-eyebrow { margin: 0 0 7px; color: var(--accent-strong); font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.step-guide-card h2 { margin: 0; color: var(--ink-strong); font-size: clamp(25px, 7vw, 32px); line-height: 1.1; letter-spacing: -.04em; }
#stepGuideCopy { margin: 12px 0 17px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.step-drag-demo {
  position: relative;
  height: 126px;
  margin: 0 0 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    radial-gradient(circle at 78% 20%, rgba(166,195,173,.18), transparent 34%),
    linear-gradient(145deg, color-mix(in srgb, var(--stage-bg) 82%, #1f3026), var(--stage-bg));
}
.step-guide-modal[data-step="ruler"] .step-drag-demo { display: none; }
.step-drag-demo-line {
  position: absolute;
  left: 25%;
  height: 7px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--muted) 46%, transparent);
  box-shadow: 0 13px 0 color-mix(in srgb, var(--muted) 24%, transparent);
}
.step-drag-demo-line-a { top: 43px; width: 48%; }
.step-drag-demo-line-b { top: 76px; width: 34%; }
.step-drag-demo-box {
  position: absolute;
  left: 17%;
  top: 21%;
  width: 0;
  height: 0;
  border: 2px dashed #ffd55a;
  border-radius: 8px;
  background: rgba(255,213,90,.07);
  box-shadow: 0 0 0 1px rgba(17,24,19,.18), 0 0 22px rgba(255,213,90,.12);
  animation: step-demo-box 3.1s cubic-bezier(.2,.75,.25,1) infinite;
}
.step-drag-demo-thumb {
  position: absolute;
  z-index: 2;
  left: calc(17% - 14px);
  top: calc(21% - 10px);
  width: 38px;
  height: 38px;
  color: #dceade;
  filter: drop-shadow(0 5px 7px rgba(0,0,0,.36));
  animation: step-demo-thumb 3.1s cubic-bezier(.2,.75,.25,1) infinite;
}
.step-drag-demo-thumb svg { width: 100%; height: 100%; display: block; }
.step-drag-demo-caption {
  position: absolute;
  left: 50%;
  bottom: 8px;
  translate: -50% 0;
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
}
@keyframes step-demo-thumb {
  0%, 9% { left: calc(17% - 14px); top: calc(21% - 10px); transform: scale(1); opacity: 0; }
  14% { opacity: 1; transform: scale(1); }
  20% { transform: scale(.9); }
  67%, 78% { left: calc(82% - 14px); top: calc(73% - 10px); transform: scale(.9); opacity: 1; }
  84%, 100% { left: calc(82% - 14px); top: calc(73% - 10px); transform: scale(1); opacity: 0; }
}
@keyframes step-demo-box {
  0%, 18% { width: 0; height: 0; opacity: 0; }
  20% { opacity: 1; }
  67%, 82% { width: 65%; height: 52%; opacity: 1; }
  90%, 100% { width: 65%; height: 52%; opacity: 0; }
}
.step-guide-tip { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-faint); color: var(--ink); font-size: 12px; line-height: 1.5; }
.step-guide-tip svg { width: 20px; height: 20px; flex: 0 0 auto; color: var(--accent-strong); }
.step-guide-continue { width: 100%; min-height: 52px; margin-top: 18px; border: 1px solid rgba(166,195,173,.48); border-radius: 14px; background: var(--accent); color: var(--accent-ink); font: inherit; font-size: 13px; font-weight: 750; cursor: pointer; }

.guide-modal { z-index: 90; padding: 10px; }
.guide-shell { width: min(860px, 100%); }
.guide-card { border-radius: 22px; max-height: calc(100dvh - 20px); overflow-y: auto; }
.guide-examples { grid-template-columns: 1fr; }
.name-dialog { z-index: 85; place-items: end center; }
.name-dialog-card { border-radius: 20px; }

@media (min-width: 480px) {
  .step-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .step-action { min-height: 62px; }
  .guide-examples { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-height: 680px) and (max-width: 779px) {
  #panel { max-height: 50dvh; }
  .step-guide { gap: 8px; }
  .sheet-handle { margin-bottom: 7px; }
}

@media (min-width: 700px) {
  :root { --header-height: 70px; }
  header { padding: 10px 20px; }
  header h1 { font-size: 15px; }
  header .tag { display: block; font-size: 10px; }
  .guide-button { width: auto; padding: 0 13px; }
  .guide-button span { display: inline; }
  .gallery-shell { width: min(100% - 48px, 1440px); padding: 40px 0 52px; }
  .gallery-header { align-items: end; flex-direction: row; }
  .gallery-actions { align-items: center; flex-direction: row; }
  .project-search { width: min(330px, 38vw); }
  .new-project-button { width: auto; }
  .project-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
  .project-card { display: block; min-height: 0; }
  .project-card:hover, .project-card:focus-visible { transform: translateY(-3px); }
  .project-preview { aspect-ratio: 1.34; min-height: 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .project-name { display: block; white-space: nowrap; font-size: 15px; }
  .project-detail { display: flex; }
  .project-detail span { display: inline; }
  .project-detail span + span::before { display: inline-block; }
  .step-guide-modal { place-items: center; padding: 24px; }
  .step-guide-card { padding: 30px; }
  .name-dialog { place-items: center; }
}

@media (min-width: 780px) {
  #app { display: grid; grid-template-columns: minmax(340px, 370px) minmax(0, 1fr); }
  #app[data-step="upload"] { grid-template-columns: minmax(0, 1fr); }
  #app[data-step="upload"] #stage { grid-column: 1 / -1; }
  #panel {
    order: 1;
    width: auto;
    max-height: none;
    min-height: 0;
    padding: 24px 22px;
    border: 0;
    border-right: 1px solid var(--line);
    border-radius: 0;
    box-shadow: 14px 0 45px rgba(0,0,0,.12);
  }
  #stage { order: 2; padding: 24px; }
  #panel { --sheet-offset: 0px !important; margin-top: 0; transform: none; }
  .sheet-handle { display: none; }
  .step-guide { gap: 14px; }
  .workflow-progress ol { display: flex; flex-direction: column; gap: 7px; }
  .workflow-progress li {
    min-height: 36px;
    grid-template-columns: 30px minmax(0, 1fr);
    justify-content: start;
    padding: 4px 8px;
    border-radius: 10px;
    font-size: 11px;
  }
  .workflow-progress li::after { display: none; }
  .workflow-progress li.is-active { background: rgba(120,149,127,.1); }
  .progress-number { width: 28px; height: 28px; }
  .step-guide h2 { font-size: 28px; }
  .step-actions { grid-template-columns: 1fr; }
  .step-action { min-height: 58px; }
  .start-step { gap: 24px; }
  .upload-intro > p:last-child { font-size: 14px; }
  .photo-actions { grid-template-columns: 1.35fr 1fr; }
  .primary-photo-button, .paste-photo-button { min-height: 56px; }
}

@media (min-width: 1180px) {
  #app { grid-template-columns: 390px minmax(0, 1fr); }
  #panel { padding: 28px 26px; }
  #stage { padding: 32px; }
}

@media (max-width: 639px) {
  .thumb-method { grid-template-columns: 1fr; }
  .thumb-method-photo img { max-height: 360px; object-position: center 72%; }
}

@media (min-width: 760px) {
  .guide-examples.guide-examples-correct { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .guide-examples.guide-examples-incorrect { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Font detection inspection stays outside the narrow result sidebar. */
#panel,
.step-guide,
.font-recognition-options,
.font-results,
.font-match-groups,
.font-match-group,
.font-option { min-width: 0; max-width: 100%; }
.font-results,
.font-recognition-options { overflow-x: hidden; }
.font-option-heading > div { min-width: 0; }
.font-option-heading small { overflow-wrap: anywhere; }
.font-developer-panel {
  position: fixed;
  z-index: 60;
  top: 56px;
  right: 0;
  bottom: 0;
  width: min(100vw, 540px);
  min-width: 0;
  padding: 18px;
  overflow: auto;
  overscroll-behavior: contain;
  border-left: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 98%, transparent);
  box-shadow: -20px 0 60px rgba(0,0,0,.3);
  backdrop-filter: blur(18px);
}
.font-developer-panel-head {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.font-developer-panel-head > div { min-width: 0; }
.font-developer-panel-head p { margin: 0 0 4px; color: var(--accent-strong); font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.font-developer-panel-head h2 { margin: 0; overflow-wrap: anywhere; color: var(--ink-strong); font-size: 21px; line-height: 1.15; }
.font-developer-panel-head button {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--chip-bg);
  color: var(--muted);
  cursor: pointer;
}
.font-developer-panel-head button:hover { color: var(--ink-strong); border-color: var(--line-soft); }
.font-developer-panel-head svg { width: 18px; height: 18px; }
.font-developer-panel-copy { margin: 9px 0 16px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.font-developer-panel .font-trace-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.font-developer-panel .font-trace-figure img { height: 116px; }
.font-developer-panel .font-evidence-thumb { display: block; width: 100%; max-height: 130px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: white; }
.font-trace-pending { margin-top: 0; }

@media (min-width: 1180px) {
  #app.has-font-developer-panel { grid-template-columns: minmax(340px, 370px) minmax(0, 1fr) minmax(380px, 440px); }
  #app.has-font-developer-panel #panel { padding: 24px 22px; }
  .font-developer-panel {
    position: relative;
    z-index: 1;
    order: 3;
    top: auto;
    right: auto;
    bottom: auto;
    width: auto;
    height: 100%;
    padding: 24px 20px;
    box-shadow: -12px 0 42px rgba(0,0,0,.12);
    backdrop-filter: none;
  }
}

/* ---- Supabase account gate --------------------------------------------- */
.account-controls {
  display: flex;
  align-items: center;
  min-width: 0;
  height: 42px;
  padding-left: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--chip-bg);
}
.account-email {
  max-width: 180px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sign-out-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-left: 6px;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0 11px 11px 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.sign-out-button:hover { color: var(--ink-strong); background: rgba(120,149,127,.1); }
.sign-out-button svg { width: 18px; height: 18px; }

.auth-gate {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 28px 18px;
  background:
    radial-gradient(circle at 24% 0%, rgba(122,154,130,.17), transparent 34%),
    linear-gradient(180deg, var(--bg-gradient-top), var(--bg));
}
.auth-card {
  width: min(100%, 430px);
  padding: clamp(26px, 6vw, 42px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card-bg);
  box-shadow: var(--shadow);
}
.auth-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  margin-bottom: 22px;
  border: 1px solid rgba(166,195,173,.3);
  border-radius: 15px;
  background: linear-gradient(145deg, rgba(120,149,127,.26), rgba(120,149,127,.08));
  color: var(--accent-strong);
}
.auth-mark svg { width: 32px; height: 32px; }
.auth-eyebrow {
  margin: 0 0 7px;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.auth-card h2 {
  margin: 0;
  color: var(--ink-strong);
  font-size: clamp(27px, 7vw, 36px);
  line-height: 1.08;
  letter-spacing: -.04em;
}
.auth-intro { margin: 12px 0 24px; color: var(--muted); }
.auth-form { display: grid; gap: 8px; }
.auth-form label { color: var(--ink); font-size: 12px; font-weight: 680; }
.auth-form input {
  width: 100%;
  height: 48px;
  margin-bottom: 7px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: 0;
  background: var(--field-bg);
  color: var(--ink-strong);
  font: inherit;
}
.auth-form input:focus { border-color: var(--accent-strong); box-shadow: 0 0 0 4px var(--focus); }
.auth-error { min-height: 20px; margin: 0; color: #d77575; font-size: 12px; }
.auth-submit {
  height: 48px;
  border: 1px solid rgba(122,154,130,.5);
  border-radius: 12px;
  background: #5d7a66;
  color: #fff;
  font: inherit;
  font-weight: 720;
  cursor: pointer;
}
.auth-submit:hover { background: #6f8b76; }
.auth-submit:disabled { opacity: .68; cursor: wait; }
.auth-mode-toggle {
  width: 100%;
  margin-top: 13px;
  padding: 8px;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  font: inherit;
  font-size: 12px;
  font-weight: 680;
  cursor: pointer;
}
.auth-mode-toggle:hover { color: var(--ink-strong); }
.auth-note { margin: 12px 0 0; color: var(--muted-soft); font-size: 11px; text-align: center; }

@media (max-width: 699px) {
  .account-controls { width: 42px; padding-left: 0; }
  .account-email { display: none; }
  .sign-out-button { width: 40px; margin-left: 0; border-left: 0; border-radius: 11px; }
}

@media (max-width: 430px) {
  .workflow-mode { grid-template-columns: 1fr; }
  .workflow-mode-option > span { min-height: 70px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
