:root {
  color-scheme: dark;
  --bg: #0d0e11;
  --nav: #111216;
  --surface: #15171c;
  --raised: #1b1d23;
  --stroke: #282a32;
  --stroke-hi: #383b45;
  --text: #f3f3f6;
  --muted: #a9abb7;
  --quiet: #858894;
  --accent: #c5c4d9;
  --danger: #f4a8a8;
  --radius: 18px;
  --rail: 224px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font: 16px/1.5 "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button { color: inherit; cursor: pointer; }
button:disabled { opacity: .55; cursor: wait; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; }
svg.glyph { width: 19px; height: 19px; flex: 0 0 auto; }
::selection { color: #121217; background: #d9d9e5; }
:focus-visible { outline: 2px solid #d4d2eb; outline-offset: 4px; }
[hidden] { display: none !important; }
.skip { position: fixed; z-index: 10; top: 10px; left: 10px; transform: translateY(-170%); padding: 10px; background: var(--raised); }
.skip:focus { transform: none; }
.layout { display: grid; grid-template-columns: var(--rail) minmax(0,1fr); min-height: 100vh; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; gap: 28px;
  padding: 23px 16px 17px; background: var(--nav); border-right: 1px solid #22242b;
  overflow: auto; scrollbar-width: thin;
}
.logo { display: inline-flex; align-items: center; gap: 11px; align-self: flex-start; margin-left: 9px; }
.logo img { width: 37px; height: 37px; }
.logo span { font-size: 25px; font-weight: 780; letter-spacing: -.07em; line-height: 1; }
.logo b { font-weight: inherit; color: #a4a7b7; }
.nav-group { display: grid; gap: 4px; }
.nav-label { margin: 0 10px 5px; color: var(--quiet); font-size: .69rem; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.nav-item {
  min-height: 45px; display: flex; gap: 11px; align-items: center; padding: 0 11px; border: 1px solid transparent;
  border-radius: 10px; color: var(--muted); font-size: .9rem; font-weight: 550; background: transparent; text-align: left;
}
.nav-item:hover, .nav-item[aria-current=page] { background: #202228; color: #fff; }
.nav-item[aria-current=page] { border-color: #30323c; }
.sidebar-bottom { margin-top: auto; display: grid; gap: 12px; }
.mini-plan {
  display: grid; gap: 7px; text-align: left; padding: 12px;
  background: linear-gradient(145deg,#1c1e25,#16171c); border: 1px solid var(--stroke); border-radius: 13px;
}
.mini-plan:hover { border-color: var(--stroke-hi); }
.mini-plan strong, .mini-plan small { display: flex; align-items: center; justify-content: space-between; gap: 7px; }
.mini-plan strong { font-size: .9rem; }
.mini-plan small { color: var(--muted); font-size: .77rem; }
progress { height: 5px; width: 100%; border: 0; border-radius: 99px; overflow: hidden; accent-color: #c9c9d8; background: #353742; }
progress::-webkit-progress-bar { background: #353742; }
progress::-webkit-progress-value { background: #c9c9d8; }
progress::-moz-progress-bar { background: #c9c9d8; }
.workspace { min-width: 0; }
.top {
  position: sticky; z-index: 4; top: 0; min-height: 72px;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 12px clamp(18px,3.6vw,54px); background: #0d0e11ed; border-bottom: 1px solid #22242b;
  backdrop-filter: blur(14px);
}
.top-title { color: var(--muted); font-size: .92rem; font-weight: 650; }
.top .logo { display: none; }
.top-actions, .row, .actions { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.top-actions { flex-wrap: nowrap; }
.search {
  min-height: 42px; display: flex; gap: 10px; align-items: center; padding: 0 12px;
  width: clamp(165px,23vw,320px); background: #16171c; border: 1px solid var(--stroke); border-radius: 10px; color: var(--quiet);
}
.search:focus-within { border-color: #767787; }
.search input { min-width: 0; border: 0; outline: none; width: 100%; padding: 8px 0; background: transparent; color: var(--text); font-size: .88rem; }
.search input:focus-visible { outline: none; }
.key { border: 1px solid #363843; border-radius: 5px; padding: 0 5px; color: #9799a7; font-size: .72rem; }
.profile-pill { width: 42px; height: 42px; border: 1px solid #42444e; background: linear-gradient(155deg,#343640,#1b1d24); border-radius: 12px; font-weight: 700; }
.btn, .icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 43px; padding: 9px 15px;
  border: 1px solid var(--stroke-hi); border-radius: 10px; background: #202228; color: var(--text);
  font-size: .9rem; font-weight: 650; text-align: center; line-height: 1.2;
  transition: background .2s, border-color .2s, transform .2s;
}
.btn:hover, .icon-btn:hover { background: #2b2d35; border-color: #555863; }
.btn:active, .icon-btn:active { transform: translateY(1px); }
.btn.primary { background: #eeeeF2; border-color: #eeeef2; color: #15161a; }
.btn.primary:hover { background: #fff; border-color: #fff; }
.btn.ghost { background: #15161cd9; border-color: #3a3c45; }
.btn.ghost:hover { background: #2b2d35; }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 37px; padding: 7px 11px; font-size: .82rem; }
.icon-btn { position: relative; min-width: 42px; padding: 8px; }
.counter { position: absolute; top: -4px; right: -4px; min-width: 17px; height: 17px; padding: 1px 3px; border-radius: 99px; color: #121317; background: #e1e0eb; font-size: .62rem; }
.frame { width: min(100%,1390px); margin: 0 auto; padding: 27px clamp(18px,3.6vw,54px) 46px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin: 0 0 23px; }
.page-head h1, .empty h2, .panel h2, .panel h3 { margin: 0; letter-spacing: -.035em; line-height: 1.19; }
.page-head h1 { font-size: clamp(1.95rem,4vw,2.8rem); }
.page-head p, .panel > p { margin: 8px 0 0; color: var(--muted); }
.meta { color: var(--muted); font-size: .86rem; }
.hero {
  position: relative; display: flex; align-items: center; isolation: isolate; overflow: hidden;
  min-height: clamp(300px,30vw,400px); padding: clamp(23px,4vw,60px);
  border: 1px solid #32343e; border-radius: 23px;
  background: radial-gradient(ellipse at 80% 50%, #252733, transparent 61%), #131419;
}
.hero canvas { position: absolute; z-index: -2; right: 0; top: 0; width: 76%; height: 100%; opacity: .97; }
.hero:after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg,#15161b 0%,#15161bf6 21%,#15161bb3 42%,transparent 72%); pointer-events: none; }
.hero-copy { max-width: 620px; }
.eyebrow { color: #babdca; margin: 0 0 13px; text-transform: uppercase; font-size: .72rem; letter-spacing: .16em; font-weight: 750; display: flex; align-items: center; gap: 8px; }
.eyebrow .glyph { width: 15px; height: 15px; }
.hero h1 { margin: 0; text-wrap: balance; font-size: clamp(2.35rem,4.7vw,4.85rem); line-height: 1.02; letter-spacing: -.078em; font-weight: 760; }
.hero p:not(.eyebrow) { max-width: 440px; margin: 16px 0 23px; color: #bcbdc8; font-size: clamp(.94rem,1.5vw,1.04rem); }
.catalogue { margin-top: 33px; scroll-margin-top: 90px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 0 0 15px; }
.section-head h2 { margin: 0; font-size: clamp(1.38rem,2.5vw,1.8rem); line-height: 1.2; letter-spacing: -.04em; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.chip { min-height: 35px; border-radius: 8px; padding: 6px 11px; background: #15161b; border: 1px solid var(--stroke); color: var(--muted); font-size: .84rem; white-space: nowrap; }
.chip[aria-pressed=true], .chip:hover { color: var(--text); background: #272932; border-color: #3a3b45; }
.cards { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 14px; }
.character { position: relative; min-width: 0; border: 1px solid #2e3039; border-radius: 15px; overflow: hidden; background: #15161b; transition: border-color .2s; }
.character:hover { border-color: #575965; }
.character-hit { display: grid; width: 100%; padding: 0; text-align: left; border: 0; background: transparent; }
.character-hit:focus-visible { outline-offset: -3px; }
.char-art { position: relative; aspect-ratio: 1.23; overflow: hidden; }
.char-art:after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 42%,#0b0c108a); pointer-events: none; }
.avatar { display: grid; place-items: center; background-color: #252730; background-repeat: no-repeat; background-position: center 41%; }
.avatar.luna, .avatar.detective, .avatar.echo, .avatar.atlas {
  background-image: url("/portraits/catalog.png"); background-size: 400% auto;
}
.avatar.luna { background-position-x: 0%; }
.avatar.detective { background-position-x: 33.3333%; }
.avatar.echo { background-position-x: 66.6667%; }
.avatar.atlas { background-position-x: 100%; }
.avatar.violet { background-image: radial-gradient(circle at 66% 22%,#8476a1,#40344e 49%,#221e2e 80%); }
.avatar.steel { background-image: radial-gradient(circle at 66% 22%,#929bae,#465165 49%,#222831 80%); }
.avatar.moss { background-image: radial-gradient(circle at 66% 22%,#849b8b,#3d544a 49%,#202f2a 80%); }
.avatar.amber { background-image: radial-gradient(circle at 66% 22%,#a38367,#5c463a 49%,#2e2426 80%); }
.avatar > .glyph { width: 40%; height: 40%; opacity: .7; }
.avatar.luna > .glyph, .avatar.detective > .glyph, .avatar.echo > .glyph, .avatar.atlas > .glyph { display: none; }
.char-tag { position: absolute; z-index: 1; bottom: 10px; left: 10px; max-width: calc(100% - 20px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: #15161cd9; border: 1px solid #ffffff33; padding: 3px 7px; border-radius: 6px; font-size: .72rem; font-weight: 650; }
.char-copy { padding: 11px 13px 13px; }
.char-copy strong { display: block; margin: 0 0 4px; overflow-wrap: anywhere; font-size: 1.06rem; line-height: 1.22; letter-spacing: -.025em; }
.char-copy p { margin: 0; color: #b2b3bf; line-height: 1.35; font-size: .84rem; min-height: 2.7em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.favorite { position: absolute; top: 8px; right: 8px; min-width: 36px; min-height: 36px; background: #111217cc; border-color: #ffffff35; }
.favorite.active svg { fill: #e4e1f5; }
.character > .row { margin: 0 12px 11px; }
.panel {
  background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--radius);
  padding: clamp(15px,2.3vw,26px); min-width: 0;
}
.stack { display: grid; gap: 14px; }
.split { display: grid; grid-template-columns: minmax(0,1.3fr) minmax(245px,.85fr); gap: 18px; align-items: start; }
.placeholder, .empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty { background: #14151a; border: 1px dashed #363843; border-radius: 15px; }
.empty h2 { font-size: 1.45rem; color: var(--text); }
.empty p { margin: 8px auto 17px; max-width: 420px; }
.plain-link { color: #ddddeb; text-decoration: underline; text-decoration-color: #777989; text-underline-offset: 4px; }
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; min-width: 0; font-weight: 620; font-size: .89rem; }
.field small { color: var(--muted); font-weight: 400; }
.field input, .field textarea, .field select, .control {
  width: 100%; color: var(--text); background: #111217; border: 1px solid #373944; border-radius: 10px;
  min-height: 44px; padding: 9px 11px; font-size: 1rem; font-weight: 400;
}
.field textarea { min-height: 112px; resize: vertical; }
.field input::placeholder, .field textarea::placeholder, .control::placeholder { color: #838592; }
.field input:focus, .field textarea:focus, .field select:focus, .control:focus { border-color: #828496; outline: 0; }
.field select { appearance: none; padding-right: 31px; background-image: linear-gradient(45deg,transparent 50%, #abadb9 50%),linear-gradient(135deg,#abadb9 50%,transparent 50%); background-position: calc(100% - 16px) center,calc(100% - 11px) center; background-size: 5px 5px; background-repeat: no-repeat; }
.check { display: flex; align-items: flex-start; gap: 9px; font-size: .91rem; color: var(--muted); }
.check input { width: 17px; height: 17px; flex: 0 0 auto; accent-color: #babbcf; }
.form-error { color: var(--danger); margin: 0; font-size: .88rem; }
.avatar-list { display: flex; flex-wrap: wrap; gap: 7px; border: 0; padding: 0; margin: 0; }
.avatar-list legend { margin-bottom: 8px; font-size: .89rem; font-weight: 620; }
.avatar-pick { position: relative; }
.avatar-pick input { position: absolute; opacity: 0; }
.avatar-pick .avatar { width: 45px; height: 45px; border: 2px solid #292b32; border-radius: 10px; cursor: pointer; }
.avatar-pick input:checked + .avatar { border-color: #d5d4e4; }
.avatar-pick input:focus-visible + .avatar { outline: 2px solid white; outline-offset: 2px; }
.portrait { width: 45px; height: 45px; flex: 0 0 auto; border-radius: 11px; }
.detail-art { aspect-ratio: 2; border-radius: 11px; }
.detail-intro, .content-text { white-space: pre-wrap; overflow-wrap: anywhere; }
dialog {
  border: 1px solid #3b3d48; border-radius: 19px; background: #17191f; color: var(--text);
  width: min(92vw,520px); max-height: min(90dvh,800px); margin: auto; padding: clamp(16px,3vw,25px); overflow: auto;
}
dialog::backdrop { background: #06070acc; backdrop-filter: blur(5px); }
dialog h2 { margin: 0; font-size: 1.55rem; letter-spacing: -.045em; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 13px; }
.dialog-head .icon-btn { min-height: 36px; min-width: 36px; }
.dialog-copy { margin: 0 0 12px; color: var(--muted); }
.toast { position: fixed; z-index: 9; right: 20px; bottom: 20px; border-radius: 12px; border: 1px solid #51535f; background: #252733; padding: 13px 16px; max-width: min(90vw,400px); box-shadow: 0 12px 40px #0007; }
.plan-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; align-items: stretch; }
.plan-note { margin-top: 15px; }
.price-card { display: grid; align-content: start; gap: 15px; }
.price-card.recommended { border-color: #767689; background: linear-gradient(145deg,#252634,#16171e 66%); }
.plan-label { min-height: 31px; display: flex; align-items: center; justify-content: space-between; gap: 5px; }
.badge { display: inline-block; border: 1px solid #3d3f49; border-radius: 6px; padding: 2px 7px; color: #d6d5e1; font-size: .73rem; line-height: 1.35; }
.price { display: flex; gap: 6px; align-items: baseline; }
.price strong { font-size: 2.1rem; letter-spacing: -.055em; line-height: 1; }
.plan-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; color: var(--muted); font-size: .88rem; }
.plan-points li { display: flex; align-items: center; gap: 7px; }
.plan-points .glyph { width: 16px; height: 16px; color: #bebfce; }
.quota-line { display: grid; gap: 7px; margin-top: 14px; }
.quota-line span { display: flex; justify-content: space-between; gap: 7px; font-size: .87rem; }
.entry {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; padding: 10px;
  border: 1px solid var(--stroke); border-radius: 11px; background: #1a1b22; min-width: 0;
}
.entry:hover, .entry.active { background: #272933; border-color: #484b58; }
.entry-text { flex: 1; min-width: 0; }
.entry-text > * { display: block; overflow-wrap: anywhere; }
.entry .meta { margin-top: 2px; font-size: .79rem; }
.chat-layout { display: grid; grid-template-columns: minmax(170px,.28fr) minmax(0,1fr); gap: 14px; }
.chat-index { max-height: calc(100dvh - 135px); overflow: auto; }
.chat-index h2 { margin: 0 0 13px; font-size: 1.18rem; }
.chat-panel { height: max(510px,calc(100dvh - 129px)); padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--stroke); padding: 12px 15px; min-width: 0; }
.chat-head .entry-text strong { font-size: 1.07rem; }
.chat-head .entry-text .meta { font-size: .8rem; }
.chat-back { display: none; }
.chat-feed { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 14px; padding: 16px; }
.bubble { max-width: min(84%,760px); border-radius: 13px 13px 13px 4px; padding: 11px 13px; background: #22242d; border: 1px solid #30323d; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.user { align-self: end; background: #343644; border-color: #474958; border-radius: 13px 13px 4px 13px; }
.bubble.pending { opacity: .68; }
.bubble-label { display: block; color: #b8bac9; font-size: .74rem; letter-spacing: .04em; margin-bottom: 3px; font-weight: 700; }
.bubble-controls { display: flex; gap: 6px; }
.composer { display: grid; gap: 5px; padding: 11px 13px; background: #16171d; border-top: 1px solid var(--stroke); }
.compose-row { display: flex; gap: 8px; align-items: end; }
.compose-row textarea { min-height: 45px; max-height: 118px; resize: vertical; }
.compose-row .icon-btn { flex: 0 0 45px; height: 45px; background: #ebebf0; color: #15161a; }
.compose-row .icon-btn:hover { background: #fff; }
.composer > small { color: var(--muted); font-size: .73rem; }
.admin-grid { display: grid; gap: 13px; grid-template-columns: repeat(4,1fr); }
.stat strong { display: block; font-size: 1.65rem; line-height: 1.1; letter-spacing: -.05em; }
.admin-list { display: grid; gap: 9px; }
.admin-item { display: flex; align-items: center; justify-content: space-between; gap: 13px; border: 1px solid var(--stroke); background: #191b21; border-radius: 11px; padding: 11px; overflow-wrap: anywhere; }
.admin-item .actions { flex-shrink: 0; }
.notice { padding: 13px; background: #1d1e26; border: 1px solid var(--stroke); border-radius: 12px; }
.notice h3 { margin: 0 0 5px; }
.notice p { margin: 0 0 6px; }
.bottom-nav { display: none; }
@media (max-width: 1110px) {
  :root { --rail: 194px; }
  .top-title { display: none; }
  .top { justify-content: end; }
  .cards { gap: 11px; }
}
@media (max-width: 880px) {
  :root { --rail: 171px; }
  .sidebar { padding-inline: 10px; }
  .cards { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .char-art { aspect-ratio: 1.5; }
  .search { width: clamp(155px,27vw,245px); }
  .plan-grid { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .layout { display: block; padding-bottom: calc(65px + var(--safe-bottom)); }
  .sidebar { display: none; }
  .top { height: auto; min-height: 63px; padding: max(8px,env(safe-area-inset-top,0px)) 13px 8px; justify-content: space-between; gap: 7px; }
  .top .logo { display: inline-flex; margin-left: 0; align-self: center; gap: 6px; }
  .top .logo img { width: 29px; height: 29px; }
  .top .logo span { font-size: 22px; }
  .top-actions { gap: 6px; }
  .top-create, .key { display: none; }
  .search { width: clamp(113px,36vw,210px); min-height: 40px; padding-inline: 7px; gap: 5px; }
  .search input { font-size: 1rem; }
  .search svg { width: 15px; }
  .top .btn, .top .icon-btn, .profile-pill { min-height: 40px; min-width: 39px; padding-inline: 9px; }
  .profile-pill { height: 40px; width: 39px; }
  .frame { padding: 15px 13px 24px; }
  .page-head { align-items: start; flex-direction: column; gap: 12px; }
  .hero { min-height: 300px; border-radius: 17px; padding: 21px 16px; }
  .hero canvas { width: 100%; }
  .hero:after { background: linear-gradient(90deg,#15161bf5,#15161bb4 64%,#15161b42); }
  .hero h1 { font-size: clamp(2.05rem,9vw,3.4rem); letter-spacing: -.068em; }
  .hero p:not(.eyebrow) { margin-block: 11px 18px; }
  .hero .actions { gap: 6px; }
  .hero .btn { min-height: 41px; padding: 8px 10px; font-size: .82rem; }
  .catalogue { margin-top: 23px; }
  .filters { flex-wrap: nowrap; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: thin; }
  .cards { gap: 8px; }
  .character { border-radius: 12px; }
  .char-art { aspect-ratio: 1.04; }
  .char-copy { padding: 8px; }
  .char-copy strong { font-size: .96rem; }
  .char-copy p { font-size: .79rem; }
  .char-tag { left: 6px; bottom: 6px; font-size: .66rem; }
  .favorite { min-width: 32px; min-height: 32px; right: 6px; top: 6px; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); position: fixed; z-index: 5; inset: auto 0 0;
    min-height: 61px; padding: 3px 4px var(--safe-bottom); background: #111217f5; border-top: 1px solid #2d2e37; backdrop-filter: blur(14px);
  }
  .bottom-nav .nav-item { flex-direction: column; justify-content: center; gap: 4px; padding: 6px 2px; font-size: .67rem; line-height: 1; white-space: nowrap; }
  .bottom-nav .nav-item .glyph { width: 18px; height: 18px; }
  .split, .chat-layout { grid-template-columns: 1fr; gap: 10px; }
  .chat-index:has(+ .chat-panel) { display: none; }
  .chat-back { display: inline-flex; }
  .chat-panel { height: calc(100dvh - 153px - var(--safe-bottom) - env(safe-area-inset-top,0px)); min-height: 320px; }
  .chat-feed { padding: 10px; }
  .bubble { max-width: 92%; }
  .chat-head { padding: 9px; }
  .chat-head .portrait { width: 34px; height: 34px; }
  .toast { bottom: calc(68px + var(--safe-bottom)); right: 10px; }
  .admin-grid { grid-template-columns: 1fr 1fr; }
  .admin-item { flex-wrap: wrap; }
}
@media (max-width: 350px) {
  .top .logo span, .search svg, .hero .ghost .glyph { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; scroll-behavior: auto !important; transition: none !important; }
}
