:root {
  color-scheme: dark;
  --bg: #0d0f12;
  --panel: #12151a;
  --surface: #181c22;
  --surface-raised: #1e232b;
  --line: #282e38;
  --line-strong: #3a424f;
  --text: #edf0f4;
  --muted: #8f98a7;
  --subtle: #697382;
  --accent: #4d87ed;
  --accent-hover: #6396ef;
  --accent-soft: #172747;
  --focus: #78a6f5;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
body { color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; }
button, input { color: inherit; font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.app-header { position: sticky; z-index: 10; top: 0; height: 68px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; border-bottom: 1px solid var(--line); background: rgba(13, 15, 18, .94); backdrop-filter: blur(10px); }
.brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand img { width: 38px; height: 38px; flex: none; }
.brand span { display: grid; gap: 2px; }
.brand strong { font-size: 14px; letter-spacing: -.015em; }
.brand small { color: var(--muted); font-size: 11px; }
.header-actions { display: flex; align-items: center; gap: 9px; }
.status { max-width: 240px; margin-right: 6px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.button { min-height: 36px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface); font-size: 12px; font-weight: 700; cursor: pointer; }
.button:hover { border-color: #556070; background: var(--surface-raised); }
.button.primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.button.primary:hover { border-color: var(--accent-hover); background: var(--accent-hover); }

.studio { min-height: calc(100vh - 68px); display: grid; grid-template-columns: 390px minmax(0, 1fr); }
.controls { z-index: 2; border-right: 1px solid var(--line); background: var(--panel); }
.control-block { display: block; margin: 0; padding: 21px 22px; border: 0; border-bottom: 1px solid var(--line); }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-heading > div { display: flex; align-items: center; gap: 9px; }
.section-heading h2 { margin: 0; font-size: 12px; letter-spacing: .01em; }
.section-heading > span { color: var(--muted); font: 10px ui-monospace, SFMono-Regular, Consolas, monospace; }
.eyebrow { color: var(--subtle); font: 9px ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .05em; }

.template-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.template-option { min-height: 68px; display: flex; align-items: center; gap: 11px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); text-align: left; cursor: pointer; }
.template-option.wide { grid-column: 1 / -1; }
.template-option:hover { border-color: var(--line-strong); background: var(--surface-raised); }
.template-option.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.template-option svg { width: 29px; height: 34px; flex: none; fill: none; stroke: currentColor; stroke-linejoin: round; stroke-width: 1.5; }
.template-option span { display: grid; gap: 2px; }
.template-option strong { font-size: 11px; }
.template-option small { color: var(--muted); font-size: 9px; }

.palette-list { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 15px; }
.palette-swatch { position: relative; width: 29px; height: 29px; padding: 0; overflow: visible; border: 1px solid #ffffff24; border-radius: 50%; background-color: #c9ced6; background-image: linear-gradient(45deg, #9097a2 25%, transparent 25%), linear-gradient(-45deg, #9097a2 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #9097a2 75%), linear-gradient(-45deg, transparent 75%, #9097a2 75%); background-position: 0 0, 0 5px, 5px -5px, -5px 0; background-size: 10px 10px; cursor: pointer; }
.palette-swatch::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--swatch); }
.palette-swatch.active::after { content: ""; position: absolute; inset: -4px; border: 1.5px solid var(--text); border-radius: inherit; }
.color-list { display: grid; gap: 2px; }
.color-list .color-row { min-height: 36px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 11px; transition: opacity .15s ease; }
.color-row.disabled .color-field { opacity: .38; }
.color-name { display: flex; align-items: center; gap: 8px; }
.color-field { display: flex; align-items: center; gap: 8px; }
.color-field input[type="color"] { width: 26px; height: 26px; padding: 0; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 5px; background: none; cursor: pointer; }
.color-field input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-field input[type="color"]::-webkit-color-swatch { border: 0; }
.hex-input { width: 92px; height: 28px; padding: 0 7px; border: 1px solid var(--line-strong); border-radius: 5px; background: #0f1216; color: #c8ced8; font: 10px ui-monospace, SFMono-Regular, Consolas, monospace; text-transform: uppercase; }
.hex-input.invalid { border-color: #e05a6f; box-shadow: 0 0 0 1px #e05a6f55; }
.color-note { margin-top: 10px; }
.color-note code { color: #bac3d0; font: 9px ui-monospace, SFMono-Regular, Consolas, monospace; }

.link-button, .text-action { padding: 0; border: 0; background: none; color: #79a7f6; font-size: 10px; font-weight: 700; cursor: pointer; }
.link-button:hover, .text-action:hover { color: #a4c4fa; text-decoration: underline; }
.search-box { position: relative; }
.search-box svg { position: absolute; top: 11px; left: 11px; width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-linecap: round; stroke-width: 1.8; pointer-events: none; }
.search-box input { width: 100%; height: 38px; padding: 0 38px 0 36px; border: 1px solid var(--line-strong); border-radius: 7px; background: #0f1216; font-size: 12px; }
.search-box input::placeholder { color: #657080; }
.search-spinner { position: absolute; top: 12px; right: 12px; width: 14px; height: 14px; border: 2px solid #3a424d; border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.source-filter { display: flex; gap: 4px; margin: 9px 0 12px; overflow-x: auto; scrollbar-width: none; }
.source-filter button { flex: none; padding: 5px 8px; border: 0; border-radius: 5px; background: none; color: var(--muted); font-size: 9px; cursor: pointer; }
.source-filter button:hover { color: var(--text); background: var(--surface-raised); }
.source-filter button.active { background: #e5e9ef; color: #15181d; }
.glyph-results { min-height: 102px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; align-content: start; }
.glyph-button { aspect-ratio: 1; min-width: 0; display: grid; place-items: center; padding: 7px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: #d9dee8; cursor: pointer; }
.glyph-button:hover { border-color: #556070; background: var(--surface-raised); }
.glyph-button.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.glyph-button svg, .glyph-button img { display: block; width: 100%; height: 100%; object-fit: contain; }
.glyph-empty { grid-column: 1 / -1; min-height: 76px; display: grid; place-items: center; padding: 12px; border: 1px dashed var(--line-strong); border-radius: 8px; color: var(--muted); font-size: 10px; text-align: center; }
.results-footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 9px; color: var(--subtle); font-size: 9px; }
.results-footer span:last-child { overflow: hidden; text-align: right; text-overflow: ellipsis; white-space: nowrap; }

.toggle { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; font-weight: 700; cursor: pointer; }
.toggle input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.toggle > span { position: relative; width: 30px; height: 17px; border: 1px solid var(--line-strong); border-radius: 20px; background: #0f1216; transition: background .15s ease, border-color .15s ease; }
.toggle > span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 11px; height: 11px; border-radius: 50%; background: #8993a2; transition: transform .15s ease, background .15s ease; }
.toggle input:checked + span { border-color: var(--accent); background: var(--accent); }
.toggle input:checked + span::after { transform: translateX(13px); background: #fff; }
.toggle input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.compact-toggle > span { width: 26px; height: 15px; }
.compact-toggle > span::after { width: 9px; height: 9px; }
.compact-toggle input:checked + span::after { transform: translateX(11px); }
.text-controls { display: grid; gap: 10px; }
.field-label { color: var(--muted); font-size: 10px; }
.text-input { width: 100%; height: 37px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 7px; background: #0f1216; font-size: 12px; font-weight: 750; letter-spacing: .02em; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: #0f1216; }
.segmented button { min-height: 28px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font-size: 10px; font-weight: 700; cursor: pointer; }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface-raised); color: var(--text); box-shadow: 0 0 0 1px var(--line-strong); }
.range-list.compact { padding: 4px 0 1px; }
.compact-colors { padding-top: 1px; border-top: 1px solid var(--line); }
.control-note { margin: 0; color: var(--subtle); font-size: 9px; line-height: 1.45; }

.adjustments { padding-top: 0; }
.adjustments summary { height: 58px; display: flex; align-items: center; justify-content: space-between; cursor: pointer; list-style: none; }
.adjustments summary::-webkit-details-marker { display: none; }
.adjustments summary > span { display: flex; align-items: center; gap: 9px; }
.adjustments summary strong { font-size: 12px; }
.adjustments summary svg { width: 18px; fill: none; stroke: var(--muted); stroke-width: 1.5; transition: transform .15s ease; }
.adjustments[open] summary svg { transform: rotate(180deg); }
.range-list { display: grid; gap: 13px; padding: 1px 0 13px; }
.range-list label > span { display: flex; justify-content: space-between; margin-bottom: 6px; color: var(--muted); font-size: 10px; }
.range-list input[type="range"] { width: 100%; height: 4px; accent-color: var(--accent); cursor: pointer; }
.exact-input { width: 68px; height: 25px; padding: 0 6px; border: 1px solid var(--line-strong); border-radius: 5px; background: #0f1216; color: var(--text); font: 10px ui-monospace, SFMono-Regular, Consolas, monospace; text-align: right; }
.export-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; }

.preview-area { position: sticky; top: 68px; min-height: calc(100vh - 68px); height: calc(100vh - 68px); display: grid; place-items: center; overflow: hidden; background-color: #13171c; background-image: linear-gradient(45deg, #1b2027 25%, transparent 25%), linear-gradient(-45deg, #1b2027 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #1b2027 75%), linear-gradient(-45deg, transparent 75%, #1b2027 75%); background-position: 0 0, 0 10px, 10px -10px, -10px 0; background-size: 20px 20px; }
.preview-area.light { background: #dfe2e7; }
.preview-area.dark { background: #090b0e; }
.preview-toolbar { position: absolute; z-index: 2; top: 18px; right: 20px; left: 20px; display: flex; align-items: center; justify-content: space-between; pointer-events: none; }
.preview-toolbar > span { color: #778292; font: 9px ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .04em; }
.background-switch { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: rgba(18,21,26,.94); box-shadow: 0 4px 14px #0005; pointer-events: auto; }
.background-switch button { min-height: 27px; padding: 0 9px; border: 0; border-radius: 5px; background: none; color: var(--muted); font-size: 9px; cursor: pointer; }
.background-switch button.active { background: #e5e9ef; color: #15181d; }
.artboard { display: flex; flex-direction: column; align-items: center; gap: clamp(26px, 5vh, 48px); padding: 80px 24px 54px; }
.main-icon { width: min(54vh, 460px, 50vw); filter: drop-shadow(0 22px 22px #0005); }
.main-icon svg { display: block; width: 100%; height: auto; }
.actual-sizes { display: flex; align-items: end; gap: 14px; padding: 12px 16px 9px; border: 1px solid var(--line); border-radius: 9px; background: rgba(18,21,26,.95); box-shadow: 0 8px 22px #0005; }
.actual-sizes div { display: grid; place-items: center; gap: 5px; }
.actual-sizes small { color: var(--muted); font: 8px ui-monospace, SFMono-Regular, Consolas, monospace; }
.size-icon { display: block; }
.size-icon svg { display: block; width: 100%; height: 100%; }
.size-64 { width: 64px; height: 64px; }
.size-48 { width: 48px; height: 48px; }
.size-32 { width: 32px; height: 32px; }
.privacy-note { position: absolute; right: 20px; bottom: 14px; left: 20px; margin: 0; color: #667180; font-size: 9px; text-align: center; }
.drop-hint { position: absolute; z-index: 5; inset: 18px; display: none; place-items: center; border: 2px dashed var(--accent); border-radius: 12px; background: rgba(18,28,47,.96); color: #a9c7fa; font-weight: 800; }
.preview-area.dragging .drop-hint { display: grid; }
.toast { position: fixed; z-index: 30; right: 18px; bottom: 18px; padding: 10px 13px; transform: translateY(12px); border: 1px solid var(--line-strong); border-radius: 7px; background: #e5e9ef; color: #15181d; opacity: 0; box-shadow: 0 8px 24px #0008; font-size: 11px; pointer-events: none; transition: opacity .15s ease, transform .15s ease; }
.toast.visible { transform: none; opacity: 1; }

@media (max-width: 900px) {
  .studio { grid-template-columns: 350px minmax(0, 1fr); }
  .main-icon { width: min(50vh, 410px, 46vw); }
  .glyph-results { grid-template-columns: repeat(7, 1fr); }
}

@media (max-width: 720px) {
  .app-header { height: 62px; padding: 0 14px; }
  .brand small, .status, #reset-all { display: none; }
  .studio { display: flex; min-height: 0; flex-direction: column; }
  .preview-area { position: relative; top: 0; order: 1; width: 100%; min-height: 470px; height: 62vh; }
  .controls { order: 2; border-top: 1px solid var(--line); border-right: 0; }
  .main-icon { width: min(56vw, 300px, 36vh); }
  .artboard { padding-top: 72px; gap: 22px; }
  .privacy-note { display: none; }
  .glyph-results { grid-template-columns: repeat(8, 1fr); }
}

@media (max-width: 460px) {
  .brand strong { font-size: 13px; }
  .header-actions .button { padding: 0 11px; }
  .control-block { padding-right: 16px; padding-left: 16px; }
  .glyph-results { grid-template-columns: repeat(6, 1fr); }
  .actual-sizes { gap: 10px; }
}

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