@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+Symbols+2&display=swap");

:root {
  color-scheme: dark;
  --bg: #0b0e0c;
  --surface: #151a16;
  --surface-raised: #1c231d;
  --line: #303831;
  --text: #e9eee8;
  --muted: #a6b1a7;
  --quiet: #879387;
  --accent: #b5d2ba;
  --nav-height: 65px;
  --tile-size: 40px;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text); font: 14px/1.45 "Segoe UI", Roboto, system-ui, sans-serif; }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.app { min-height: 100dvh; }
.masthead, .controls, .main { width: min(100%, 1080px); margin-inline: auto; }
.masthead { display: flex; justify-content: space-between; align-items: baseline; padding: 23px 17px 17px; gap: 15px; }
.masthead h1 { margin: 0; font-size: 21px; font-weight: 600; font-variant: small-caps; letter-spacing: .11em; line-height: 1.2; }
.edition { font: 10px/1 "Segoe UI", system-ui, sans-serif; letter-spacing: .15em; color: var(--quiet); white-space: nowrap; }
.controls { position: sticky; top: 0; background: var(--bg); z-index: 5; padding-top: 1px; }
.search-panel { padding-bottom: 6px; }
.search-field { display: flex; align-items: center; position: relative; margin: 0 16px; height: 46px; border: 1px solid #414b42; border-radius: 8px; background: var(--surface); }
.search-field:focus-within { border-color: var(--accent); }
.search-icon { width: 20px; height: 20px; margin-left: 13px; color: var(--muted); flex: none; }
.search-field input { min-width: 0; width: 100%; padding: 0 9px 0 12px; height: 100%; color: var(--text); background: transparent; border: 0; outline: none; font-size: 15px; }
.search-field input::placeholder { color: #99a599; opacity: 1; }
.search-field input::-webkit-search-cancel-button { display: none; }
.clear { flex: none; width: 40px; height: 40px; margin-right: 2px; border: 0; background: transparent; color: var(--muted); font-size: 24px; cursor: pointer; }
.categories { display: flex; gap: 19px; align-items: stretch; overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: none; padding: 0 17px; height: 52px; border-bottom: 1px solid var(--line); scroll-padding-inline: 17px; }
.categories::-webkit-scrollbar { display: none; }
.categories button { position: relative; flex: none; border: 0; padding: 1px 1px 0; background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.categories button[aria-pressed="true"] { color: var(--text); }
.categories button[aria-pressed="true"]::after { content: ""; position: absolute; bottom: 0; left: 0; right: 0; height: 2px; background: var(--accent); }
.categories button { touch-action: pan-x; }
.categories .sortable-chosen { color: var(--accent); }
.categories .sortable-ghost { opacity: .3; }
.categories .sortable-drag { background: var(--surface-raised); border-radius: 6px; padding-inline: 8px; }

.main { padding: 22px 16px calc(var(--nav-height) + env(safe-area-inset-bottom) + 32px); }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.section-heading h2 { font-size: 17px; line-height: 1.4; letter-spacing: .012em; font-weight: 600; margin: 0; }
#count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hint { margin: 0 0 18px; font-size: 12px; color: var(--muted); }
.hint span { margin-inline: 4px; }
.glyph-grid { position: relative; width: 100%; }
.glyph-rows { position: absolute; top: 0; left: 0; right: 0; display: grid; gap: 5px; }
.glyph-grid.is-complete .glyph-rows { position: relative; top: auto; left: auto; right: auto; }
.glyph { position: relative; display: grid; place-items: center; width: 100%; min-width: 0; aspect-ratio: 1; padding: 0; border: 1px solid #2a332c; border-radius: 7px; background: var(--surface); color: var(--text); cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: pan-y; }
.glyph:active { background: var(--surface-raised); border-color: #66816c; }
@media (hover: hover) { .glyph:hover { border-color: #718675; background: var(--surface-raised); } }
.glyph .glyph-visual { position: absolute; inset: 0; display: block; width: 100%; height: 100%; pointer-events: none; }
.glyph.is-selected { border-color: var(--accent); background: var(--surface-raised); }
.glyph.is-favorite { border-color: #c69c68; }
.glyph.is-favorite.is-selected { border-color: #c69c68; background: #28382e; }
.empty { padding: 54px 10px 35px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--text); margin: 0 0 6px; font-size: 16px; font-weight: 600; }
.empty p { margin: 0; font-size: 13px; }
.bottom-tabs { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; height: calc(var(--nav-height) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: #111612; border-top: 1px solid var(--line); }
.bottom-inner { display: flex; align-items: stretch; justify-content: space-around; width: min(100%, 520px); height: var(--nav-height); margin: 0 auto; }
.bottom-tabs button { touch-action: manipulation; display: flex; flex: 1; min-width: 0; flex-direction: column; justify-content: center; align-items: center; gap: 4px; border: 0; border-top: 2px solid transparent; color: var(--muted); background: transparent; font-size: 11px; cursor: pointer; }
.bottom-tabs button.selected { color: var(--accent); border-top-color: var(--accent); }
.bottom-tabs svg { width: 21px; height: 21px; }
.toast { pointer-events: none; position: fixed; z-index: 20; bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 14px); left: 50%; transform: translate(-50%, 7px); padding: 10px 15px; border: 1px solid #546558; border-radius: 7px; background: #243027; color: var(--text); font-size: 13px; max-width: min(92vw, 380px); opacity: 0; transition: opacity .16s ease, transform .16s ease; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 660px) {
  .masthead { padding: 32px 26px 20px; }
  .masthead h1 { font-size: 24px; }
  .search-field { margin-inline: 26px; }
  .categories { padding-inline: 27px; gap: 24px; }
  .main { padding-inline: 26px; padding-top: 30px; }
  .glyph-rows { gap: 7px; }
}
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* Character selection and collection */
.compose-toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 34px; color: var(--muted); font-size: 12px; cursor: pointer; user-select: none; }
.settings-compose { display: flex; justify-content: space-between; flex-direction: row-reverse; margin-top: 10px; min-height: 38px; font-size: 13px; }
.compose-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; width: 30px; height: 17px; border-radius: 99px; background: #364039; flex: none; transition: background .1s; }
.switch-track::after { content: ""; position: absolute; left: 3px; top: 3px; width: 11px; height: 11px; border-radius: 50%; background: var(--text); transition: transform .1s; }
.compose-toggle input:checked + .switch-track { background: #669b71; }
.compose-toggle input:checked + .switch-track::after { transform: translateX(13px); }
.compose-toggle input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 3px; }
.compose-panel { position: relative; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.compose-panel:focus-within { border-color: var(--accent); }
.compose-panel textarea { font-family: "Noto Sans Symbols 2","Noto Color Emoji","Segoe UI Emoji","Apple Color Emoji",system-ui,sans-serif; display: block; width: 100%; min-height: 112px; resize: vertical; border: 0; outline: none; padding: 12px 12px 49px; color: var(--text); background: transparent; font-size: 24px; line-height: 1.45; }
.compose-actions { position: absolute; display: flex; align-items: center; gap: 4px; bottom: 7px; right: 7px; }
.compose-actions button, #copy-selection { display: grid; place-items: center; background: var(--surface-raised); border: 1px solid var(--line); color: var(--text); border-radius: 7px; width: 35px; height: 35px; min-height: 35px; padding: 0; cursor: pointer; }
.compose-actions button svg { width: 18px; height: 18px; }
.selection-stack { position: sticky; top: 53px; z-index: 4; background: var(--bg); padding-bottom: 6px; }
body:has(#search-panel:not([hidden])) .selection-stack { top: 105px; }
body:has(#categories[hidden]) .selection-stack { top: 1px; }
.selection-panel { min-height: 86px; display: flex; align-items: center; gap: 13px; min-width: 0; padding: 8px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.selection-canvas { width: 68px; height: 68px; flex: none; }
.selection-info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.selection-info strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 13px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.selection-info span { color: var(--muted); font: 11px/1.4 "Segoe UI",system-ui,sans-serif; }
#copy-selection { width: 37px; height: 37px; display: grid; place-items: center; padding: 0; flex: none; }
#copy-selection svg { width: 19px; height: 19px; }
.main .hint { margin-bottom: 10px; }
.settings-panel { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-height) + env(safe-area-inset-bottom)); z-index: 11; width: min(100%, 520px); height: min(43dvh, 295px); margin-inline: auto; padding: 17px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px 14px 0 0; }
.settings-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
.settings-heading strong { font-size: 16px; font-weight: 600; }
.settings-heading button { border: 0; background: none; color: var(--muted); font-size: 24px; width: 32px; height: 32px; cursor: pointer; }
.size-heading { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.size-heading output { color: var(--text); font-variant-numeric: tabular-nums; }
#tile-size { width: 100%; margin: 17px 0; accent-color: var(--accent); cursor: pointer; }
.settings-note { color: var(--quiet); font-size: 12px; margin: 14px 0 0; }
