:root {
  color-scheme: light;
  --page: #f6f8fc;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-soft: #eef4ff;
  --text: #10203b;
  --muted: #61708a;
  --line: #dbe3ef;
  --line-strong: #c4d1e2;
  --accent: #2563eb;
  --accent-strong: #164fc1;
  --accent-soft: #dbeafe;
  --danger: #c82d3e;
  --warning: #ad6200;
  --success: #16804a;
  --shadow: 0 20px 60px rgba(30, 64, 175, .10);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --page: #08111f;
  --surface: #0f1c2f;
  --surface-raised: #14243a;
  --surface-soft: #142a49;
  --text: #edf4ff;
  --muted: #9aabc2;
  --line: #263a56;
  --line-strong: #385270;
  --accent: #60a5fa;
  --accent-strong: #93c5fd;
  --accent-soft: #18375f;
  --danger: #fb7185;
  --warning: #fbbf24;
  --success: #4ade80;
  --shadow: 0 24px 80px rgba(0, 0, 0, .34);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--page); color: var(--text); min-width: 300px; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.skip-link { position: fixed; left: 12px; top: -60px; z-index: 20; padding: 10px 14px; border-radius: 10px; background: var(--text); color: var(--page); }
.skip-link:focus { top: 12px; }

.site-header { max-width: 1440px; margin: 0 auto; padding: 22px clamp(20px, 4vw, 64px); display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; font-weight: 620; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: #fff; background: linear-gradient(145deg, #4f8cff, #194fca); box-shadow: 0 8px 24px rgba(37, 99, 235, .28); font-weight: 800; }
.site-header nav { display: flex; align-items: center; gap: 8px; }
.site-header nav a { padding: 10px 12px; color: var(--muted); text-decoration: none; border-radius: 10px; }
.site-header nav a:hover { color: var(--text); background: var(--surface); }
.icon-control { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); cursor: pointer; }

