:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #22221f;
  background: #f5f7f1;
  --surface-white: #fff;
  --surface-paper: #f5f7f1;
  --surface-panel: #eef0ea;
  --surface-ink: #22221f;
  --sidebar: #1f1f1d;
  --sidebar-hover: #2c2c29;
  --text-muted: #65716a;
  --sidebar-muted: #a4a39d;
  --border-light: rgba(11, 13, 11, .16);
  --border-dark: #3b3b37;
  --brand-accent: #12cbb5;
  --brand-accent-soft: rgba(18, 203, 181, .12);
  --brand-accent-strong: #087f71;
  --brand-accent-strong-hover: #066c60;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; background: var(--surface-paper); }
body { min-width: 320px; min-height: 100vh; margin: 0; color: var(--surface-ink); background: var(--surface-paper); }
button, input { font: inherit; }
button, .file-button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, .file-button:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 3px; }
button:disabled, input:disabled { cursor: not-allowed; opacity: .6; }
dialog { max-width: calc(100vw - 32px); }
.skip-link { position: fixed; z-index: 100; top: 1rem; left: 1rem; padding: .65rem .9rem; color: var(--surface-ink); background: var(--surface-white); transform: translateY(-200%); }
.skip-link:focus { transform: translateY(0); }

.app-shell { display: grid; min-height: 100vh; grid-template-columns: 268px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; display: flex; height: 100vh; min-height: 600px; flex-direction: column; padding: 30px 20px 22px; color: #f6f5ef; background: var(--sidebar); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px; color: inherit; font-size: 15px; font-weight: 650; letter-spacing: -.02em; text-decoration: none; }
.brand-mark { display: grid; width: 32px; height: 32px; flex: 0 0 auto; place-items: center; }
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: contain; }
.brand small { display: block; margin-top: 3px; color: var(--brand-accent); font: 500 8px/1.2 var(--mono); letter-spacing: .1em; }
.new-font { margin: 42px 0 18px; padding: 11px 12px; border: 1px solid var(--brand-accent-strong); border-radius: 7px; color: #fff; background: var(--brand-accent-strong); font-size: 12px; font-weight: 700; text-align: left; }
.new-font:hover { border-color: var(--brand-accent-strong-hover); background: var(--brand-accent-strong-hover); }
.new-font span { margin-right: 6px; color: #a8eee4; font-size: 16px; vertical-align: -1px; }
.nav-label, .eyebrow { margin: 0; color: var(--text-muted); font-size: 10px; font-weight: 750; letter-spacing: .1em; }
.nav-label { margin: 0 10px 8px; color: #91918b; }
.project-nav { display: grid; gap: 2px; }
.nav-item { display: flex; min-height: 34px; align-items: center; gap: 8px; margin: 0; padding: 8px 11px; border: 0; border-radius: 6px; color: #bdbcb6; background: transparent; font-size: 11px; text-align: left; text-decoration: none; }
.nav-item:hover { color: #fff; background: #292926; }
.nav-item.active { color: #fff; background: #343431; }
.nav-item[aria-current="location"] { color: #fff; box-shadow: inset 2px 0 var(--brand-accent); }
.nav-button { width: 100%; font: inherit; }
.nav-icon { display: inline-grid; width: 18px; height: 18px; flex: 0 0 18px; place-items: center; color: var(--brand-accent); font-size: 11px; font-weight: 750; }
.nav-icon-grid::before { width: 11px; height: 11px; border: 1px solid currentColor; border-radius: 2px; content: ""; box-shadow: 3px 3px 0 -2px var(--sidebar), 3px 3px 0 -1px currentColor; }
.nav-icon-guides::before { width: 12px; height: 12px; background: linear-gradient(90deg,currentColor 1px,transparent 1px 5px,currentColor 5px 6px,transparent 6px),linear-gradient(currentColor 1px,transparent 1px 5px,currentColor 5px 6px,transparent 6px); content: ""; }
.nav-icon-export { font-size: 15px; }
.count { margin-left: auto; color: #8d8c87; font-size: 11px; }
.lock-icon { margin-left: auto; color: #96958e; font-size: 10px; }
.sidebar-project { margin-top: 24px; }
.sidebar-divider { height: 1px; margin: 0 10px 16px; background: var(--border-dark); }
.project-entry { display: flex; min-width: 0; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 6px; color: #f4f3ee; background: #2c2c29; font-size: 11px; }
.project-dot { width: 6px; height: 6px; flex: 0 0 auto; border-radius: 50%; background: var(--brand-accent); box-shadow: 0 0 0 3px var(--brand-accent-soft); }
.project-entry-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-storage { margin: 8px 10px; color: #888780; font-size: 9px; }
.sidebar-bottom { display: grid; gap: 8px; margin-top: auto; padding: 0 10px; }
.online-note { display: flex; align-items: center; gap: 7px; color: #aaa9a3; font: 500 8px var(--mono); letter-spacing: .08em; }
.online-indicator { width: 6px; height: 6px; border-radius: 50%; background: var(--brand-accent); box-shadow: 0 0 0 3px var(--brand-accent-soft); }
.sidebar-bottom p { margin: 0; color: #8e8d86; font-size: 10px; line-height: 1.5; }

.workspace { min-width: 0; background: var(--surface-paper); }
.workspace section[id] { scroll-margin-top: 112px; }
.workspace section[id]:focus { outline: 2px solid var(--brand-accent); outline-offset: 4px; }
.topbar { position: sticky; z-index: 5; top: 0; display: flex; min-height: 96px; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 42px; border-bottom: 1px solid var(--border-light); background: var(--surface-white); }
.project-controls { min-width: 0; }
.project-name-label { display: block; margin-bottom: 5px; color: var(--text-muted); font-size: 10px; font-weight: 750; letter-spacing: .1em; }
.project-name-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.project-name-row input { min-width: 0; padding: 0; border: 0; color: var(--surface-ink); background: transparent; }
.family-name { width: min(21rem, 42vw); font-size: 21px; font-weight: 630; letter-spacing: -.04em; }
.style-name { width: 7rem; color: var(--text-muted) !important; font-size: 15px; }
.top-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 14px; }
.save-status { color: var(--text-muted); font-size: 10px; }
.text-button { padding: 0; border: 0; color: var(--text-muted); background: transparent; font-size: 11px; text-decoration: none; white-space: nowrap; }
.text-button:hover { color: var(--surface-ink); }
.primary-button, .small-button, .secondary-button, .affinity-button, .save-metrics { display: inline-flex; min-height: 36px; align-items: center; justify-content: center; gap: 7px; padding: 9px 12px; border: 1px solid var(--border-light); border-radius: 6px; color: var(--surface-ink); background: var(--surface-white); font-size: 11px; font-weight: 650; text-decoration: none; }
.primary-button { min-height: 38px; padding: 10px 14px; border-color: #087f71; color: #fff; background: #087f71; }
.primary-button:hover { border-color: #066c60; background: #066c60; }
.small-button:hover, .secondary-button:hover, .affinity-button:hover, .save-metrics:hover { border-color: var(--brand-accent); background: var(--brand-accent-soft); }
.small-button-primary { border-color: var(--brand-accent); background: var(--brand-accent); }
.small-button-primary:hover { background: #4de1ce; }
.file-button { white-space: nowrap; }
.visually-hidden-input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); clip-path: inset(50%); white-space: nowrap; }

.content-layout { display: grid; min-height: calc(100vh - 96px); grid-template-columns: minmax(0, 1fr) 300px; }
.glyphs-panel { min-width: 0; padding: 38px 42px 36px; }
.panel-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; padding-bottom: 22px; }
.panel-heading .eyebrow { margin-bottom: 8px; }
.panel-heading h1 { margin: 0; font-size: 30px; font-weight: 650; letter-spacing: -.05em; line-height: 1; }
.panel-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.search { display: flex; min-width: 130px; align-items: center; gap: 5px; padding: 8px 9px; border: 1px solid var(--border-light); border-radius: 6px; color: var(--text-muted); background: var(--surface-white); }
.search input { width: 100%; min-width: 0; padding: 0; border: 0; outline: 0; color: var(--surface-ink); background: transparent; font-size: 10px; }
.search input:focus-visible { outline: 0; }
.character-tools { margin-bottom: 14px; padding: 11px 12px; border: 1px solid var(--border-light); border-radius: 7px; background: #eef0ea; }
.character-tools-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.character-tools-heading h2 { margin: 0; font-size: 11px; font-weight: 650; }
.character-tools-heading span { color: var(--text-muted); font-size: 9px; }
.set-buttons { display: flex; flex-wrap: wrap; gap: 5px; }
.set-buttons button { min-height: 27px; padding: 5px 8px; border: 1px solid var(--border-light); border-radius: 5px; color: var(--surface-ink); background: var(--surface-white); font-size: 9px; }
.set-buttons button:hover { border-color: var(--brand-accent); background: var(--brand-accent-soft); }
.set-buttons .add-glyph { border-color: rgba(18, 203, 181, .45); color: var(--brand-accent-strong); background: var(--brand-accent-soft); font-weight: 700; }
.category-tabs { display: flex; min-height: 39px; align-items: stretch; gap: 2px; margin-bottom: 15px; border-bottom: 1px solid var(--border-light); }
.tab { position: relative; padding: 9px 11px 10px; border: 0; color: var(--text-muted); background: transparent; font-size: 10px; }
.tab:hover { color: var(--surface-ink); }
.tab.active { color: var(--surface-ink); font-weight: 650; }
.tab.active::after { position: absolute; right: 7px; bottom: -1px; left: 7px; height: 2px; background: var(--brand-accent); content: ""; }
.glyph-count { align-self: center; margin-left: auto; color: var(--text-muted); font-size: 9px; white-space: nowrap; }
.glyph-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); gap: 8px; max-height: min(52vh, 530px); overflow: auto; padding: 2px 2px 12px; scrollbar-color: #b5b8b0 transparent; }
.glyph-card { display: flex; min-width: 0; min-height: 75px; flex-direction: column; justify-content: space-between; padding: 8px; border: 1px solid var(--border-light); border-radius: 8px; color: var(--surface-ink); background: var(--surface-white); text-align: left; transition: border-color .16s ease, box-shadow .16s ease, background .16s ease; }
.glyph-card:hover, .glyph-card[aria-pressed="true"] { border-color: var(--brand-accent); box-shadow: 0 0 0 2px rgba(18, 203, 181, .12); }
.glyph-card[aria-pressed="true"] { background: #f9fcf7; }
.glyph-card-symbol { display: grid; height: 39px; place-items: center; overflow: hidden; color: var(--surface-ink); font: 27px/1 Georgia, serif; }
.glyph-card-symbol.is-empty { color: #9b9e96; }
.glyph-card-code { overflow: hidden; color: #82857d; font: 8px var(--mono); text-overflow: ellipsis; white-space: nowrap; }
.empty-state { grid-column: 1/-1; margin: 0; padding: 20px; color: var(--text-muted); font-size: 12px; }

.affinity-workflow { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border-light); }
.workflow-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.workflow-heading .eyebrow { margin: 0; }
.workflow-steps { color: var(--text-muted); font: 9px var(--mono); }
.affinity-workflow h2 { margin: 9px 0 5px; font-size: 16px; font-weight: 650; letter-spacing: -.03em; }
.workflow-summary { max-width: 34rem; margin: 0; color: var(--text-muted); font-size: 10px; line-height: 1.5; }
.workflow-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.affinity-button { border-color: rgba(18, 203, 181, .45); color: var(--brand-accent-strong); background: var(--brand-accent-soft); }
.affinity-button:hover { border-color: var(--brand-accent); background: rgba(18, 203, 181, .2); }

.inspector { position: sticky; top: 96px; align-self: start; height: calc(100vh - 96px); min-height: 550px; overflow: auto; padding: 38px 26px; border-left: 1px solid var(--border-light); background: var(--surface-panel); }
.inspector>.eyebrow { color: var(--text-muted); }
.selected-glyph { display: grid; justify-items: start; gap: 7px; margin-top: 24px; }
.selected-glyph-preview { display: grid; width: 100%; min-height: 230px; place-items: center; overflow: hidden; border: 1px solid var(--border-light); border-radius: 8px; background: var(--surface-white); }
.selected-glyph-preview svg { display: block; width: 100%; height: 220px; }
.selected-glyph small { margin-top: 6px; color: var(--surface-ink); font-size: 11px; font-weight: 750; }
.unicode-value { color: var(--text-muted); font: 9px var(--mono); }
.glyph-zoom-button { padding: 5px 0; border: 0; color: var(--brand-accent-strong); background: transparent; font-size: 10px; font-weight: 650; text-align: left; }
.glyph-zoom-button:hover { color: var(--brand-accent-strong-hover); }
.metrics { display: grid; gap: 0; margin: 22px 0 0; padding: 16px 0 0; border: 0; border-top: 1px solid var(--border-light); }
.metrics legend { display: flex; width: 100%; justify-content: space-between; padding: 0 0 8px; color: var(--surface-ink); font-size: 10px; font-weight: 750; letter-spacing: .07em; }
.metrics legend span { color: var(--text-muted); font: 8px var(--mono); letter-spacing: 0; }
.metrics label { display: grid; grid-template-columns: minmax(0,1fr) 88px; align-items: center; gap: 8px; min-height: 39px; border-bottom: 1px solid var(--border-light); color: var(--text-muted); font-size: 9px; }
.metrics input, .grid-inputs input { width: 100%; min-width: 0; min-height: 27px; padding: 5px 7px; border: 1px solid var(--border-light); border-radius: 5px; color: var(--surface-ink); background: var(--surface-white); font: 10px var(--mono); }
.metrics input[readonly] { color: var(--text-muted); background: var(--surface-muted); }
.metrics input[aria-invalid="true"], .grid-inputs input[aria-invalid="true"] { border-color: #b34545; }
.metrics-help { margin: 7px 0 0; color: var(--text-muted); font-size: 9px; line-height: 1.5; }
.typography-grid { margin-top: 21px; padding-top: 15px; border-top: 1px solid var(--border-light); }
.typography-grid .workflow-heading { margin-bottom: 9px; }
.typography-grid h2 { margin: 0; color: var(--surface-ink); font-size: 13px; font-weight: 700; }
.grid-icon { color: var(--brand-accent-strong); font-size: 14px; }
.grid-inputs { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.grid-inputs label { display: grid; gap: 4px; color: var(--text-muted); font-size: 8px; }
.app-footer { display: flex; justify-content: space-between; gap: 12px; padding: 13px 24px; border-top: 1px solid var(--border-light); color: var(--text-muted); font-size: 9px; }

.new-font-dialog, .glyph-zoom-dialog { position: fixed; inset: 50% auto auto 50%; width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; margin: 0; padding: 34px; border: 1px solid var(--border-light); border-radius: 14px; color: var(--surface-ink); background: var(--surface-white); box-shadow: 0 24px 90px rgba(11,13,11,.23); transform: translate(-50%,-50%); }
.new-font-dialog::backdrop, .glyph-zoom-dialog::backdrop { background: rgba(11,13,11,.52); backdrop-filter: blur(3px); }
.new-font-dialog h2, .glyph-zoom-dialog h2 { margin: 8px 0 14px; color: var(--surface-ink); font-size: clamp(24px,5vw,34px); letter-spacing: -.05em; line-height: 1.04; }
.new-font-dialog .eyebrow, .glyph-zoom-dialog .eyebrow { color: var(--brand-accent-strong); }
.dialog-copy, .hint { color: var(--text-muted); font-size: 12px; line-height: 1.6; }
.dialog-field { display: grid; max-width: 240px; gap: 7px; color: var(--text-muted); font-size: 11px; }
.dialog-field input { width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid var(--border-light); border-radius: 6px; color: var(--surface-ink); background: var(--surface-white); }
.dialog-field input:focus { border-color: var(--brand-accent); box-shadow: 0 0 0 3px rgba(18,203,181,.16); outline: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.close-dialog { position: absolute; top: 12px; right: 12px; display: grid; width: 30px; height: 30px; place-items: center; border: 0; border-radius: 50%; color: var(--text-muted); background: transparent; font-size: 22px; }
.close-dialog:hover { color: var(--surface-ink); background: var(--brand-accent-soft); }
.buy-button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 8px; padding: 10px 15px; border-radius: 6px; text-decoration: none; }
.hint { margin: 14px 0 0; font-size: 10px; }
.glyph-zoom-dialog { width: min(740px, calc(100vw - 32px)); }
.zoom-preview { display: grid; min-height: 330px; place-items: center; overflow: hidden; border: 1px solid var(--border-light); border-radius: 9px; background: var(--surface-white); }
.zoom-preview svg { width: 100%; height: min(58vh, 420px); }
.toast { position: fixed; z-index: 30; right: 18px; bottom: 18px; max-width: min(360px,calc(100vw - 36px)); padding: 11px 14px; border: 1px solid var(--border-light); border-radius: 8px; color: var(--surface-ink); background: var(--surface-white); box-shadow: 0 10px 30px rgba(11,13,11,.14); font-size: 11px; opacity: 0; pointer-events: none; transform: translateY(6px); transition: opacity .16s ease, transform .16s ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }

@media (max-width: 1200px) {
  .app-shell { grid-template-columns: 230px minmax(0,1fr); }
  .sidebar { padding-right: 16px; padding-left: 16px; }
  .content-layout { grid-template-columns: minmax(0,1fr) 270px; }
  .glyphs-panel { padding-right: 27px; padding-left: 27px; }
  .inspector { padding-right: 20px; padding-left: 20px; }
  .topbar { padding-right: 27px; padding-left: 27px; }
  .top-actions { gap: 9px; }
  .save-status { display: none; }
}
@media (max-width: 960px) {
  .app-shell { grid-template-columns: 200px minmax(0,1fr); }
  .content-layout { grid-template-columns: minmax(0,1fr); }
  .inspector { position: static; height: auto; min-height: 0; border-top: 1px solid var(--border-light); border-left: 0; }
  .selected-glyph-preview { max-width: 360px; }
}
@media (max-width: 680px) {
  .app-shell { display: block; }
  .sidebar { position: static; height: auto; min-height: 0; padding: 15px 18px; }
  .new-font { margin: 15px 0 10px; }
  .project-nav { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .project-nav .nav-label { grid-column: 1/-1; }
  .sidebar-project, .sidebar-bottom { display: none; }
  .topbar { position: static; align-items: flex-start; flex-direction: column; padding: 15px 18px; }
  .top-actions { width: 100%; justify-content: flex-start; }
  .save-status { display: inline; flex: 1 0 100%; }
  .family-name { width: min(56vw,21rem); }
  .glyphs-panel { padding: 24px 18px; }
  .panel-heading { align-items: flex-start; flex-direction: column; }
  .panel-actions { width: 100%; justify-content: flex-start; }
  .search { flex: 1 1 100%; }
  .glyph-grid { grid-template-columns: repeat(auto-fill,minmax(56px,1fr)); max-height: 52vh; }
  .inspector { padding: 24px 18px; }
  .app-footer { flex-direction: column; }
}
@media (max-width: 420px) {
  .project-nav { grid-template-columns: minmax(0,1fr); }
  .project-nav .nav-label { grid-column: auto; }
  .top-actions > .text-button, .top-actions > .file-button { min-height: 34px; }
  .category-tabs { overflow-x: auto; }
  .tab { flex: 0 0 auto; padding-right: 8px; padding-left: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
