﻿
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  /* ── Editorial palette — warm paper, ink, single sienna accent ── */
  --paper:       #EFE8D8;  /* page background — aged paper */
  --paper-deep:  #E6DDC8;  /* slight tint variant for texture wells */
  --surface:     #FAF5E7;  /* card surface — lighter cream */
  --ink:         #1C1813;  /* body ink */
  --ink-2:       #5A5448;  /* secondary */
  --ink-3:       #9A917C;  /* meta / captions */
  --rule:        #CEC4AC;  /* hairline */
  --rule-strong: #9A917C;  /* emphasis rule */
  --accent:      #8F2A18;  /* burnt sienna */
  --accent-2:    #D4521F;  /* brighter siena for hover glow */
  --accent-wash: rgba(143, 42, 24, 0.07);
  --accent-wash-2: rgba(143, 42, 24, 0.14);
  --danger:      #B33020;
  --guide:       rgba(143, 42, 24, 0.7);
  --folder-blue: #5CBFEC;
  --paper-default: #FFFFFF;
  --paper-default-stroke: rgba(28,24,19,0.28);
  --bg-glow-1:   rgba(143, 42, 24, 0.06);
  --bg-glow-2:   rgba(28, 24, 19, 0.05);
  --preview-bg:
    repeating-conic-gradient(rgba(28,24,19,0.045) 0% 25%, transparent 0% 50%) 0 0 / 22px 22px,
    linear-gradient(180deg, #FBF7EC, #F5EEDD);
  --frame-border: rgba(28, 24, 19, 0.08);
  --shadow-strong: rgba(28, 24, 19, 0.35);
  --shadow-soft: rgba(28, 24, 19, 0.15);
  --shadow-ui: rgba(28,24,19,0.3);
  --shadow-ui-soft: rgba(28,24,19,0.18);
  --shadow-ui-strong: rgba(28,24,19,0.28);
  --overlay-btn-bg: var(--ink);
  --overlay-btn-fg: var(--surface);
  --overlay-btn-border: var(--surface);
  --overlay-btn-hover-bg: var(--accent);
  --overlay-btn-delete-hover: var(--danger);

  /* ── Legacy aliases — kept so existing JS/CSS that references them still works ── */
  --bg: var(--paper);
  --card: var(--surface);
  --text: var(--ink);
  --text2: var(--ink-2);
  --border: var(--rule);
  --radius: 0px;

  /* ── Typography ── */
  --font-display: 'Instrument Serif', 'Songti SC', 'STSong', 'Times New Roman', serif;
  --font-body:    'Hanken Grotesk', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', -apple-system, 'Helvetica Neue', sans-serif;
  --font-mono:    'JetBrains Mono', 'SF Mono', 'Menlo', monospace;
}