main { max-width: 1440px; margin: 0 auto; padding: 34px clamp(20px, 4vw, 64px) 72px; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 42px; padding: clamp(44px, 8vw, 108px) 0 58px; }
.eyebrow, .section-kicker { margin: 0 0 12px; color: var(--accent); font-size: .76rem; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.hero h1 { max-width: 900px; margin: 0; font-size: clamp(3rem, 6.5vw, 6.8rem); line-height: .94; letter-spacing: -.065em; }
.hero h1 span { color: var(--accent); }
.hero-copy { max-width: 720px; margin: 28px 0 0; color: var(--muted); font-size: clamp(1rem, 1.5vw, 1.24rem); line-height: 1.65; }
.hero-metric { min-width: 220px; padding: 22px; border-left: 1px solid var(--line-strong); }
.hero-metric strong { display: block; color: var(--accent); font-size: 3.5rem; line-height: 1; }
.hero-metric span { display: block; margin-top: 8px; color: var(--muted); }

.workspace { display: grid; grid-template-columns: 250px minmax(420px, 1fr) 310px; border: 1px solid var(--line); border-radius: 26px; background: var(--surface); box-shadow: var(--shadow); overflow: clip; }
.control-panel, .catalog-panel, .inspector { padding: 26px; }
.control-panel { border-right: 1px solid var(--line); background: color-mix(in srgb, var(--surface-soft) 35%, var(--surface)); }
.inspector { border-left: 1px solid var(--line); }
.panel-heading h2, .catalog-header h2, .inspector h2, .policy-section h2, .principles h2 { margin: 0; letter-spacing: -.035em; }
.field { display: grid; gap: 10px; margin-top: 28px; color: var(--muted); font-size: .82rem; font-weight: 700; }
.field-row { display: flex; justify-content: space-between; gap: 16px; }
.field output, .color-control code { color: var(--text); font-variant-numeric: tabular-nums; }
.search-wrap { height: 46px; display: flex; align-items: center; gap: 9px; padding: 0 11px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.search-wrap input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); }
kbd { padding: 2px 7px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; color: var(--muted); background: var(--page); font: 600 .75rem ui-monospace, monospace; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.color-control { display: flex; align-items: center; gap: 10px; height: 46px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
input[type="color"] { width: 34px; height: 30px; padding: 0; border: 0; border-radius: 8px; background: transparent; cursor: pointer; }
select, .policy-input-row input { width: 100%; height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); }
.keyline-note { display: flex; gap: 12px; align-items: center; margin-top: 30px; padding-top: 22px; border-top: 1px solid var(--line); }
.keyline-note p { margin: 0; color: var(--muted); font-size: .78rem; line-height: 1.55; }
.keyline-swatch { width: 42px; height: 42px; flex: 0 0 auto; border: 1px dashed var(--accent); border-radius: 9px; box-shadow: inset 0 0 0 6px var(--accent-soft); }

.catalog-panel { min-width: 0; }
.catalog-header { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.catalog-header > p { margin: 0; color: var(--muted); font-size: .84rem; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.icon-card { min-height: 98px; display: grid; place-items: center; align-content: center; gap: 10px; padding: 12px 8px; border: 1px solid transparent; border-radius: 14px; color: var(--text); background: transparent; cursor: pointer; }
.icon-card:hover { border-color: var(--line-strong); background: var(--surface-soft); }
.icon-card[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.icon-card span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: .72rem; white-space: nowrap; }
.icon-card[aria-pressed="true"] span { color: var(--accent-strong); }
.empty-state { margin: 70px 0; text-align: center; color: var(--muted); }

.inspector { display: flex; flex-direction: column; gap: 20px; }
.preview-stage { min-height: 244px; position: relative; display: grid; place-items: center; border: 1px solid var(--line); border-radius: var(--radius); color: var(--accent); overflow: hidden; transition: background .18s, color .18s; }
.preview-stage.paper { background: #fff; }
.preview-stage.ink { background: #08111f; }
.preview-stage.grid { background-color: var(--surface); background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: 16px 16px; }
.safe-zone { position: absolute; width: 84px; height: 84px; border: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 12px; pointer-events: none; }
#icon-preview { position: relative; z-index: 1; display: grid; place-items: center; }
.spec-row { display: grid; grid-template-columns: 1fr auto; gap: 8px 18px; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: .78rem; }
.spec-row span { color: var(--muted); }
.copy-stack { display: grid; gap: 9px; }
.primary-button, .secondary-button { min-height: 44px; padding: 0 16px; border-radius: 12px; font-weight: 750; cursor: pointer; }
.primary-button { border: 1px solid var(--accent); background: var(--accent); color: #fff; }
[data-theme="dark"] .primary-button { color: #071225; }
.secondary-button { border: 1px solid var(--line-strong); background: transparent; color: var(--text); }
.primary-button:hover { background: var(--accent-strong); }
.secondary-button:hover { border-color: var(--accent); color: var(--accent); }
.code-preview { min-height: 116px; margin: 0; padding: 14px; border-radius: 12px; overflow: auto; background: var(--page); color: var(--muted); font: .72rem/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-all; }

.policy-section { display: grid; grid-template-columns: minmax(0, .8fr) minmax(420px, 1.2fr); gap: clamp(32px, 7vw, 100px); margin-top: 88px; padding: clamp(30px, 6vw, 74px); border-radius: 26px; background: #0d1c33; color: #edf4ff; }
.policy-intro > p:not(.section-kicker) { color: #aebdd1; line-height: 1.65; }
.example-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.example-list button { min-height: 40px; padding: 0 13px; border: 1px solid #334a68; border-radius: 999px; background: #142944; color: #cbd8e8; cursor: pointer; }
.example-list button:hover { border-color: #60a5fa; color: #fff; }
.policy-card { padding: clamp(22px, 4vw, 34px); border: 1px solid #304868; border-radius: 20px; background: #122642; }
.policy-card > label { display: block; margin-bottom: 9px; color: #aebdd1; font-size: .82rem; font-weight: 700; }
.policy-input-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.policy-input-row input { border-color: #385270; background: #0a1a30; color: #fff; }
.policy-result { margin-top: 22px; padding-top: 22px; border-top: 1px solid #304868; }
.mode-line { display: flex; align-items: center; gap: 10px; font-size: 1.2rem; }
.mode-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 5px rgba(251, 113, 133, .12); }
.policy-result[data-mode="icon-only-safe"] .mode-dot { background: #4ade80; box-shadow: 0 0 0 5px rgba(74, 222, 128, .12); }
.policy-result[data-mode="icon-text"] .mode-dot { background: #60a5fa; box-shadow: 0 0 0 5px rgba(96, 165, 250, .12); }
.policy-result[data-mode="review"] .mode-dot { background: #fbbf24; box-shadow: 0 0 0 5px rgba(251, 191, 36, .12); }
.policy-result > p { color: #b9c7d9; line-height: 1.6; }
.policy-result dl { margin: 20px 0 0; }
.policy-result dl div { display: grid; grid-template-columns: 1fr auto; gap: 16px; padding: 10px 0; border-top: 1px solid #263f5f; }
.policy-result dt { color: #91a5bf; }
.policy-result dd { margin: 0; font-weight: 700; text-align: right; }

.principles { padding: 88px 0 16px; }
.principle-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 26px; }
.principle-grid article { padding: 26px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.principle-grid article > span { color: var(--accent); font: 800 .75rem ui-monospace, monospace; }
.principle-grid h3 { margin: 22px 0 8px; }
.principle-grid p { margin: 0; color: var(--muted); line-height: 1.6; }

footer { max-width: 1440px; margin: 0 auto; padding: 24px clamp(20px, 4vw, 64px) 44px; display: flex; justify-content: space-between; gap: 20px; color: var(--muted); font-size: .85rem; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 10; max-width: min(360px, calc(100vw - 44px)); padding: 12px 16px; border-radius: 12px; background: var(--text); color: var(--page); box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }

:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 70%, white); outline-offset: 3px; }
button:active { transform: scale(.98); }

@media (max-width: 1120px) {
  .workspace { grid-template-columns: 230px minmax(0, 1fr); }
  .inspector { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); border-left: 0; }
  .inspector > div:first-child { grid-column: 1 / -1; }
  .preview-stage { grid-row: span 3; }
}

@media (max-width: 760px) {
  .site-header { align-items: flex-start; }
  .site-header nav a { display: none; }
  main { padding-top: 0; }
  .hero { grid-template-columns: 1fr; padding-top: 48px; }
  .hero-metric { border-left: 0; border-top: 1px solid var(--line); padding-left: 0; }
  .workspace { display: block; }
  .control-panel, .catalog-panel, .inspector { border: 0; border-bottom: 1px solid var(--line); }
  .inspector { display: flex; }
  .icon-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .policy-section { grid-template-columns: 1fr; margin-top: 48px; padding: 26px 20px; }
  .policy-input-row { grid-template-columns: 1fr; }
  .principle-grid { grid-template-columns: 1fr; }
  footer { flex-direction: column; }
}

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