@charset "UTF-8";

:root {
  color-scheme: dark;
  --bg: #0b1020;
  --surface: #11192e;
  --surface-raised: #18223b;
  --input: #0d1528;
  --ink: #edf0f8;
  --muted: #a4b0ca;
  --faint: #7484a6;
  --brand: #8b8dff;
  --accent: #72ddeb;
  --line: #2b3751;
  --danger: #ffaaaa;
  --success: #79ddbe;
  --warning: #f4d494;
  --radius: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
  font-size: 15px;
  background: var(--bg);
  color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button, a, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .52; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 4px; }
button, a, input, select, textarea, summary { outline-offset: 4px; }
:focus-visible { outline: 3px solid var(--accent); }
input, textarea, select { color: var(--ink); background: var(--input); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; width: 100%; min-width: 0; }
input::placeholder, textarea::placeholder { color: var(--faint); opacity: 1; }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: #8b8dff; flex: 0 0 17px; margin: 3px 0 0; }
input[readonly], textarea[readonly] { color: #d4ddef; }
input:invalid:not(:placeholder-shown) { border-color: var(--danger); }
textarea { resize: vertical; }
button { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(26px, 3vw, 34px); line-height: 1.3; letter-spacing: -.03em; margin-bottom: 10px; }
h2 { font-size: 20px; line-height: 1.4; margin-bottom: 10px; }
h3 { font-size: 16px; margin-bottom: 8px; }
p { margin-bottom: 12px; }
small, .small { font-size: 13px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 750; letter-spacing: .17em; text-transform: uppercase; margin-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 11px; font-size: 20px; font-weight: 730; text-decoration: none; color: var(--ink); white-space: nowrap; }
.brand-mark { width: 36px; height: 36px; border-radius: 11px; display: inline-grid; place-items: center; color: white; background: linear-gradient(135deg, #6366f1, #22d3ee); font-weight: 800; font-size: 20px; }
.brand small { font-size: 12px; font-weight: 450; color: var(--muted); display: block; line-height: 1.2; letter-spacing: .03em; }
.skip-link { position: fixed; top: 8px; left: 8px; padding: 9px 16px; background: var(--surface-raised); z-index: 100; transform: translateY(-180%); }
.skip-link:focus { transform: none; }
.loading-screen { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; color: var(--muted); }

.shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100dvh; }
.sidebar { position: sticky; top: 0; height: 100dvh; border-right: 1px solid var(--line); padding: 30px 20px 24px; display: flex; flex-direction: column; gap: 36px; background: #0e1527; }
.sidebar .brand { margin-left: 8px; }
.nav-label { font-size: 11px; letter-spacing: .14em; color: var(--faint); margin: 0 14px 12px; }
.nav { display: grid; gap: 7px; }
.nav button { border: 1px solid transparent; background: none; padding: 12px 14px; display: flex; gap: 12px; text-align: left; align-items: center; border-radius: 10px; color: var(--muted); font-weight: 550; }
.nav button:hover { background: var(--surface); color: var(--ink); }
.nav button[aria-current="page"] { color: #c5c6ff; background: #222647; border-color: #383c65; }
.nav-icon { font-size: 18px; width: 22px; text-align: center; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 20px 12px 0; font-size: 12px; color: var(--muted); }
.sidebar-foot .btn { margin-top: 12px; width: 100%; }
.session-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--success); margin-right: 7px; vertical-align: 2px; }
.workspace { padding: 40px clamp(20px, 4vw, 64px) 60px; min-width: 0; max-width: 1540px; width: 100%; margin: 0 auto; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-heading p { margin-bottom: 0; color: var(--muted); max-width: 650px; }
.page-heading .actions { margin-top: 6px; }
.section-heading { display: flex; justify-content: space-between; gap: 18px; align-items: center; margin-bottom: 18px; }
.section-heading h2, .section-heading p { margin-bottom: 0; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.btn { border: 1px solid var(--line); background: var(--surface-raised); color: var(--ink); border-radius: 9px; padding: 9px 15px; font-weight: 600; text-decoration: none; display: inline-flex; justify-content: center; align-items: center; gap: 7px; line-height: 1.5; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover:not(:disabled) { background: #25324f; border-color: #536383; }
.btn-primary { background: #777af0; border-color: #8b8dff; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #8a8df7; border-color: #a7a9ff; }
.btn-quiet { background: transparent; }
.btn-small { font-size: 13px; padding: 6px 11px; }
.btn-danger { color: var(--danger); background: #402c38; border-color: #66414d; }
.btn-link { background: none; border: 0; color: var(--brand); padding: 4px 0; font-weight: 600; border-radius: 3px; }
.back { color: var(--muted); margin-bottom: 18px; display: inline-flex; gap: 8px; }
.stack { display: grid; gap: 20px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.card, .panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 24px; min-width: 0; }
.card { display: flex; flex-direction: column; }
.card .actions { margin-top: auto; padding-top: 20px; }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.card-top h2 { margin: 0; word-break: break-word; }
.card-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-size: 20px; background: #24294a; color: #b2b4ff; margin-bottom: 18px; }
.card-description { font-size: 13px; color: var(--muted); word-break: break-word; margin-bottom: 15px; }
.facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 7px 16px; font-size: 13px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.badge { font-size: 11px; font-weight: 600; border: 1px solid #3c4865; background: #1b2740; color: #bdcae5; padding: 3px 8px; border-radius: 6px; display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.badge.success { color: var(--success); background: #153c36; border-color: #28594d; }
.badge.warning { color: var(--warning); background: #413a29; border-color: #615336; }
.badge.danger { color: var(--danger); background: #402c38; border-color: #66414d; }
.notice { padding: 13px 16px; background: #1a2742; border: 1px solid #354967; border-radius: 10px; color: #c6d7f6; font-size: 13px; margin: 0 0 22px; overflow-wrap: anywhere; }
.notice.warning { background: #393323; border-color: #635437; color: var(--warning); }
.notice.danger { background: #382530; border-color: #64404e; color: var(--danger); }
.notice.success { background: #19362f; border-color: #2b584a; color: var(--success); }
.notice p:last-child { margin-bottom: 0; }
.empty { text-align: center; padding: 54px 24px; border: 1px dashed #3d4b68; border-radius: var(--radius); background: #10182a; }
.empty p { color: var(--muted); max-width: 440px; margin-left: auto; margin-right: auto; }
.empty .btn { margin-top: 12px; }
.inline-error { color: var(--danger); font-size: 13px; margin: 10px 0; overflow-wrap: anywhere; }
.notifications { position: fixed; bottom: 24px; right: 24px; z-index: 90; display: grid; gap: 10px; width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; align-items: flex-start; gap: 12px; color: var(--ink); background: #25324a; border: 1px solid #50617c; border-radius: 12px; padding: 12px 12px 12px 17px; box-shadow: 0 12px 35px #0005; font-size: 14px; overflow-wrap: anywhere; }
.toast-message { flex: 1; min-width: 0; max-height: min(220px, 27dvh); overflow-y: auto; padding-top: 3px; }
.toast-close { flex: 0 0 30px; width: 30px; height: 30px; border: 0; border-radius: 6px; background: transparent; color: var(--ink); font-size: 23px; line-height: 1; padding: 0; }
.toast-close:hover { background: #ffffff12; }
.toast.danger { border-color: #885664; background: #452d39; }

.auth-wrap { min-height: 100dvh; display: grid; align-items: center; padding: 40px 24px; background: radial-gradient(ellipse at 50% 0, #292752 0, transparent 57%); }
.auth-card { width: min(460px, 100%); margin: 0 auto; }
.auth-card > .brand { margin-bottom: 52px; }
.auth-card .panel { padding: 32px; box-shadow: 0 20px 80px #0003; }
.auth-symbol { font-size: 28px; color: #a8aaff; margin-bottom: 24px; width: 54px; height: 54px; background: #282c50; border: 1px solid #424773; border-radius: 16px; display: grid; place-items: center; }
.auth-card h1 { font-size: 28px; }
.auth-card .btn-primary { width: 100%; margin-top: 12px; padding: 12px 18px; }
.auth-footer { color: var(--faint); font-size: 12px; text-align: center; margin-top: 24px; }

.field { display: grid; gap: 7px; margin-bottom: 18px; min-width: 0; }
.field > label:first-child { font-size: 13px; font-weight: 600; }
.help { display: block; font-size: 12px; color: var(--muted); font-weight: 400; line-height: 1.7; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.field-row .field { margin-bottom: 0; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 13px; padding: 6px 0; }
.check > span { min-width: 0; word-break: break-word; }
.check-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 5px 20px; }
.check-card { padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--input); }
.check-card strong { display: block; font-size: 14px; }
.check-card .help { margin-top: 3px; }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; padding-top: 22px; margin-top: 5px; border-top: 1px solid var(--line); }
.tabs { display: flex; border-bottom: 1px solid var(--line); margin-bottom: 26px; gap: 23px; overflow-x: auto; scrollbar-width: thin; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 12px 2px; background: transparent; color: var(--muted); white-space: nowrap; font-weight: 600; }
.tabs button[aria-selected="true"] { border-color: var(--brand); color: #c5c6ff; }
.editor-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); margin-bottom: 20px; flex-wrap: wrap; }
.editor-toolbar p { margin: 0; font-size: 13px; }
.dirty-dot { color: var(--warning); }
.rule-editor { min-height: 420px; font-size: 13px; line-height: 1.9; tab-size: 2; white-space: pre; overflow-x: auto; }
.rule-helper { display: grid; grid-template-columns: 170px minmax(160px, 1fr) 180px auto; gap: 12px; align-items: end; }
.rule-helper .field { margin-bottom: 0; }
.rule-helper .btn { min-height: 45px; }
.group-card { padding: 0; }
.group-card > summary { padding: 20px 24px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 10px; list-style: none; }
.group-card > summary::-webkit-details-marker { display: none; }
.group-card > summary::after { content: "+"; font-size: 20px; color: var(--muted); }
.group-card[open] > summary::after { content: "−"; }
.group-content { padding: 0 24px 24px; }
.group-label { font-size: 13px; font-weight: 600; margin-bottom: 9px; display: block; }
.group-section { margin-top: 22px; }
.member-add { display: flex; gap: 8px; margin-bottom: 12px; }
.section-editor { min-height: 180px; line-height: 1.8; white-space: pre; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; text-align: left; }
th { color: var(--muted); background: #162039; font-weight: 500; white-space: nowrap; }
td, th { padding: 14px 17px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td:first-child { overflow-wrap: anywhere; }
.table-actions { display: flex; gap: 9px; justify-content: flex-end; }
.node-list { list-style: none; padding: 0; margin: 0; }
.node-list li { display: flex; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); padding: 11px 0; word-break: break-word; font-size: 13px; }
.node-list li:last-child { border: 0; }
.digest { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }

dialog { color: var(--ink); background: var(--surface); border: 1px solid #44516c; border-radius: 18px; padding: 0; width: min(600px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); box-shadow: 0 24px 100px #0009; }
dialog::backdrop { background: #030716bf; backdrop-filter: blur(4px); }
dialog.wide { width: min(1000px, calc(100vw - 32px)); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 22px 26px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; }
.dialog-body { padding: 24px 26px; overflow-y: auto; max-height: calc(100dvh - 142px); }
.dialog-close { background: transparent; border: 0; font-size: 24px; line-height: 1; width: 30px; height: 30px; padding: 0; border-radius: 6px; color: var(--muted); }
.preview-text { min-height: min(55dvh, 600px); white-space: pre; font-size: 12px; line-height: 1.7; }
.copy-row { display: flex; gap: 9px; align-items: flex-start; }
.copy-row input { min-width: 0; }
.stat-line { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; margin: 8px 0 22px; font-size: 13px; color: var(--muted); }
.no-margin { margin: 0; }
.space-top { margin-top: 18px; }
.space-bottom { margin-bottom: 20px; }
.section-space { margin-top: 34px; }

@media (max-width: 1100px) {
  .shell { grid-template-columns: 190px minmax(0, 1fr); }
  .sidebar { padding-left: 12px; padding-right: 12px; }
  .workspace { padding: 32px 26px 50px; }
  .rule-helper { grid-template-columns: 140px minmax(140px, 1fr); }
}
@media (max-width: 760px) {
  .shell { display: block; }
  .sidebar { position: static; height: auto; padding: 16px 20px 0; display: grid; grid-template-columns: 1fr auto; gap: 17px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar .brand { margin-left: 0; font-size: 18px; }
  .sidebar .brand-mark { width: 32px; height: 32px; }
  .sidebar > div:has(.nav) { grid-column: 1 / -1; grid-row: 2; }
  .nav-label { display: none; }
  .nav { display: flex; gap: 7px; }
  .nav button { flex: 1; justify-content: center; border-radius: 8px 8px 0 0; font-size: 13px; padding: 10px 7px; gap: 6px; }
  .nav-icon { font-size: 15px; width: auto; }
  .sidebar-foot { margin: 0; padding: 0; border: 0; align-self: center; }
  .sidebar-foot p { display: none; }
  .sidebar-foot .btn { margin: 0; padding: 6px 10px; font-size: 12px; }
  .workspace { padding: 28px 20px 45px; }
  .page-heading { gap: 16px; flex-direction: column; margin-bottom: 24px; }
  .page-heading .actions { margin: 0; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .card, .panel { padding: 20px; }
  .tabs { gap: 20px; margin-bottom: 20px; }
  .editor-toolbar { padding: 14px; }
  .editor-toolbar .actions { width: 100%; }
  .editor-toolbar .actions .btn { flex: 1; }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  .rule-helper { grid-template-columns: minmax(0, 1fr); }
  .rule-helper .btn { width: 100%; }
  .group-card > summary { padding: 17px 20px; }
  .group-content { padding: 0 20px 20px; }
  .section-heading { align-items: flex-start; }
  .dialog-head { padding: 20px; }
  .dialog-body { padding: 20px; }
  .copy-row { flex-direction: column; }
  .copy-row .btn { width: 100%; }
  .notifications { right: 16px; bottom: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