html.theme-dark {
  color-scheme: dark;
  --paper:       #0F1317;
  --paper-deep:  #13181E;
  --surface:     #171C22;
  --ink:         #E6E9EE;
  --ink-2:       #B7C0CB;
  --ink-3:       #7E8896;
  --rule:        #2A313A;
  --rule-strong: #3A4350;
  --accent:      #5CBFEC;
  --accent-2:    #89D4FF;
  --accent-wash: rgba(92, 191, 236, 0.12);
  --accent-wash-2: rgba(92, 191, 236, 0.22);
  --danger:      #E25A4F;
  --guide:       rgba(92, 191, 236, 0.7);
  --bg-glow-1:   rgba(92, 191, 236, 0.08);
  --bg-glow-2:   rgba(0, 0, 0, 0.4);
  --preview-bg:
    repeating-conic-gradient(rgba(230,233,238,0.05) 0% 25%, transparent 0% 50%) 0 0 / 22px 22px,
    linear-gradient(180deg, #1B2129, #151A20);
  --frame-border: rgba(230, 233, 238, 0.08);
  --shadow-strong: rgba(0,0,0,0.65);
  --shadow-soft: rgba(0,0,0,0.4);
  --shadow-ui: rgba(0,0,0,0.6);
  --shadow-ui-soft: rgba(0,0,0,0.45);
  --shadow-ui-strong: rgba(0,0,0,0.55);
  --paper-default-stroke: rgba(0,0,0,0.5);
  --overlay-btn-bg: var(--surface);
  --overlay-btn-fg: var(--ink);
  --overlay-btn-border: var(--rule-strong);
  --overlay-btn-hover-bg: var(--accent);
  --overlay-btn-delete-hover: var(--danger);
}

html {
  background: var(--paper);
  height: 100%;
  overflow: hidden; /* no page-level scroll — content fits the viewport */
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100vh;
  overflow: hidden;
  position: relative;
  /* Warm atmospheric gradient wells — soft colored "light" on paper */
  background-image:
    radial-gradient(ellipse 60% 40% at 12% 0%,  var(--bg-glow-1), transparent 70%),
    radial-gradient(ellipse 50% 40% at 90% 100%, var(--bg-glow-2), transparent 75%);
  background-attachment: fixed;
}

/* Fine grain / paper noise overlay — adds texture, no performance cost */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.55;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch' seed='3'/><feColorMatrix values='0 0 0 0 0.17  0 0 0 0 0.14  0 0 0 0 0.10  0 0 0 0.11 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

html.theme-dark body::before {
  opacity: 0.25;
  mix-blend-mode: screen;
}

/* All actual content sits above the noise layer */
header, .app, .toast, .loupe, .header-links { position: relative; z-index: 1; }

body.eyedropper-mode, body.eyedropper-mode * {
  cursor: crosshair !important;
}

/* ── Selection ── */
::selection { background: var(--accent); color: var(--surface); }

/* ── Scrollbars (applied globally; re-themed to match paper palette) ── */
* { scrollbar-width: thin; scrollbar-color: var(--rule-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--rule);
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 10px;
}
*::-webkit-scrollbar-thumb:hover { background: var(--rule-strong); background-clip: padding-box; border: 2px solid transparent; }

/* ── Header external links (GitHub / X) ── */
/* Inline chips that sit in the masthead-meta bar on the right,
   keeping the editorial "row of metadata" feel uninterrupted. */
.header-links {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
}
.masthead-right {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.header-controls {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
  border: 1px solid var(--rule);
  background: var(--paper-deep);
}
.header-controls .toggle-label-inline {
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.header-controls .ios-toggle {
  transform: scale(0.9);
  transform-origin: center;
}
.header-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--rule);
  color: var(--ink-2);
  background: transparent;
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
.header-link:hover {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}
.header-link:active { transform: translateY(1px); }
.header-link svg {
  width: 12px;
  height: 12px;
  display: block;
  fill: currentColor;
}
@media (max-width: 720px) {
  .header-link {
    width: 22px;
    height: 22px;
  }
  .header-link svg {
    width: 11px;
    height: 11px;
  }
  .masthead {
    flex-wrap: wrap;
  }
  .masthead-right {
    width: 100%;
    justify-content: space-between;
  }
  .header-controls {
    padding: 4px 4px;
  }
}

.app {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 40px 24px;
  display: flex;
  flex-direction: row-reverse;
  gap: 28px;
  align-items: stretch;
  /* Fill the viewport exactly — masthead + app = 100vh, no scroll */
  height: calc(100vh - var(--masthead-h, 72px));
  min-height: 0;
}

/* ── Preview ── */
.preview-col {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 28px;
  align-self: flex-start;
}

.preview-wrap {
  /* Shrinks when the viewport is too short to hold a 560² canvas plus the
     two cards below — keeps everything inside a single non-scrolling view. */
  --preview-size: min(560px, calc(100vh - 260px));
  width: var(--preview-size);
  height: var(--preview-size);
  border-radius: var(--radius);
  background: var(--preview-bg);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--rule);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.6) inset,
    0 30px 60px -30px var(--shadow-strong),
    0 2px 10px -4px var(--shadow-soft);
}

/* Inner frame — a subtle "passepartout" feel like a framed print */
.preview-wrap::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid var(--frame-border);
  pointer-events: none;
  z-index: 8;
}

