@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Noto+Serif+SC:wght@400;500;600;700&family=Manrope:wght@400;500;600;700&display=swap');

:root {
  color-scheme: light;
  --paper: #f3f0e7;
  --surface: #fbfaf5;
  --sidebar-bg: #e5e1d3;
  --detail-bg: #edeee4;
  --ink: #232a24;
  --muted: #6f7268;
  --line: #d6d4c6;
  --green: #345b45;
  --green-soft: #dfe7da;
  --red: #bd5b43;
  --serif: 'Noto Serif SC', 'Songti SC', Georgia, serif;
  --sans: 'Manrope', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
  --mono: 'DM Mono', monospace;
  --topbar-h: 90px;
  --radius: 11px;
  --field-h: 46px;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100dvh; background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.6; }
button, input, select { font: inherit; }
button { color: inherit; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

.topbar { height: var(--topbar-h); display: flex; align-items: center; justify-content: space-between; padding: 0 46px; border-bottom: 1px solid var(--line); background: rgba(251,250,245,.8); }
.brand { display: flex; align-items: center; gap: 13px; text-decoration: none; color: inherit; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--green); color: #f5f3ec; font: 21px var(--serif); }
.brand strong, .brand small { display: block; }
.brand strong { font: 600 20px var(--serif); letter-spacing: 0; }
.brand small { margin-top: 3px; color: var(--muted); font: 11px var(--mono); letter-spacing: .04em; }
.topbar-right { display: flex; align-items: center; gap: 26px; color: var(--muted); font-size: 13px; }
.save-state { display: flex; align-items: center; gap: 8px; }
.save-dot { width: 7px; height: 7px; background: #638565; border-radius: 50%; }
.top-date { font: 12px var(--mono); }

.app-layout { display: grid; grid-template-columns: 300px minmax(420px, 1fr) 380px; max-width: 1720px; min-height: calc(100dvh - var(--topbar-h)); margin: 0 auto; }

.sidebar { display: flex; flex-direction: column; padding: 48px 32px 34px 42px; border-right: 1px solid var(--line); background: var(--sidebar-bg); }
.eyebrow { color: var(--red); font: 12px var(--mono); letter-spacing: .035em; }
.setup-block > .eyebrow { display: flex; justify-content: space-between; }
.setup-block > .eyebrow span { color: #9b9a8f; }
.setup-block h1 { margin: 26px 0 30px; font: 500 30px/1.5 var(--serif); letter-spacing: 0; }
.name-form { display: grid; gap: 9px; }
.name-form label { margin-top: 12px; color: #6b6e64; font-size: 13px; }
.name-form input, .length-control select { width: 100%; height: var(--field-h); padding: 0 14px; outline: 0; border: 1px solid #cdcabe; border-radius: var(--radius); background: rgba(252,251,247,.8); color: var(--ink); font-size: 15px; }
.name-form input:focus, .length-control select:focus { border-color: var(--green); }
.length-control { display: flex; gap: 9px; }
.length-control select { flex: 1; }
.icon-button { width: var(--field-h); border: 0; border-radius: var(--radius); background: var(--green); color: white; font-size: 21px; cursor: pointer; }
.name-preview { display: flex; flex-direction: column; gap: 10px; margin: 32px 0 44px; padding: 18px 16px; border-left: 3px solid var(--red); background: rgba(255,255,255,.45); border-radius: 0 var(--radius) var(--radius) 0; }
.preview-caption { color: var(--muted); font-size: 13px; }
.name-preview strong { min-height: 34px; font: 500 26px var(--serif); letter-spacing: .04em; }
.library-nav { display: flex; flex-direction: column; gap: 6px; }
.nav-heading { margin: 0 0 12px 4px; color: #7c7e74; font: 11px var(--mono); letter-spacing: .055em; text-transform: uppercase; }
.nav-item { display: flex; align-items: center; gap: 13px; width: 100%; min-height: 54px; padding: 0 15px; border: 0; border-radius: var(--radius); background: transparent; text-align: left; color: #5c5f56; font-size: 15px; cursor: pointer; transition: background .16s, color .16s; }
.nav-item:hover { background: rgba(255,255,255,.55); }
.nav-item.active { background: var(--green-soft); color: var(--green); font-weight: 600; }
.nav-index { width: 22px; color: var(--red); font: 19px var(--serif); }
.nav-count { margin-left: auto; color: #8e8f85; font: 12px var(--mono); }
.nav-item.active .nav-count { color: var(--green); }
.pending-icon, .blocked-icon { width: 22px; color: var(--red); text-align: center; font-size: 20px; }
.blocked-icon { color: #9a9c92; font-size: 15px; }
.common-icon { width: 22px; color: var(--red); text-align: center; font-size: 15px; }
.nav-rule { height: 1px; margin: 12px 6px; background: var(--line); }
.sidebar-foot { display: flex; align-items: center; gap: 10px; margin-top: auto; padding-top: 34px; color: #8b8b81; font: 13px var(--serif); }
.foot-line { width: 22px; height: 1px; background: var(--red); }

.browse-panel { display: flex; flex-direction: column; min-width: 0; height: calc(100dvh - var(--topbar-h)); padding: 48px 46px 30px; overflow: hidden; }
.browse-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.browse-heading h2 { margin: 12px 0 8px; font: 600 30px var(--serif); letter-spacing: 0; }
.section-note { margin: 0; color: var(--muted); font-size: 14px; }
.heading-meta { display: flex; align-items: center; gap: 11px; padding-bottom: 4px; color: #7f8177; font: 12px var(--mono); white-space: nowrap; }
.heading-divider { width: 1px; height: 14px; background: var(--line); }
.name-warning-legend { display: flex; align-items: center; gap: 8px; margin-top: 14px; color: #7f574d; font-size: 12px; }
.name-warning-legend small { color: #9b9890; font-size: 12px; }
.warning-swatch { width: 11px; height: 11px; flex: 0 0 auto; border-radius: 3px; background: var(--red); }

.search-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 34px 0 20px; }
.search-box { display: flex; align-items: center; gap: 11px; width: min(100%, 380px); height: var(--field-h); padding: 0 15px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.search-icon { color: var(--green); font: 24px var(--serif); line-height: 1; transform: rotate(-20deg); }
.search-box input { flex: 1; width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 15px; }
.search-box input::placeholder { color: #9b9b91; }
.search-box kbd { padding: 4px 7px; border: 1px solid #dedcd0; border-radius: 5px; color: #8d8d84; font: 11px var(--mono); }
.search-hint { color: #8b8b81; font-size: 13px; white-space: nowrap; }

.filter-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 18px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(252,251,247,.6); }
.filter-field { display: flex; flex-direction: column; gap: 6px; }
.filter-label { color: #7c7e74; font: 11px var(--mono); letter-spacing: .04em; }
.filter-select { min-width: 124px; height: 38px; padding: 0 10px; border: 1px solid #cdcabe; border-radius: 8px; background: var(--surface); color: var(--ink); font: 14px var(--sans); }
.filter-select:disabled { opacity: .45; cursor: progress; }
.filter-chips { display: flex; align-items: center; gap: 8px; }
.chip { min-height: 38px; padding: 0 14px; border: 1px solid #cdcabe; border-radius: 19px; background: transparent; color: #5c5f56; font-size: 13px; cursor: pointer; transition: background .16s, border-color .16s, color .16s; }
.chip:hover { border-color: #9aab9c; }
.chip.active { border-color: var(--green); background: var(--green); color: #fbfaf5; }
.chip-clear { margin-left: auto; border-style: dashed; color: var(--red); border-color: #d9a893; }
.chip-clear:hover { border-color: var(--red); }

.character-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); align-content: start; gap: 14px; flex: 1 1 auto; min-height: 0; overflow: hidden; }
.character-tile { position: relative; container-type: inline-size; display: grid; place-items: center; aspect-ratio: 1; min-width: 0; border: 1px solid #d9d7ca; border-radius: var(--radius); background: rgba(252,251,247,.82); cursor: pointer; transition: border-color .16s, background .16s, transform .16s, box-shadow .16s; animation: arrive .28s both; }
.character-tile:hover { z-index: 1; border-color: #9aab9c; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(42,76,54,.1); }
.character-tile[aria-selected="true"] { border-color: var(--green); background: var(--green); color: #fbfaf5; box-shadow: 0 4px 14px rgba(42,76,54,.18); }
.character-tile.common-name-warning { border-color: #a54a35; background: var(--red); color: #fffaf6; }
.character-tile.common-name-warning[aria-selected="true"] { border-color: #923c2b; background: #a94733; }
.tile-glyph { font: 400 clamp(34px, 58cqi, 92px) var(--serif); line-height: 1; }
.tile-pinyin { position: absolute; right: 8px; bottom: 6px; color: #8f9086; font: 11px var(--mono); }
.character-tile[aria-selected="true"] .tile-pinyin { color: #ccd6cd; }
.character-tile.pending-tile::after { position: absolute; top: 8px; right: 9px; width: 6px; height: 6px; border-radius: 50%; background: var(--red); content: ''; }
.character-tile.blocked-tile { border-color: #d5d2c6; background: rgba(238,236,228,.75); color: #a2a398; }
.character-tile.blocked-tile .tile-glyph { text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: rgba(189,91,67,.5); }
.character-tile.blocked-tile .tile-pinyin { color: #b0afa4; }
.character-tile.blocked-tile[aria-selected="true"] { border-color: #6d7668; background: #6d7668; color: #f6f5ef; box-shadow: 0 4px 14px rgba(80,86,76,.2); }
.character-tile.blocked-tile[aria-selected="true"] .tile-glyph { text-decoration-color: rgba(246,245,239,.65); }
.character-tile.blocked-tile[aria-selected="true"] .tile-pinyin { color: #d8dbd2; }

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1 1 auto; min-height: 200px; color: var(--muted); gap: 10px; font-size: 14px; }
.empty-state strong { color: var(--ink); font: 500 19px var(--serif); }
.empty-glyph { display: grid; place-items: center; width: 58px; height: 58px; margin-bottom: 6px; border: 1px solid var(--line); border-radius: 50%; color: #b5b4a9; font: 25px var(--serif); }
.hidden { display: none !important; }

.pager { display: flex; align-items: center; justify-content: center; gap: 18px; padding: 20px 0 6px; }
.pager-btn { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--green); font-size: 18px; cursor: pointer; transition: background .16s, border-color .16s; }
.pager-btn:hover:not(:disabled) { border-color: var(--green); background: var(--green-soft); }
.pager-btn:disabled { opacity: .4; cursor: not-allowed; }
.page-info { color: var(--muted); font-size: 13px; min-width: 200px; text-align: center; }

.browse-footer { display: flex; justify-content: space-between; gap: 14px; padding-top: 10px; color: #8f8e84; font: 12px var(--mono); }
.footer-mark { color: var(--muted); }
.footer-mark i { color: var(--red); font-style: normal; }

.detail-panel { display: flex; flex-direction: column; padding: 48px 40px 34px; border-left: 1px solid var(--line); background: var(--detail-bg); }
.detail-topline { display: flex; align-items: center; justify-content: space-between; color: #7c7e74; font: 11px var(--mono); letter-spacing: .03em; }
.detail-number { color: #9c9b90; }
.detail-character-wrap { display: flex; align-items: flex-end; justify-content: space-between; margin-top: 40px; gap: 14px; }
.detail-character { display: grid; place-items: center; width: clamp(126px, 15vw, 178px); height: clamp(140px, 16vw, 196px); background: #e3e6d9; color: var(--green); font: 400 clamp(88px, 11vw, 132px) var(--serif); border-radius: var(--radius); }
.detail-tier { margin-bottom: 9px; color: #7f8076; font: 12px var(--mono); }
.detail-panel h2 { margin: 28px 0 14px; font: 500 25px/1.55 var(--serif); }
.detail-description { min-height: 82px; margin: 0; color: #6f7168; font-size: 14px; line-height: 1.95; overflow-wrap: anywhere; }
.detail-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 26px; }
.primary-action, .secondary-action { display: flex; align-items: center; justify-content: space-between; min-height: 50px; padding: 0 16px; border-radius: var(--radius); cursor: pointer; transition: background .15s; }
.primary-action { border: 1px solid var(--green); background: var(--green); color: white; }
.primary-action:hover:not(:disabled) { background: #294b39; }
.secondary-action { border: 1px solid #cbccc0; background: transparent; color: #454d44; }
.secondary-action:hover:not(:disabled) { background: rgba(252,251,247,.7); }
.primary-action:disabled, .secondary-action:disabled, .text-action:disabled { opacity: .45; cursor: not-allowed; }
.primary-action span:first-child, .secondary-action span:first-child { font-size: 15px; }
.text-action { align-self: flex-start; display: flex; align-items: center; gap: 8px; min-height: 40px; margin-left: -10px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--red); font-size: 14px; cursor: pointer; }
.text-action:hover:not(:disabled) { background: rgba(252,251,247,.6); }
.text-action.is-pending { color: var(--green); }
.text-action.is-pending:hover:not(:disabled) { background: var(--green-soft); }
.text-action.blocked-action { color: #7b7d73; }
.text-action.blocked-action.is-blocked { color: var(--green); }
.text-action.blocked-action.is-blocked:hover:not(:disabled) { background: var(--green-soft); }
.detail-separator { height: 1px; margin: 30px 0 22px; background: var(--line); }
.slot-heading { display: flex; justify-content: space-between; color: #6f7168; font-size: 14px; }
.slot-heading span:last-child { color: #93938a; font: 12px var(--mono); }
.slot-list { display: flex; gap: 10px; margin-top: 16px; }
.name-slot { display: flex; flex: 1; align-items: center; justify-content: space-between; min-width: 0; height: 52px; padding: 0 13px; border: 1px dashed #c6c5b8; border-radius: var(--radius); color: #8f8f85; font-size: 12px; cursor: pointer; }
.name-slot.active-slot { border-color: var(--green); border-style: solid; background: #dfe7da; color: var(--green); }
.name-slot.filled-slot { border-style: solid; color: var(--ink); }
.slot-glyph { font: 22px var(--serif); }
.detail-note { display: flex; gap: 11px; align-items: center; margin-top: auto; padding-top: 30px; color: #909086; font: 13px var(--serif); }
.note-symbol { color: var(--red); font-size: 15px; }

.toast { position: fixed; right: 28px; bottom: 26px; z-index: 4; max-width: calc(100vw - 32px); padding: 14px 18px; transform: translateY(15px); border: 1px solid #d8d6c9; border-radius: var(--radius); background: var(--surface); box-shadow: 0 8px 28px rgba(34,40,33,.12); color: var(--ink); font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.visible { transform: translateY(0); opacity: 1; }
@keyframes arrive { from { transform: translateY(5px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@media (min-width: 1500px) {
  .app-layout { grid-template-columns: 330px minmax(480px, 1fr) 420px; }
  .browse-panel { padding: 52px 54px 34px; }
  .character-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 16px; }
  .sidebar { padding-right: 38px; padding-left: 48px; }
  .detail-panel { padding: 52px 46px 38px; }
}
@media (max-width: 1100px) {
  .app-layout { grid-template-columns: 268px minmax(340px, 1fr); }
  .browse-panel { height: auto; min-height: 760px; overflow: visible; }
  .character-grid { flex: none; height: 560px; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 12px; }
  .detail-panel { grid-column: 2; display: grid; grid-template-columns: 1fr 1fr; gap: 0 26px; padding: 30px 34px; border-top: 1px solid var(--line); border-left: 0; }
  .detail-character-wrap { margin-top: 22px; }
  .detail-panel h2 { margin-top: 16px; }
  .detail-separator { display: none; }
  .slot-area { align-self: center; }
  .detail-note { grid-column: 1 / -1; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
  .sidebar { padding: 34px 24px 26px 30px; }
}
@media (max-width: 700px) {
  :root { --topbar-h: 68px; --field-h: 44px; }
  .topbar { padding: 0 20px; }
  .topbar-right { gap: 0; }
  .top-date { display: none; }
  .app-layout { display: flex; flex-direction: column; min-height: calc(100dvh - var(--topbar-h)); }
  .sidebar { padding: 26px 20px 18px; border-right: 0; border-bottom: 1px solid var(--line); }
  .setup-block h1 { margin: 16px 0 18px; font-size: 24px; line-height: 1.35; }
  .setup-block h1 br { display: none; }
  .name-form { grid-template-columns: 56px 1fr 78px minmax(96px, .8fr) var(--field-h); align-items: center; gap: 8px; }
  .name-form label { margin: 0; }
  .length-control { display: contents; }
  .length-control select { grid-column: 4; }
  .icon-button { grid-column: 5; grid-row: 2; height: var(--field-h); }
  .name-preview { flex-direction: row; align-items: center; justify-content: space-between; margin: 20px 0 22px; padding: 12px 14px; }
  .name-preview strong { min-height: 0; font-size: 22px; }
  .library-nav { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 6px; }
  .nav-heading, .nav-rule { display: none; }
  .nav-item { justify-content: center; gap: 6px; min-height: 48px; padding: 0 6px; font-size: 13px; }
  .nav-index, .pending-icon, .blocked-icon, .common-icon { display: none; }
  .nav-count { margin-left: 0; font-size: 11px; }
  .sidebar-foot { display: none; }
  .browse-panel { height: auto; min-height: 560px; padding: 26px 20px 20px; }
  .browse-heading h2 { font-size: 26px; }
  .section-note { max-width: 260px; }
  .heading-meta { flex-direction: column; align-items: flex-end; gap: 5px; }
  .heading-divider { display: none; }
  .search-row { margin: 24px 0 16px; }
  .search-hint { display: none; }
  .filter-row { gap: 10px 12px; padding: 14px; }
  .filter-select { min-width: 108px; }
  .character-grid { height: 420px; grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); gap: 10px; }
  .detail-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; padding: 24px 20px; }
  .detail-topline { grid-column: 1 / -1; }
  .detail-character-wrap { grid-column: 1; grid-row: 2; margin-top: 18px; }
  .detail-character { width: 96px; height: 108px; font-size: 66px; }
  .detail-tier { max-width: 96px; }
  .detail-panel h2 { grid-column: 2; grid-row: 2; align-self: end; margin: 0 0 12px; font-size: 19px; }
  .detail-description { grid-column: 1 / -1; min-height: 56px; margin-top: 18px; }
  .detail-actions { grid-column: 1; margin-top: 18px; }
  .detail-separator { display: none; }
  .slot-area { grid-column: 2; grid-row: 5; align-self: center; }
  .name-slot { padding: 0 9px; }
  .name-slot span:first-child { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .detail-note { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } }
