:root {
  color-scheme: dark;
  --bg: #100d12; --panel: #1b161e; --surface: #241d27; --line: #3b303e;
  --text: #f8f3f7; --muted: #c3b4c2; --accent: #f48697; --fill: #a81943; --good: #8ddaaf;
  --header: 4rem; --side: 15rem;
  font-family: system-ui, sans-serif;
}
:root[data-accent="ruby"] { --accent: #fe9f87; --fill: #9c361c; }
:root[data-accent="plum"] { --accent: #ec9eee; --fill: #863286; }
:root[data-light="true"] {
  color-scheme: light;
  --bg: #f7f2f5; --panel: #fff; --surface: #f5edf2; --line: #dac9d4;
  --text: #231822; --muted: #63535f; --accent: #9c1940; --good: #19744b;
}
:root[data-light="true"][data-accent="ruby"] { --accent: #992f17; }
:root[data-light="true"][data-accent="plum"] { --accent: #7b2780; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--accent); }
button, .button, input, textarea, select { font: inherit; }
button, .button { background: var(--fill); color: white; border: 1px solid transparent; font-weight: 650; padding: .52rem .83rem; border-radius: .48rem; cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .button:hover { filter: brightness(1.16); }
button:disabled { opacity: .55; cursor: default; }
button.secondary { background: var(--surface); border-color: var(--line); color: var(--text); }
button.danger { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input, textarea, select { color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: .4rem; padding: .52rem .65rem; width: 100%; min-width: 0; }
input[type="checkbox"] { accent-color: var(--fill); width: 1.15rem; height: 1.15rem; }
input[type="checkbox"][role="switch"] { appearance: none; width: 2.2rem; height: 1.25rem; border-radius: 1rem; padding: 2px; display: grid; align-items: center; }
input[type="checkbox"][role="switch"]::before { content: ""; width: .85rem; height: .85rem; background: var(--muted); border-radius: 50%; }
input[type="checkbox"][role="switch"]:checked { background: var(--fill); }
input[type="checkbox"][role="switch"]:checked::before { justify-self: end; background: white; }
select[multiple] { min-height: 6.5rem; }
textarea { resize: vertical; min-height: 5rem; }
.masthead { display: flex; align-items: center; gap: 1rem; padding: 0 max(1rem, 3vw); height: var(--header); position: sticky; top: 0; z-index: 3; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; gap: .9rem; align-items: center; color: var(--text); font-size: 1.2rem; font-weight: 750; text-decoration: none; }
.mark { display: block; width: 1.45rem; height: 1.45rem; transform: rotate(45deg); border: 2px solid var(--accent); background: var(--fill); border-radius: .2rem; box-shadow: inset 0 0 0 3px var(--panel); }
#account { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
#account select { max-width: min(36vw, 17rem); }
#account button { white-space: nowrap; }
.connection { color: var(--good); font-size: .82rem; }
#sidebar { border-right: 1px solid var(--line); background: var(--panel); position: fixed; inset: var(--header) auto 0 0; width: var(--side); overflow: auto; z-index: 2; padding: 1rem .8rem; }
#navigation { display: grid; gap: .18rem; }
#navigation button { display: flex; align-items: center; gap: .66rem; text-align: left; background: transparent; color: var(--muted); padding: .44rem .72rem; font-size: .9rem; font-weight: 560; }
#navigation button[aria-current="page"] { background: var(--surface); border-color: var(--line); color: var(--accent); }
.nav-icon { width: 1.25rem; text-align: center; color: var(--accent); }
.legal { display: flex; gap: .9rem; padding: 1rem .72rem; font-size: .82rem; }
#workspace { margin-left: var(--side); max-width: 102rem; padding: clamp(1rem, 4vw, 3rem); }
.view-heading h1 { margin: 0; font-size: clamp(1.9rem, 4vw, 2.65rem); line-height: 1.2; }
.view-heading p, .help, .empty { color: var(--muted); }
.startup { max-width: 36rem; margin: min(17vh, 10rem) auto 0; padding: 2rem; text-align: center; }
.spinner { display: inline-block; width: 1.9rem; height: 1.9rem; border: .18rem solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: .8rem; margin: 1rem 0; padding: clamp(.85rem, 2.5vw, 1.5rem); min-width: 0; }
.card h2, .card h3 { margin: 0 0 .8rem; font-size: 1.13rem; }
.grid, .fields { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit,minmax(min(100%,17rem),1fr)); }
.fields .full { grid-column: 1 / -1; }
label.field { display: grid; gap: .3rem; align-content: start; font-size: .91rem; }
label.toggle { display: flex; align-items: center; gap: .6rem; }
.section-divider { color: var(--muted); font-size: .85rem; }
.entry { background: var(--surface); border: 1px solid var(--line); border-radius: .6rem; padding: .74rem; margin: .5rem 0; }
.entry summary { cursor: pointer; font-weight: 630; overflow-wrap: anywhere; }
.entry[open] summary { margin-bottom: .8rem; }
.toolbar, .form-actions { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.toolbar > input, .toolbar > select { width: auto; max-width: 100%; }
.form-actions { margin-top: 1.15rem; border-top: 1px solid var(--line); padding-top: .8rem; }
.form-actions .help { margin-right: auto; }
#feedback[data-error="true"], .error { color: var(--accent); }
.server-name { display: flex; align-items: center; gap: .75rem; }
.server-name img { border-radius: .45rem; }
.metric { display: grid; gap: .2rem; padding: .7rem .9rem; background: var(--surface); border: 1px solid var(--line); border-radius: .55rem; }
.metric strong { font-size: 1.4rem; }
.chart { display: flex; align-items: end; height: 10rem; gap: .2rem; overflow: hidden; }
.chart progress { appearance: none; flex: 1; min-width: 0; height: .77rem; transform: rotate(-90deg); overflow: visible; background: transparent; }
.chart .bar { flex: 1; min-width: 1px; height: 9.5rem; display: grid; align-items: end; }
.chart .bar span { display: block; height: 100%; }
.chart circle { fill: var(--accent); }
.table-wrap { overflow: auto; }
table { border-collapse: collapse; width: 100%; }
td, th { text-align: left; padding: .45rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
td pre { white-space: pre-wrap; max-width: 24rem; }
.embed-preview { color-scheme: dark; max-width: 38rem; padding: .75rem .95rem; margin: .75rem 0; background: #25242a; border-radius: .4rem; color: #f4f2f6; overflow-wrap: anywhere; white-space: pre-wrap; }
.embed-preview img { max-width: 100%; max-height: 16rem; object-fit: contain; border-radius: .35rem; display: block; }
.embed-preview .thumb { width: 4rem; float: right; }
.embed-preview .icon { width: 1.5rem; height: 1.5rem; display: inline-block; vertical-align: middle; margin-right: .4rem; }
.embed-fields { display: flex; flex-wrap: wrap; gap: .6rem; }
.embed-fields > div { flex: 1 1 100%; }
.embed-fields > .inline { flex: 1 1 24%; }
.visually-hidden, .skip:not(:focus) { position: absolute; clip-path: inset(50%); }
.skip:focus { position: fixed; z-index: 8; background: var(--bg); padding: .5rem; }
@media (max-width: 830px) {
  #workspace { margin-left: 0; }
  #sidebar { transform: translateX(-100%); visibility: hidden; transition: transform .16s ease-out; }
  #sidebar.open { transform: none; visibility: visible; box-shadow: 0 0 2rem #0007; }
  .connection { display: none; }
  .masthead { gap: .55rem; }
}
@media (prefers-reduced-motion: reduce) { *, *::before { animation-duration: .001ms !important; transition-duration: .001ms !important; } }

.ticket-preview-row { margin-bottom: .5rem; }
.ticket-button-preview { color: #fff; background: #5865f2; }
.ticket-button-preview[data-button-style="2"] { background: #4e5058; }
.ticket-button-preview[data-button-style="3"] { background: #248046; }
.ticket-button-preview[data-button-style="4"] { background: #c5343d; }

.message-chart { margin-block: 1.25rem; min-width: 0; }
.message-plot { display: grid; grid-template-columns: 4.1rem minmax(0, 1fr); grid-template-rows: 12rem auto; gap: .45rem; }
.message-y { display: flex; flex-flow: column; justify-content: space-between; text-align: right; color: var(--muted); }
.message-bars { display: flex; gap: 2px; border-left: 1px solid var(--muted); border-bottom: 1px solid var(--muted); padding-inline: 3px; }
.message-slot { flex: 1 0 0; min-width: 0; display: flex; align-items: end; justify-content: center; }
.message-slot.missing { opacity: .45; }
.message-slot.missing::before { content: ""; width: 45%; border-bottom: 1px dashed var(--muted); }
.message-bar { width: 100%; max-width: 26px; padding: 0; min-width: 1px; background: var(--accent); border: 0; border-radius: .2rem .2rem 0 0; }
.message-bar:focus-visible { outline-offset: 0; z-index: 1; }
.message-time { grid-column: 2; display: flex; justify-content: space-between; gap: .4rem; font-size: .78rem; color: var(--muted); }
.message-chart output { display: block; margin-block: .5rem; }
@media (max-width: 520px) {
  .message-plot { grid-template-columns: 2.8rem minmax(0, 1fr); grid-template-rows: 9rem auto; }
  .message-bars { gap: 1px; }
}

:root[data-theme="cirno"] {
  color-scheme: dark;
  --bg: #0b1729; --panel: #10243a; --surface: #17324d; --line: #396280;
  --text: #eaf8ff; --muted: #a7c5df; --accent: #78d9ff; --fill: #16629b;
  --good: #8ddaaf; --error: #ffb3bd;
  scrollbar-color: #396280 #0b1729;
}
:root[data-theme="cirno"] .mark { border-radius: .08rem; box-shadow: inset 0 0 0 3px var(--panel), 0 0 .5rem #78d9ff44; }
:root[data-theme="cirno"] button.danger,
:root[data-theme="cirno"] #feedback[data-error="true"],
:root[data-theme="cirno"] .error { color: var(--error); }
