:root {
  color-scheme: light dark;
  --canvas: #f7fafe; --surface: #fdfeff; --subtle: #eef4fc;
  --ink: #0d1321; --muted: #404858; --faint: #515866;
  --line: #d4dbe5; --line-strong: #a7b2c1;
  --accent: #3f56e8; --accent-hover: #3242d3; --on-accent: #fcfcfc;
  --success: #00641a; --success-soft: #d7f4dc; --danger: #bb061e;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ink); background: var(--canvas); font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; }
button, input, textarea { font: inherit; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:where(button, a, input, textarea):focus-visible, label:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }
.skip-link { position: fixed; z-index: 20; top: 8px; left: 8px; padding: 10px 14px; border-radius: 8px; color: var(--ink); background: var(--surface); transform: translateY(-160%); }
.skip-link:focus { transform: none; }
.topbar { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 max(24px, calc((100% - 1200px) / 2)); background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--ink); text-decoration: none; font-size: 16px; font-weight: 650; }
.brandmark, .login-brandmark { display: flex; flex-shrink: 0; align-items: center; }
.brandmark img { width: 28px; height: auto; }
.logo-dark { display: none; }
.top-right { display: flex; align-items: center; gap: 18px; min-width: 0; }
#account { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13px; }
main { width: min(100% - 48px, 1200px); margin: 0 auto; }
#workspace { padding: 40px 0 72px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(28px, 3vw, 36px); line-height: 1.1; letter-spacing: -.025em; font-weight: 650; overflow-wrap: anywhere; }
h2 { font-size: 16px; line-height: 1.35; font-weight: 650; }
.page-heading, .editor-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.page-heading p, .editor-heading p { margin-top: 8px; color: var(--muted); line-height: 1.5; font-size: 15px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 9px 14px; border: 1px solid transparent; border-radius: 10px; font-size: 14px; font-weight: 600; line-height: 1.4; text-decoration: none; white-space: nowrap; }
.primary { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.secondary { border-color: var(--line); background: var(--surface); color: var(--ink); }
.secondary:hover { background: var(--subtle); border-color: var(--line-strong); }
.text-button, .back { min-height: 44px; padding: 8px 0; border: 0; background: transparent; color: var(--muted); font-size: 14px; font-weight: 550; }
.text-button:hover, .back:hover { color: var(--ink); }
.danger { color: var(--danger); }
.page-list-shell { margin-top: 28px; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.list-header, .page-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px 140px; gap: 24px; align-items: center; }
.list-header { min-height: 46px; padding: 0 20px; background: var(--subtle); color: var(--muted); font-size: 12px; font-weight: 650; }
.page-row { min-height: 76px; padding: 14px 20px; border-top: 1px solid var(--line); cursor: pointer; }
.page-row:hover { background: var(--subtle); }
.page-row:focus-visible { outline-offset: -3px; }
.page-name { display: flex; min-width: 0; align-items: center; gap: 12px; }
.page-icon { width: 40px; height: 40px; flex: 0 0 40px; display: grid; place-items: center; border-radius: 10px; background: var(--subtle); color: var(--accent); font-size: 20px; }
.page-name strong, .page-name small { display: block; overflow-wrap: anywhere; }
.page-name strong { font-size: 14px; line-height: 1.4; }
.page-name small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.pill { display: inline-flex; width: fit-content; align-items: center; gap: 6px; border-radius: 99px; padding: 5px 9px; background: var(--subtle); color: var(--muted); font-size: 12px; font-weight: 600; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.live { background: var(--success-soft); color: var(--success); }
.date { color: var(--muted); font-size: 13px; }
.empty { padding: 28px 20px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.back { display: inline-flex; gap: 8px; align-items: center; margin: -8px 0 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.editor-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 20px; margin-top: 24px; align-items: start; }
.main-column, aside { display: grid; min-width: 0; gap: 20px; }
.panel { min-width: 0; padding: 24px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.panel-title { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 20px; }
.panel-title p { margin-top: 5px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
label { display: block; min-width: 0; color: var(--muted); font-size: 13px; font-weight: 600; }
.label-hint { display: block; margin-top: 3px; color: var(--faint); font-size: 12px; font-weight: 400; }
input:not([type=file]), textarea { width: 100%; min-width: 0; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink); }
input:not([type=file]) { min-height: 44px; margin-top: 8px; padding: 8px 12px; }
input:disabled { color: var(--muted); background: var(--subtle); }
.url-input { display: flex; align-items: center; margin-top: 8px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--muted); font-size: 14px; }
.url-input:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }
.url-input input { margin: 0; padding: 8px 5px; border: 0; outline: 0; }
.url-input input:focus-visible { outline: 0; }
textarea { display: block; min-height: 390px; padding: 16px; resize: vertical; font: 13px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; tab-size: 2; }
.upload-label { cursor: pointer; }
.asset-drop { display: flex; min-height: 104px; align-items: center; justify-content: center; flex-direction: column; gap: 6px; border: 1px dashed var(--line-strong); border-radius: 10px; background: var(--subtle); cursor: pointer; text-align: center; }
.asset-drop strong { color: var(--ink); font-size: 13px; }
.asset-drop span { color: var(--muted); font-size: 12px; font-weight: 400; }
.aside-note { margin-top: 16px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.aside-note code { overflow-wrap: anywhere; }
.linkbox { display: flex; align-items: center; gap: 4px; margin-top: 8px; padding: 4px 8px 4px 12px; border-radius: 10px; background: var(--subtle); }
.linkbox a { flex: 1; overflow: hidden; color: var(--accent); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.linkbox button { width: 40px; height: 40px; border: 0; background: none; color: var(--muted); font-size: 20px; }
.asset-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 13px; overflow-wrap: anywhere; }
.asset-row:first-child { margin-top: 16px; }
.asset-row button { min-height: 44px; border: 0; background: none; color: var(--danger); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
#toast { position: fixed; z-index: 10; right: 24px; bottom: 24px; max-width: min(400px, calc(100% - 48px)); padding: 14px 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--ink); color: var(--surface); font-size: 14px; opacity: 0; pointer-events: none; }
#toast.visible { opacity: 1; }
.login { display: grid; min-height: 100dvh; place-items: center; padding: 32px 0; }
.login-stack { width: min(100%, 448px); display: grid; justify-items: center; gap: 24px; }
.login-card { width: 100%; display: grid; gap: 24px; padding: 40px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.login-heading { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 8px; }
.login-brandmark img { width: auto; height: 40px; }
.login-heading h1 { min-width: 0; font-size: 30px; line-height: 1.1; }
.login-action { width: 100%; min-height: 48px; justify-content: space-between; font-size: 16px; }
.login-action svg { flex-shrink: 0; }
.login .hint { color: var(--muted); font-size: 13px; line-height: 1.5; }
.login .hint:empty { display: none; }
.login-wordmark img { display: block; max-width: 100%; width: 207px; height: auto; }
@media (max-width: 760px) {
  main { width: min(100% - 32px, 1200px); }
  .topbar { padding: 0 16px; }
  #workspace { padding-top: 28px; }
  .page-heading, .editor-heading { align-items: flex-start; flex-direction: column; }
  .editor-grid, .fields { grid-template-columns: 1fr; }
  .list-header, .page-row { grid-template-columns: minmax(0, 1fr) auto; gap: 12px; }
  .list-header span:last-child, .date { display: none; }
  .panel { padding: 20px; }
  .panel-title { flex-wrap: wrap; }
  textarea { min-height: 300px; }
}
@media (max-width: 480px) {
  .login-card { padding: 24px; }
  .login-heading h1 { font-size: 26px; }
  #account { max-width: 120px; }
  .top-right { gap: 10px; }
}
@media (prefers-color-scheme: dark) {
  :root { --canvas: #050a16; --surface: #0c111e; --subtle: #151b2a; --ink: #ebf1f8; --muted: #a6afbb; --faint: #a6afbb; --line: #262e3d; --line-strong: #636e82; --accent: #7c9cff; --accent-hover: #90b0ff; --on-accent: #060b18; --success: #65c67d; --success-soft: #0a2913; --danger: #ff847c; }
  .logo-light { display: none; }
  .logo-dark { display: block; }
}
.login-wordmark .logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
  .login-wordmark .logo-light { display: none; }
  .login-wordmark .logo-dark { display: block; }
}
@media (max-width: 360px) {
  #account { display: none; }
  .brand, .top-right .text-button { white-space: nowrap; }
}
.login-stack, .login-card { min-width: 0; }
.login-action { min-width: 0; white-space: normal; text-align: left; }
.icon-button { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 24px; cursor: pointer; }
.icon-button:hover { background: var(--subtle); color: var(--ink); }
#mcp-dialog { width: min(560px, calc(100% - 32px)); max-height: min(85dvh, 720px); overflow-y: auto; padding: 24px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); }
#mcp-dialog::backdrop { background: rgb(5 10 22 / .55); }
.dialog-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.dialog-heading p, .connection-note, .secret-box p { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
#mcp-form { margin-top: 20px; }
.connection-form { display: flex; align-items: end; gap: 8px; }
.connection-form input { flex: 1; min-width: 0; }
.secret-box { margin-top: 20px; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--subtle); font-size: 14px; }
#mcp-dialog h3 { margin: 24px 0 12px; font-size: 14px; }
.connection-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.connection-row strong, .connection-row small { display: block; overflow-wrap: anywhere; }
.connection-row small { margin-top: 4px; color: var(--muted); }
@media (max-width: 480px) { .connection-form { align-items: stretch; flex-direction: column; } .top-right { gap: 8px; } #mcp-open { white-space: nowrap; } }
.mcp-address { display: grid; gap: 6px; margin-top: 16px; font-size: 13px; }
.mcp-address code { overflow-wrap: anywhere; color: var(--muted); }
@media (max-width: 400px) { .topbar { flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; } .top-right { margin-left: auto; } }
