:root {
  color-scheme: light dark;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #172033;
  --muted: #697386;
  --border: #dce2eb;
  --primary: #245fe5;
  --primary-hover: #174dc7;
  --danger: #c43b43;
  --success: #14804a;
  --warning-bg: #fff8e7;
  --warning-border: #e8c76b;
  --shadow: 0 12px 30px rgba(26, 39, 64, .07);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10141c;
    --panel: #171d28;
    --panel-soft: #1d2532;
    --text: #e8edf6;
    --muted: #a0aabd;
    --border: #30394a;
    --primary: #6e96ff;
    --primary-hover: #8aaaff;
    --danger: #ff777f;
    --success: #5ed59a;
    --warning-bg: #332d1d;
    --warning-border: #75602d;
    --shadow: 0 12px 30px rgba(0, 0, 0, .2);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input, textarea { font: inherit; }
button { cursor: pointer; border: 1px solid transparent; border-radius: 9px; padding: 9px 13px; font-weight: 600; transition: background .15s ease, border-color .15s ease, transform .15s ease; }
button:disabled { opacity: .55; cursor: not-allowed; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.primary { color: #fff; background: var(--primary); }
.primary:hover:not(:disabled) { background: var(--primary-hover); }
.secondary { color: var(--text); background: var(--panel); border-color: var(--border); }
.secondary:hover:not(:disabled) { background: var(--panel-soft); }
.danger-ghost { color: var(--danger); background: transparent; border-color: var(--border); }
.danger-ghost:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 9%, transparent); }
.full { width: 100%; }
.muted { color: var(--muted); }
.tiny { font-size: 11px; }
.small-text { font-size: 12px; }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 13px; color: white; background: #245fe5; font-size: 22px; font-weight: 800; }
.brand-mark.small { width: 35px; height: 35px; border-radius: 10px; font-size: 18px; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(100%, 380px); padding: 30px; border: 1px solid var(--border); border-radius: 18px; background: var(--panel); box-shadow: var(--shadow); }
.login-card .brand-mark { margin-bottom: 20px; }
h1, h2, p { margin-top: 0; }
.login-card h1 { margin-bottom: 8px; font-size: 25px; }
.login-card p { line-height: 1.55; }
.login-card label { display: block; margin: 18px 0 7px; font-size: 13px; font-weight: 700; }
.login-card input, .name-field input { width: 100%; min-width: 0; border: 1px solid var(--border); border-radius: 9px; padding: 11px 12px; color: var(--text); background: var(--panel-soft); }
.login-card .primary { margin-top: 22px; padding: 12px; }
.error-text { min-height: 20px; margin: 12px 0 0; color: var(--danger); font-size: 13px; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 255px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; display: flex; flex-direction: column; height: 100vh; padding: 20px 14px 14px; border-right: 1px solid var(--border); background: var(--panel); }
.brand-row { display: flex; align-items: center; gap: 10px; padding: 0 7px 22px; }
.brand-row strong { font-size: 14px; }
.sidebar > .primary { padding: 11px; }
.section-label { margin: 24px 8px 9px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .07em; }
.profile-list { display: flex; flex-direction: column; gap: 5px; overflow-y: auto; min-height: 0; }
.profile-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; text-align: left; color: var(--text); background: transparent; border-color: transparent; }
.profile-item:hover { background: var(--panel-soft); }
.profile-item.active { background: color-mix(in srgb, var(--primary) 12%, var(--panel)); border-color: color-mix(in srgb, var(--primary) 25%, var(--border)); }
.file-icon { display: grid; place-items: center; flex: 0 0 31px; height: 31px; border: 1px solid var(--border); border-radius: 8px; color: var(--primary); font-size: 13px; }
.profile-item-text { min-width: 0; flex: 1; }
.profile-item-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 700; }
.profile-item-meta { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.sidebar-bottom { display: grid; gap: 6px; margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }
.nav-button { text-align: left; color: var(--muted); background: transparent; border-color: transparent; }
.nav-button:hover { color: var(--text); background: var(--panel-soft); }
.main-panel { min-width: 0; padding: 28px clamp(16px, 3vw, 42px) 48px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 25px; }
.topbar h1 { margin: 5px 0 0; font-size: clamp(22px, 2vw, 29px); letter-spacing: -.025em; }
.eyebrow { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .13em; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.status-pill, .count-pill { display: inline-flex; align-items: center; padding: 6px 9px; border-radius: 999px; color: var(--muted); background: var(--panel-soft); border: 1px solid var(--border); font-size: 11px; white-space: nowrap; }
.content-view { display: grid; gap: 18px; }
.editor-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.editor-toolbar h2 { margin: 0 0 5px; font-size: 18px; }
.editor-toolbar p { margin: 0; max-width: 620px; font-size: 12px; line-height: 1.5; }
.toolbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; flex-wrap: wrap; }
.toolbar-actions button { font-size: 12px; padding: 9px 11px; }
.name-field { display: flex; flex-direction: column; gap: 7px; width: min(100%, 310px); }
.name-field label { color: var(--muted); font-size: 11px; font-weight: 800; }
.name-field input { padding: 9px 11px; font-size: 15px; font-weight: 700; }
.panel-card { border: 1px solid var(--border); border-radius: 15px; background: var(--panel); box-shadow: var(--shadow); overflow: hidden; }
.editor-card { padding: 18px; }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.card-heading h2 { margin: 0 0 5px; font-size: 15px; }
.card-heading p { margin: 0; font-size: 12px; line-height: 1.5; }
.editor-frame { display: grid; grid-template-columns: 46px minmax(0, 1fr); height: min(48vh, 490px); min-height: 220px; overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-soft); }
.template-frame { height: min(64vh, 650px); }
.line-gutter { margin: 0; padding: 12px 10px 12px 0; overflow: hidden; text-align: right; color: var(--muted); background: color-mix(in srgb, var(--panel-soft) 65%, var(--border)); border-right: 1px solid var(--border); font: 12px/1.6rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; user-select: none; }
.code-editor { display: block; width: 100%; height: 100%; resize: vertical; min-width: 0; border: 0; outline: 0; padding: 12px 14px; color: var(--text); background: transparent; font: 12px/1.6rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre; overflow: auto; tab-size: 2; }
.code-editor:focus-visible { outline: 0; box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--primary) 60%, transparent); }
.editor-footnote { margin-top: 12px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.warning-box { margin-top: 12px; padding: 11px 12px; border: 1px solid var(--warning-border); border-radius: 9px; color: var(--text); background: var(--warning-bg); font-size: 12px; line-height: 1.55; }
.warning-box ul { margin: 7px 0 0; padding-left: 19px; }
.links-card { padding: 18px; }
.subscription-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.link-card { min-width: 0; padding: 13px; border: 1px solid var(--border); border-radius: 11px; background: var(--panel-soft); }
.link-card h3 { margin: 0 0 6px; font-size: 12px; }
.link-card code { display: block; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.link-card-actions { display: flex; gap: 6px; margin-top: 12px; }
.link-card-actions button, .link-card-actions a { display: inline-flex; align-items: center; justify-content: center; flex: 1; padding: 7px 8px; border: 1px solid var(--border); border-radius: 7px; color: var(--text); background: var(--panel); text-decoration: none; font-size: 11px; }
.link-card-actions .copy-link { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.empty-view { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 55vh; padding: 30px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 66px; height: 66px; margin-bottom: 18px; border: 1px solid var(--border); border-radius: 20px; color: var(--primary); background: var(--panel); font-size: 24px; font-weight: 800; }
.empty-view h2 { margin-bottom: 8px; font-size: 20px; }
.empty-view p { max-width: 440px; line-height: 1.7; font-size: 13px; }
.empty-view button { margin-top: 10px; }
.history-dialog { width: min(560px, calc(100vw - 28px)); max-height: min(80vh, 700px); padding: 0; border: 1px solid var(--border); border-radius: 16px; color: var(--text); background: var(--panel); box-shadow: var(--shadow); }
.history-dialog::backdrop { background: rgba(7, 12, 22, .55); backdrop-filter: blur(3px); }
.dialog-header { display: flex; justify-content: space-between; gap: 15px; padding: 20px; border-bottom: 1px solid var(--border); }
.dialog-header h2 { margin: 0 0 5px; font-size: 17px; }
.dialog-header p { margin: 0; font-size: 12px; }
.icon-button { align-self: flex-start; padding: 5px 8px; color: var(--muted); background: transparent; border-color: var(--border); }
.history-list { display: grid; gap: 8px; max-height: 55vh; overflow: auto; padding: 15px 20px 20px; }
.history-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-soft); }
.history-item strong { display: block; font-size: 12px; }
.history-item small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.history-item button { flex: 0 0 auto; padding: 7px 10px; font-size: 11px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 20; max-width: min(440px, calc(100vw - 44px)); padding: 12px 16px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); background: var(--panel); box-shadow: var(--shadow); font-size: 13px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .18s ease, transform .18s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { border-color: color-mix(in srgb, var(--danger) 55%, var(--border)); }
@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 220px minmax(0, 1fr); }
  .subscription-links { grid-template-columns: 1fr; }
  .toolbar-actions { justify-content: flex-start; }
}
@media (max-width: 720px) {
  .app-shell { display: block; }
  .sidebar { position: relative; height: auto; padding: 12px; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand-row { padding-bottom: 12px; }
  .sidebar > .primary { width: auto; align-self: flex-start; }
  .section-label { margin-top: 14px; }
  .profile-list { display: flex; flex-direction: row; overflow-x: auto; padding-bottom: 5px; }
  .profile-item { min-width: 165px; width: auto; }
  .sidebar-bottom { display: flex; justify-content: space-between; padding-top: 7px; }
  .main-panel { padding: 18px 12px 34px; }
  .topbar { align-items: flex-start; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .editor-card, .links-card { padding: 12px; }
  .editor-toolbar { align-items: flex-start; }
  .name-field { width: 100%; }
  .toolbar-actions { width: 100%; }
  .toolbar-actions button { flex: 1 1 auto; }
  .editor-frame { grid-template-columns: 35px minmax(0, 1fr); height: 42vh; min-height: 200px; }
  .line-gutter { padding-right: 7px; font-size: 10px; }
  .code-editor { padding: 10px; font-size: 11px; }
}

.status-pill.status-error { color: var(--danger); }