.preview-wrap > svg {
  width: 100%;
  height: 100%;
  display: block;
  position: absolute;
  top: 0; left: 0;
  filter: drop-shadow(0 6px 14px rgba(28,24,19,0.14)) drop-shadow(0 2px 4px rgba(28,24,19,0.10));
}
.preview-wrap > svg.hidden { display: none; }

/* Colophon strip below preview — small meta info */
.preview-col::after {
  content: "";
  position: absolute;
  pointer-events: none;
  /* cosmetic only — placeholder hook for a future footer annotation */
}

/* SVG source container — off-screen, holds originals for reference */
.svg-sources {
  position: absolute;
  top: -9999px;
  left: -9999px;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* Overlay image */
.overlay-img {
  position: absolute;
  cursor: grab;
  z-index: 10;
  user-select: none;
  -webkit-user-select: none;
  display: none;
}

.overlay-img.active { display: block; }
.overlay-img:active { cursor: grabbing; }

/* Unified overlay button style — used for all image controls */
.overlay-btn {
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--overlay-btn-bg);
  border: 1.5px solid var(--overlay-btn-border);
  color: var(--overlay-btn-fg);
  cursor: pointer;
  z-index: 11;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s, border-color 0.15s;
  box-shadow: 0 2px 6px var(--shadow-ui);
}
.overlay-btn.show { display: flex; }
.overlay-btn:hover {
  background: var(--overlay-btn-hover-bg);
  color: var(--paper);
  transform: scale(1.12);
}
.overlay-btn svg {
  width: 14px;
  height: 14px;
  display: block;
}
.overlay-btn svg path { stroke: currentColor; }
.overlay-btn svg circle { fill: currentColor; }
/* Variant overrides */
.overlay-btn.btn-delete:hover {
  background: var(--overlay-btn-delete-hover);
  color: var(--paper);
}
.overlay-btn.overlay-resize { cursor: nwse-resize; z-index: 12; }
.overlay-btn.overlay-rotate { cursor: grab; z-index: 12; }
.overlay-btn.overlay-rotate:active { cursor: grabbing; }
.overlay-btn.overlay-radius { z-index: 13; }

/* Snap guide lines — switched from blue to accent sienna to match palette */
.guide-h, .guide-v {
  position: absolute;
  z-index: 9;
  display: none;
}

.guide-h {
  left: 0;
  right: 0;
  height: 1px;
  background: var(--guide);
}

.guide-v {
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--guide);
}

.guide-h.show, .guide-v.show { display: block; }

/* ── Controls ── */
.controls-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.controls-col .card-color {
  display: flex;
  flex-direction: column;
}
/* Horizontal sub-layout for the two color cards (文件夹颜色 | 文件颜色).
   When 含文件 is off, the paper card is display:none and the folder card
   stretches to fill the full row automatically (flex:1 on the only child).
   flex-wrap lets them stack gracefully on very narrow viewports where
   the two cards can't both fit above their ~200px minimum. */
.color-cards-row {
  display: flex;
  gap: 14px;
  align-items: stretch;
  flex-wrap: wrap;
}
/* Equalize title rows so row height doesn't jump when 含文件 toggles
   (toggle is 31px — pin both title rows to 32px min to match). */
.color-cards-row > .card-color > .card-title {
  min-height: 32px;
}
.color-cards-row > .card-color {
  flex: 1 1 180px;
  min-width: 0;
  padding: 14px 14px 16px;
}
.color-cards-row .color-tools { gap: 6px; }
.color-cards-row .color-tools .tool-btn {
  padding: 6px 6px;
  gap: 5px;
  white-space: nowrap;
  font-size: 10.5px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 18px 16px;
  border: 1px solid var(--rule);
  position: relative;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.card:hover { border-color: var(--rule-strong); }
.card:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

/* Card titles — editorial: serif-italic mark + sans label + mono number on right */
.card-title {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 10px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 10px;
}
/* Small sienna diamond marker as the title's "drop cap" */
.card-title::before {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--accent);
  transform: rotate(45deg);
  flex-shrink: 0;
}
/* Trailing hairline fills to the right edge of the card */
.card-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}
/* Title row with an inline control (e.g. 含文件样式 toggle) on the right */
.card-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
/* When the title row has a trailing control (toggle), suppress the
   auto-filling rule since the control should flow at the end. */
