:root {
  color-scheme: dark;
  --bg:#100e17; --surface:#191522; --raised:#211b2d; --ink:#eee5ff; --muted:#b8accb;
  --line:#30273d; --accent:#9966ed; --bright:#b68aff; --lavender:#c4a4ff;
  --shadow:0 24px 70px #0806119c; --radius:18px;
  font-family: "Segoe UI", system-ui, sans-serif;
  color:var(--ink);
  background:var(--bg);
}
* { box-sizing:border-box }
[hidden] { display:none !important }
body { margin:0; display:flex; flex-direction:column; height:100dvh; height:var(--viewport-height,100dvh); overflow:hidden }
button, select { font:inherit }
a { color:inherit; text-decoration:none }
button { cursor:pointer }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible { outline:2px solid var(--lavender); outline-offset:3px }
svg { width:22px; height:22px; display:block; flex:none }
.header { position:relative; z-index:3; flex:none; min-height:70px; display:grid; grid-template-columns:1fr auto 1fr; align-items:center; gap:16px; padding:0 clamp(14px, 3vw, 48px); border-bottom:1px solid var(--line); background:var(--bg) }
.brand { justify-self:start; display:flex; align-items:center; gap:10px; font-size:1.04rem; font-weight:800; letter-spacing:.18em; min-height:44px }
#brand-mark { display:grid; place-items:center; width:36px; height:36px; border-radius:12px; color:var(--ink); background:linear-gradient(145deg,#6a3db6,#382654); border:1px solid #9a69e8a8; box-shadow:inset 0 1px #e5d4ff35 }
#brand-mark svg { width:23px; height:23px }
.nav { position:relative; display:flex; align-items:stretch; height:70px }
.nav a { display:grid; place-items:center; min-width:48px; padding:0 clamp(7px,1.3vw,22px); font-size:.77rem; letter-spacing:.07em; font-weight:700; color:var(--muted); transition:color 150ms,background 150ms }
.nav a:hover { color:var(--ink); background:#c6a9ff0a }
.nav a[aria-current="page"] { color:var(--ink) }
.nav-line { position:absolute; bottom:0; left:0; height:2px; width:var(--line-width,0); border-radius:10px; pointer-events:none; transform:translateX(var(--line-x,0)); background:var(--bright); box-shadow:0 -2px 11px #b68aff70; transition:transform 260ms cubic-bezier(.22,.72,.22,1),width 260ms cubic-bezier(.22,.72,.22,1) }
.actions { justify-self:end; display:flex; align-items:center; gap:8px }
.icon-button, .gem { min-width:44px; height:44px; display:inline-flex; align-items:center; justify-content:center; gap:5px; flex:none }
.icon-button { position:relative; border:1px solid transparent; border-radius:12px; background:transparent; color:var(--muted); transition:background 150ms,color 150ms }
.icon-button:hover, .icon-button[aria-expanded="true"] { color:var(--ink); background:var(--raised) }
.profile { border-radius:50%; color:var(--lavender); background:#2b1d42; border-color:#4c3471 }
.gem { padding:0 10px; color:var(--lavender); font-size:.82rem; white-space:nowrap; letter-spacing:.03em }
.gem svg { width:18px; height:18px }
.gem[data-changed="true"] { animation:gem 230ms ease-out }
@keyframes gem { 50% { transform:scale(1.12) } }
#notice-button[data-unread="true"]::after { content:""; width:6px; height:6px; border-radius:50%; background:var(--bright); position:absolute; right:7px; top:7px }
.skip { position:fixed; z-index:10; top:9px; left:9px; background:var(--raised); padding:12px; border-radius:8px; transform:translateY(-160%) }
.skip:focus { transform:none }
main { position:relative; min-height:0; flex:1; overflow:auto }
main:focus-visible, #section:focus-visible { outline:none }
#ai { display:flex; flex-direction:column; height:100%; min-height:0 }
.chat-top { min-height:43px; flex:none; display:flex; flex-wrap:wrap; align-items:center; gap:5px 14px; padding:4px clamp(8px,2vw,24px); background:var(--surface); border-bottom:1px solid var(--line) }
.model-control { display:flex; align-items:center; gap:9px; color:var(--muted); font-size:.82rem }
select { appearance:none; padding:6px 27px 6px 9px; color:var(--ink); background:var(--raised) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23715333' stroke-width='1.5'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E") right 7px center/13px no-repeat; border:1px solid var(--line); border-radius:8px }
.ai-state { display:flex; align-items:center; min-height:25px; gap:7px; color:var(--muted); font-size:.79rem; max-width:100% }
.state-art { position:relative; width:18px; flex:none; display:flex; gap:3px; align-items:center; justify-content:center }
.state-art i { display:none; width:4px; height:4px; border-radius:50%; background:var(--bright) }
.ai-state[data-state="idle"] i:first-child, .ai-state[data-state="completed"] i:first-child { display:block; width:6px; height:6px; background:#70d6a7 }
.ai-state[data-state="connecting"] i, .ai-state[data-state="queued"] i, .ai-state[data-state="cooling"] i { display:block; animation:pulse 1.4s ease-in-out infinite alternate }
.ai-state[data-state="processing"] i { display:block; animation:bounce .82s ease-in-out infinite alternate }
.ai-state i:nth-child(2) { animation-delay:.13s !important }
.ai-state i:nth-child(3) { animation-delay:.26s !important }
.ai-state[data-state="loading"] .state-art { height:14px; width:14px; border-radius:50%; border:2px solid #594078; border-top-color:var(--lavender); animation:spin .8s linear infinite }
.ai-state[data-state="thinking"] .state-art { animation:spin 1.75s linear infinite }
.ai-state[data-state="thinking"] i:nth-child(-n+2) { display:block }
.ai-state[data-state="thinking"] i:nth-child(2) { background:var(--lavender) }
.ai-state[data-state="generating"] i:first-child { display:block; width:5px; height:10px; border-radius:2px; animation:pulse .7s ease-in-out infinite alternate }
.ai-state[data-state="error"] { color:#ffc1cc }
.ai-state[data-state="error"] i:first-child { display:block; background:#ff9caa }
.subtle { background:transparent; color:var(--lavender); border:1px solid var(--line); padding:5px 9px; border-radius:8px; font-size:.8rem }
@keyframes pulse { to { opacity:.22 } }
@keyframes bounce { to { transform:translateY(-4px); opacity:.56 } }
@keyframes spin { to { transform:rotate(360deg) } }
iframe { display:block; width:100%; border:0; flex:1; min-height:0; background:var(--bg) }
#section { min-height:100%; background:radial-gradient(ellipse 900px 470px at 82% -60px,#302048 0%,#100e17 74%) }
.scene { width:min(100%, 1120px); padding:clamp(25px,5vw,68px) clamp(16px,4vw,54px) 54px; margin:auto; animation:enter 230ms ease-out both }
.section-intro { position:relative; padding:0 0 clamp(23px,4vw,42px); border-bottom:1px solid var(--line) }
.section-mark { display:grid; place-items:center; color:var(--lavender); width:44px; height:44px; border:1px solid #62458495; background:#32224c; border-radius:13px; margin-bottom:19px }
.section-mark svg { width:24px; height:24px }
.pill, .card-art span { display:inline-flex; align-items:center; padding:5px 10px; border:1px solid #6e4ca3; border-radius:999px; color:#e3d1ff; background:#301e4a; font-size:.8rem; font-weight:650; white-space:nowrap }
.section-intro h1 { margin:7px 0 10px; font-size:clamp(2.2rem,6vw,4.3rem); letter-spacing:-.06em; line-height:1.06 }
.section-intro p { margin:0; max-width:600px; color:var(--muted); line-height:1.65; font-size:clamp(1rem,1.55vw,1.13rem) }
.section-grid { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:clamp(24px,6vw,90px); margin-top:27px; align-items:start }
.section-grid h2, .monitor h2, .popover h2, .settings h2 { font-size:1.125rem; letter-spacing:-.018em; margin:0 0 14px }
.categories ul { margin:0; padding:0; display:grid; grid-template-columns:1fr 1fr; gap:7px; list-style:none }
.categories li { padding:9px 11px; border:1px solid var(--line); border-radius:9px; background:var(--surface); font-size:.9rem; color:var(--muted) }
.card { overflow:hidden; border:1px solid var(--line); border-radius:var(--radius); background:var(--surface); transition:transform 170ms,border-color 170ms; max-width:440px }
@media (hover:hover) { .card:hover { transform:translateY(-3px); border-color:#624a7c } }
.card-art { position:relative; min-height:155px; height:clamp(160px,16vw,230px); background:#2b2040 url("/dorium/ui/preview-art.jpg") 0 center/300% auto no-repeat }
.card-art[data-art="stories"] { background-position:50% 50% }
.card-art[data-art="marketplace"] { background-position:100% 50% }
.card-art span { position:absolute; top:12px; left:12px; background:#140c23e8 }
.card-body { padding:15px 17px }
.card-byline { font-size:.81rem; color:var(--lavender) !important }
.card-body h3 { margin:3px 0 6px; font-size:1.28rem }
.card-body p { margin:0; color:var(--muted); line-height:1.45 }
.card dl { display:flex; gap:21px; margin:13px 0 11px; font-size:.85rem }
.card dt { color:var(--muted) }
.card dd { margin:2px 0 0 }
.card-foot { border-top:1px solid var(--line); padding-top:9px; color:var(--lavender); font-size:.85rem }
.monitor { margin-top:25px; padding:clamp(12px,2.5vw,25px); background:var(--surface); border:1px solid var(--line); border-radius:var(--radius) }
.monitor-head { display:flex; justify-content:space-between; flex-wrap:wrap; gap:8px; align-items:start }
.monitor-head span { color:var(--muted); font-size:.86rem }
.bars { --meter:#9966ed; display:flex; gap:5px; align-items:center; height:42px; margin-bottom:9px }
.bars[data-level="high"] { --meter:#7b9dff }.bars[data-level="overload"] { --meter:#fa9f68 }
.bars[data-level="battery"] { --meter:#f3d477 }.bars[data-level="critical"] { --meter:#ff85a2 }.bars[data-level="offline"] { --meter:#958da0 }
.bars i { width:5px; height:28px; border-radius:4px; background:var(--meter); transform:scaleY(.28) }
.bars i:nth-child(3n) { transform:scaleY(.75) }.bars i:nth-child(4n) { transform:scaleY(.52) }
.bars[data-live="true"] i { animation:bounce .66s ease-in-out infinite alternate }
.monitor-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:7px }
.monitor-grid div { display:flex; justify-content:space-between; gap:6px; color:var(--muted); font-size:.88rem; padding:9px 11px; border:1px solid var(--line); border-radius:9px }
.monitor-grid strong { color:var(--ink) }
.popover { position:absolute; right:clamp(10px,3vw,48px); top:calc(100% + 7px); width:min(310px, calc(100vw - 20px)); padding:17px; border:1px solid var(--line); border-radius:var(--radius); background:var(--surface); box-shadow:var(--shadow); animation:enter 185ms ease-out both }
.popover p { margin:0; color:var(--muted) }
.profile-list,.notice-list { padding:0; margin:0; list-style:none }
.profile-list li > span,.profile-list button,.notice-list li { width:100%; min-height:36px; display:flex; align-items:center; justify-content:space-between; gap:8px; border:0; padding:5px 7px; border-radius:7px; background:none; color:var(--muted); font-size:.88rem; text-align:left }
.profile-list button { min-height:44px; color:var(--ink); background:var(--raised) }
.profile-list button:hover { background:#36274e }
.profile-list small,.notice-list time { color:var(--lavender); font-size:.79rem; white-space:nowrap }
.settings { width:min(740px, calc(100% - 22px)); max-height:min(680px, calc(100dvh - 24px)); padding:0; color:var(--ink); background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow); animation:enter 190ms ease-out }
.settings::backdrop { background:#080610aa }
.dialog-head { position:sticky; top:0; z-index:1; display:flex; align-items:center; justify-content:space-between; padding:10px 16px 10px 21px; background:var(--surface); border-bottom:1px solid var(--line) }
.dialog-head h2 { margin:0 }
.settings-body { display:grid; grid-template-columns:200px minmax(0,1fr) }
.settings-nav { display:flex; flex-direction:column; gap:4px; padding:13px; border-right:1px solid var(--line) }
.settings-nav button { min-height:42px; text-align:left; color:var(--muted); background:transparent; border:0; border-radius:9px; padding:8px 10px }
.settings-nav button:hover,.settings-nav button[aria-selected="true"] { color:var(--ink); background:var(--raised) }
#settings-content { min-width:0; padding:12px clamp(14px,3vw,32px) 24px }
#settings-content h3 { font-size:1.18rem }
#settings-content p { color:var(--muted); line-height:1.55 }
.setting-row { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:7px; padding:10px 0; min-height:48px; border-bottom:1px solid var(--line) }
.setting-row select { min-height:38px; max-width:100% }
.setting-row input { width:21px; height:21px; accent-color:var(--accent) }
@keyframes enter { from { transform:translateY(7px); opacity:0 } to { transform:translateY(0); opacity:1 } }
@media (max-width:890px) {
  .header { grid-template-columns:1fr 1fr; min-height:0; gap:0 }
  .brand, .actions { min-height:54px }
  .nav { grid-row:2; grid-column:1 / -1; justify-content:space-between; height:44px }
  .nav a { flex:1; padding:0 4px; font-size:clamp(.63rem,1.65vw,.77rem); letter-spacing:.03em }
  .popover { top:56px }
}
@media (max-width:600px) {
  .section-grid { grid-template-columns:1fr; gap:22px }
  .card { max-width:none }
  .monitor-grid { grid-template-columns:repeat(2,minmax(0,1fr)) }
  .settings-body { grid-template-columns:1fr }
  .settings-nav { flex-direction:row; overflow:auto; border-right:0; border-bottom:1px solid var(--line) }
  .settings-nav button { flex:none; min-height:44px }
  .model-control > span { display:none }
  .scene { padding-bottom:34px }
}
html[data-keyboard="true"] .header .brand,html[data-keyboard="true"] .header .actions { min-height:44px }
html[data-keyboard="true"] .header .nav { height:42px }
@media (prefers-reduced-motion:reduce) {
  *,*::before,*::after { animation:none !important; transition:none !important; scroll-behavior:auto !important }
}
html[data-motion="reduced"] *,html[data-motion="reduced"] *::before,html[data-motion="reduced"] *::after { animation:none !important; transition:none !important; scroll-behavior:auto !important }

:root {
  color-scheme:light;
  --bg:#fbf9f3; --surface:#fffefa; --raised:#f3eee3; --ink:#2e2921; --muted:#685f50;
  --line:#e0d7c9; --accent:#785c41; --bright:#aa794f; --lavender:#715333;
  --shadow:0 18px 44px #4e3a2024; --radius:13px;
}
html[data-text-size="small"] { font-size:14px }
html[data-text-size="large"] { font-size:18px }
.header { background:var(--surface) }
#brand-mark { background:#eee3d2; border-color:#dbcab1; color:#735735; box-shadow:none }
.nav a:hover { background:#8c63430b }
.nav-line { box-shadow:none }
.profile { background:#f0e5d7; border-color:#e3d4be }
.pill,.card-art span { background:#f2eadb; color:#6e5435; border-color:#e4d6c0 }
.section-mark { background:#f1e8da; border-color:#e4d5be }
.section-intro h1 { font-size:clamp(2rem,5vw,3.3rem) }
.profile-list button:hover { background:#eee3d2 }
#section { background:var(--bg) }
.simple-page { width:min(100%,900px); margin:0 auto; padding:clamp(20px,5vw,65px) clamp(13px,4vw,35px) 45px }
.simple-page h1 { margin:0 0 7px; font-size:clamp(1.85rem,4.5vw,2.65rem); letter-spacing:-.045em }
.simple-page > p { color:var(--muted); margin:0 0 24px; line-height:1.5 }
.story-list article { display:flex; gap:14px; padding:16px; border:1px solid var(--line); background:var(--surface); border-radius:var(--radius) }
.story-list h2,.story-list p { margin:0 0 5px }
.story-list h2 { font-size:1.12rem }
.story-list p,.story-list small { color:var(--muted) }
.story-icon { width:40px; height:40px; flex:none; display:grid; place-items:center; border-radius:8px; color:var(--lavender); background:var(--raised) }
.bot-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px }
.bot-tile { display:flex; align-items:center; text-align:left; gap:10px; min-height:71px; padding:8px; border:1px solid var(--line); border-radius:var(--radius); color:var(--ink); background:var(--surface); transition:background 150ms,border-color 150ms }
.bot-tile:hover { background:#f7f0e4; border-color:#c5a685 }
.bot-tile strong,.bot-tile small { display:block; overflow-wrap:anywhere }
.bot-tile small { color:var(--muted); margin-top:3px; font-size:.84rem }
.portrait { display:block; width:49px; aspect-ratio:1; flex:none; border-radius:11px; background:#eadcc9 url("/dorium/ui/portraits.jpg") var(--px) var(--py)/300% 300% no-repeat }
.bot-usage { margin-top:22px; color:var(--muted); font-size:.83rem }
.bot-usage strong,.bot-usage span { display:block }
.bot-usage strong { color:var(--ink); margin-bottom:3px }
.bot-chat { height:100%; max-width:840px; display:flex; flex-direction:column; padding-top:18px; padding-bottom:12px }
#section[data-route="chatbot"] { height:100% }
.bot-heading { display:flex; align-items:center; gap:10px; padding-bottom:10px; border-bottom:1px solid var(--line) }
.bot-heading h1 { margin:0; font-size:1.2rem }
.bot-heading .portrait { width:38px }
.bot-heading button,.status-row + button { min-height:44px }
.bot-transcript { flex:1; min-height:70px; overflow:auto; padding:13px 1px; display:flex; align-items:start; flex-direction:column; gap:8px }
.bot-transcript p,.bot-live:not(:empty) { padding:9px 12px; margin:0; max-width:90%; white-space:pre-wrap; overflow-wrap:anywhere; border:1px solid var(--line); border-radius:12px; background:var(--surface); line-height:1.55 }
.bot-transcript p[data-role="user"] { align-self:end; background:#eee2d0 }
.bot-form { display:flex; align-items:end; gap:7px; flex:none }
.bot-form textarea { flex:1; min-width:0; resize:none; max-height:95px; font:inherit; color:var(--ink); background:var(--surface); border:1px solid var(--line); border-radius:10px; padding:7px }
.bot-form button { min-height:44px }
.bot-error:empty { display:none }
.bot-chat .bot-usage { margin-top:8px }
.solid { border:1px solid #6c5039; border-radius:9px; background:#75573e; color:white; padding:8px 12px }
.solid:disabled { opacity:.58; cursor:default }
.writing-dots,.ai-state[data-state="processing"] .state-art,.ai-state[data-state="generating"] .state-art { display:inline-flex; position:relative; gap:4px; align-items:center; padding-inline:3px; margin-inline-start:3px; height:20px }
.writing-dots i,.ai-state:is([data-state="processing"],[data-state="generating"]) .state-art i { display:block; width:5px; height:5px; border-radius:50%; background:#926541; animation:dots-wave 1.12s ease-in-out infinite }
.writing-dots i:nth-child(2) { animation-delay:.13s }
.writing-dots i:nth-child(3) { animation-delay:.26s }
@keyframes dots-wave { 0%,100% { transform:translateX(0) translateY(0) rotate(0); opacity:.6 } 35% { transform:translateX(2px) translateY(-5px) rotate(150deg); opacity:1 } 65% { transform:translateX(-1px) translateY(2px) rotate(310deg); opacity:.85 } }
.live-status { display:grid; gap:8px }
.status-row { min-height:75px; display:flex; align-items:center; justify-content:space-between; gap:12px; padding:10px 15px; background:var(--surface); border:1px solid var(--line); border-radius:var(--radius) }
.status-row h2 { font-size:1rem; margin:0 0 3px }
.status-row strong { color:var(--muted); font-size:.9rem; font-weight:500 }
.status-row .bars { --meter:#a16c70; height:30px; margin:0 }
.status-row .bars i { height:24px }
.status-row .bars[data-live="true"] i { animation:equalize 960ms ease-in-out 4 alternate both }
.status-row .bars i:nth-child(3n+1) { animation-delay:.12s }
.status-row .bars i:nth-child(3n+2) { animation-delay:.36s }
@keyframes equalize { from { transform:scaleY(.25) } to { transform:scaleY(1) } }
#status-refresh { justify-self:start; min-height:44px }
@media(max-width:680px) { .bot-grid { grid-template-columns:repeat(2,minmax(0,1fr)) } }
@media(max-width:600px) {
  .nav { display:grid; grid-template-columns:.56fr 1fr .9fr 1.54fr .9fr }
  .nav a { min-width:0; padding-inline:2px; font-size:clamp(.6rem,2.55vw,.74rem) }
}
@media(max-width:400px) { .bot-tile { gap:6px; font-size:.87rem } .bot-tile .portrait { width:38px } }
.writing-dots { animation:dots-tilt 1.96s ease-in-out infinite }
@keyframes dots-tilt { 0%,100% { transform:rotate(0) } 38% { transform:rotate(-16deg) scale(.86) } 68% { transform:rotate(12deg) scale(1.02) } }