.card-title.card-title-row::after { display: none; }
.card-title.card-title-row > span:first-child {
  flex: 1;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.card-title.card-title-row > span:first-child::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}
.toggle-cluster {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.toggle-label-inline {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
}
/* ── Symbol Picker ── */
.card-symbol {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.symbol-search {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 14px;
  font: inherit;
  font-family: var(--font-body);
  font-size: 13px;
  letter-spacing: 0.01em;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  border-radius: 0;
  outline: none;
  margin-bottom: 10px;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.symbol-search::placeholder { color: var(--ink-3); font-style: italic; }
.symbol-search:focus {
  border-color: var(--ink);
  background: var(--surface);
  box-shadow: inset 0 -2px 0 var(--accent);
}

/* ── Text Input ── */
.text-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 14px;
  font: inherit;
  font-family: var(--font-body);
  font-size: 14px;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  border-radius: 0;
  outline: none;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.text-input::placeholder { color: var(--ink-3); font-style: italic; }
.text-input:focus {
  border-color: var(--ink);
  background: var(--surface);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.symbol-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.symbol-tab {
  font: inherit;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 5px 11px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  border-radius: 0;
  position: relative;
  transition: color 0.18s, border-color 0.18s, background 0.18s;
}
.symbol-tab:hover {
  color: var(--ink);
  border-color: var(--rule-strong);
}
.symbol-tab.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
}
.symbol-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  gap: 5px;
  align-content: start;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 2px;
}
.symbol-item {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 0;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  padding: 0;
}
.symbol-item:hover {
  background: var(--accent-wash);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.symbol-item.active {
  background: var(--ink);
  border-color: var(--ink);
}
.symbol-item svg {
  width: 60%;
  height: 60%;
  display: block;
  stroke: var(--ink);
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.symbol-item.active svg { stroke: var(--surface); }

/* ── Brand icons render as FILLED paths, not stroked. ── */
.symbol-item.brand svg {
  stroke: none;
  fill: var(--ink);
  width: 62%;
  height: 62%;
}
.symbol-item.brand.active svg { fill: var(--surface); }
.symbol-item.brand:hover svg { fill: var(--accent); }

/* ── Library mode toggle (符号 / 品牌) ── */
.lib-toggle {
  display: inline-flex;
  border: 1px solid var(--rule);
  background: var(--paper);
  padding: 2px;
  gap: 2px;
}
.lib-toggle-btn {
  font: inherit;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  text-transform: none;
}
.lib-toggle-btn:hover { color: var(--ink); }
.lib-toggle-btn.active {
  background: var(--ink);
  color: var(--surface);
}

/* ── Brand-color apply bar ── */
.brand-color-bar {
  margin-top: 10px;
  padding: 8px 10px;
  background: var(--paper);
  border: 1px dashed var(--rule-strong);
  font-size: 12px;
  line-height: 1.3;
}
.brand-color-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  user-select: none;
}
.brand-color-toggle input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
}
.brand-color-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1px solid var(--rule);
  background: var(--ink);
  flex-shrink: 0;
}
.brand-color-text { color: var(--ink-2); }
.brand-color-text em {
  font-style: italic;
  font-family: var(--font-display);
  color: var(--ink);
  font-weight: 500;
}

.symbol-grid-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--ink-3);
  padding: 28px 0;
  font-size: 13px;
  font-style: italic;
  font-family: var(--font-display);
}

/* ── iOS Toggle ── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toggle-label {
  font-size: 15px;
  font-weight: 500;
}

.ios-toggle {
  position: relative;
  width: 51px;
  height: 31px;
  flex-shrink: 0;
}

.ios-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.ios-toggle .track {
  position: absolute;
  inset: 0;
  border-radius: 15.5px;
  background: var(--paper-deep);
  border: 1px solid var(--rule);
  transition: background 0.3s, border-color 0.3s;
  cursor: pointer;
}

.ios-toggle input:checked + .track {
  background: var(--ink);
  border-color: var(--ink);
}

.ios-toggle .thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 3px var(--shadow-ui-soft), 0 0 0 0.5px rgba(28,24,19,0.1);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}
.ios-toggle input:checked ~ .thumb {
  background: var(--accent);
  box-shadow: 0 1px 3px var(--shadow-ui-strong), 0 0 0 0.5px rgba(28,24,19,0.15);
}

.ios-toggle input:checked ~ .thumb {
  transform: translateX(20px);
}

/* ── Color Card ── */
.color-picker-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.color-picker-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 0;
}

.color-tools {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.color-tools .tool-btn {
  flex: 1;
  justify-content: center;
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border: 1px solid var(--rule);
  border-radius: 0;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.1s;
}
.tool-btn:hover {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--surface);
}
.tool-btn:active { transform: translateY(1px); }
.tool-btn svg { width: 13px; height: 13px; flex-shrink: 0; }
.tool-btn .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--folder-blue);
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.1) inset;
}
/* White swatch for 文件颜色 "恢复默认" (outlined, since default is white) */
.tool-btn .dot.dot-white {
  background: var(--paper-default);
  box-shadow: 0 0 0 1px var(--paper-default-stroke) inset;
}

/* ── Upload Zone ── */
.upload-zone {
  border: 1px dashed var(--rule-strong);
  border-radius: 0;
  padding: 18px 14px;
  text-align: center;
  cursor: pointer;
  color: var(--ink-2);
  font-family: var(--font-body);
  font-size: 13px;
  font-style: italic;
  letter-spacing: 0.01em;
  background: var(--paper);
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.upload-zone:hover {
  border-color: var(--ink);
  background: var(--accent-wash);
  color: var(--ink);
}

.upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-wash-2);
  color: var(--accent);
  border-style: solid;
}

.overlay-controls {
  display: none;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
}

.overlay-controls.show {
  display: flex;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slider-row label {
  font-size: 13px;
  color: var(--text2);
  flex-shrink: 0;
  min-width: 32px;
}

.slider-row input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 2px;
  background: var(--rule);
  border-radius: 0;
  outline: none;
}

.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 2px rgba(28,24,19,0.3);
  cursor: pointer;
  border: 2px solid var(--surface);
}

.slider-val {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-2);
  min-width: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.remove-btn {
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 7px 14px;
  border-radius: 0;
  cursor: pointer;
  align-self: flex-start;
  transition: background 0.2s, color 0.2s;
}

.remove-btn:hover {
  background: var(--accent);
  color: var(--surface);
}

/* ── Export Card ── */
.export-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  flex: 1 1 160px;
  padding: 11px 14px;
  border: 1px solid transparent;
  border-radius: 0;
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.1s;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
  position: relative;
}
.btn-primary::before {
  content: "→";
  font-family: var(--font-display);
  margin-right: 8px;
  color: var(--accent);
  font-style: italic;
  font-size: 1.2em;
  letter-spacing: 0;
}
.btn-primary:hover {
  background: var(--accent);
  border-color: var(--accent);
}
.btn-primary:hover::before { color: var(--surface); }

.btn-secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
}
.btn-secondary:hover {
  background: var(--ink);
  color: var(--surface);
}

/* ── Eyedropper Loupe ── */
.loupe {
  position: fixed;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  overflow: hidden;
  pointer-events: none;
  z-index: 9999;
  display: none;
  box-shadow: 0 4px 20px rgba(28,24,19,0.35), 0 0 0 4px var(--surface);
}

.loupe canvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  display: block;
}

.loupe-crosshair {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.loupe-crosshair::before,
.loupe-crosshair::after {
  content: '';
  position: absolute;
  background: rgba(0,0,0,0.4);
}

.loupe-crosshair::before {
  width: 1px;
  height: 100%;
  left: 50%;
  transform: translateX(-0.5px);
}

.loupe-crosshair::after {
  height: 1px;
  width: 100%;
  top: 50%;
  transform: translateY(-0.5px);
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 48px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--surface);
  padding: 12px 24px;
  border-radius: 0;
  border: 1px solid var(--ink);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 10000;
  box-shadow: 0 8px 32px rgba(28,24,19,0.35);
}
.toast::before {
  content: "· ";
  color: var(--accent);
  font-weight: 700;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Hidden file input ── */
#fileInput { display: none; }

/* ══════════════════════════════════════════════════
   HEADER — compact title on the left
   ══════════════════════════════════════════════════ */
.masthead {
  position: relative;
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 40px 14px;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--rule);
}
.masthead h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-style: italic;
  font-size: 38px;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0;
  flex-shrink: 0;
}
.masthead h1 .roman {
  font-style: normal;
  letter-spacing: -0.035em;
}
.masthead h1 .accent {
  color: var(--accent);
}

/* ══════════════════════════════════════════════════
   Load animations — subtle fade-in on load
   ══════════════════════════════════════════════════ */
@keyframes riseFade {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.masthead > * { animation: riseFade 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.masthead h1          { animation-delay: 0.00s; }
.masthead .masthead-right { animation-delay: 0.08s; }
.app > .preview-col { animation: riseFade 0.8s 0.15s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.app > .controls-col > * { animation: riseFade 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.app > .controls-col > *:nth-child(1) { animation-delay: 0.20s; }
.app > .controls-col > *:nth-child(2) { animation-delay: 0.28s; }
.app > .controls-col > *:nth-child(3) { animation-delay: 0.36s; }
.app > .controls-col > *:nth-child(4) { animation-delay: 0.44s; }

@media (prefers-reduced-motion: reduce) {
  .masthead > *,
  .app > .preview-col,
  .app > .controls-col > * { animation: none; }
}

/* ══════════════════════════════════════════════════
   Responsive
   ══════════════════════════════════════════════════ */
@media (max-width: 1000px) {
  /* Mobile/tablet: restore page-level scrolling. Desktop locks the viewport
     (html/body overflow:hidden) to fit everything in one screen, but on
     narrower viewports the stacked layout genuinely needs to scroll. */
  html, body {
    height: auto;
    overflow: visible;
    overflow-x: hidden;
  }
  body {
    min-height: 100vh;
  }
  .app {
    flex-direction: column;
    align-items: center;
    padding: 20px 20px 48px;
    gap: 18px;
    /* Release the viewport-height lock — let content determine height. */
    height: auto;
    min-height: 0;
  }
  .preview-col {
    position: static;
    width: 100%;
    max-width: 560px;
    height: auto !important; /* override the JS lockControlsColHeight fallback */
  }
  .preview-wrap {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    --preview-size: auto;
  }
  .controls-col {
    width: 100%;
    max-width: 560px;
    height: auto !important; /* unlock — page scrolls now, not inner panels */
  }
  /* Let the symbol grid expand to its natural height. Otherwise the grid
     keeps its desktop `flex:1; overflow-y:auto` and becomes a tiny inner
     scroll window — bad on touch where the page should scroll instead. */
  .symbol-grid {
    flex: 0 1 auto;
    min-height: 0;
    max-height: 46vh;   /* still cap it so it doesn't dominate the page */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .masthead {
    padding: 20px 20px 12px;
  }
}

@media (max-width: 720px) {
  .masthead h1 {
    font-size: 28px;
  }
  .app {
    padding: 16px 14px 44px;
    gap: 14px;
  }
  .card {
    padding: 12px 14px 14px;
  }
  .color-cards-row {
    gap: 10px;
  }
  .color-cards-row > .card-color {
    flex: 1 1 100%;   /* stack the two color cards on phones */
    padding: 12px 12px 14px;
  }
  /* Smaller grid cells on phones so the default rows stay useful */
  .symbol-grid {
    grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
    max-height: 42vh;
  }
  .header-links { margin-left: 4px; }
  .header-link { width: 26px; height: 26px; } /* slightly larger hit target */
}

@media (max-width: 420px) {
  .masthead {
    padding: 16px 14px 10px;
    gap: 12px;
  }
  .masthead h1 {
    font-size: 24px;
  }
}
