:root {
  color-scheme: light dark;
  --bg: #eef1f6;
  --panel: #ffffff;
  --ink: #1b2430;
  --muted: #5e6b7b;
  --line: #d9dfe8;
  --field: #f5f7fa;
  --brand: #0b4a8f;
  --brand-2: #1266c4;
  --brand-ink: #ffffff;
  --accent: #0b64c8;
  --ok: #1a7f37;
  --warn: #9a6700;
  --error: #c0362c;
  --shadow: 0 10px 30px rgba(20, 40, 70, .10);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e141c;
    --panel: #161e29;
    --ink: #e7ecf2;
    --muted: #9aa7b6;
    --line: #273040;
    --field: #0f1620;
    --brand: #0b3f78;
    --brand-2: #10528f;
    --brand-ink: #eaf2ff;
    --accent: #4aa0f5;
    --ok: #3fb950;
    --warn: #d29922;
    --error: #f0837a;
    --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

.logo { width: 1.6em; height: 1.6em; flex: none; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: .2px;
}
.brand.small { font-size: 16px; }

/* ---------- Login ---------- */
.login-layout {
  min-height: 100%;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}

.brand-panel {
  background: linear-gradient(150deg, var(--brand) 0%, var(--brand-2) 100%);
  color: var(--brand-ink);
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.brand-panel .brand { font-size: 20px; }
.brand-copy h2 { font-size: 30px; line-height: 1.2; margin: 0 0 10px; }
.brand-copy p { margin: 0; opacity: .9; max-width: 44ch; }
.brand-points { margin: auto 0 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.brand-points li { position: relative; padding-left: 26px; opacity: .95; }
.brand-points li::before {
  content: "✓"; position: absolute; left: 0; top: -1px;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(255, 255, 255, .18); font-size: 12px; text-align: center; line-height: 18px;
}

.login-main { display: flex; align-items: center; justify-content: center; padding: 24px; }

.login-card { width: 100%; max-width: 380px; }
.login-card h1 { font-size: 24px; margin: 0 0 4px; }
.subtitle { color: var(--muted); margin: 0 0 24px; }

label { display: block; font-weight: 600; font-size: 13px; margin: 14px 0 6px; }

input[type="text"], input[type="password"] {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  font-size: 15px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

button {
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}
button:hover { filter: brightness(1.05); }
button:disabled { opacity: .55; cursor: progress; }
button.secondary { background: var(--panel); color: var(--ink); border-color: var(--line); }
button.ghost { background: transparent; color: var(--muted); border-color: transparent; padding: 7px 12px; }
button.ghost:hover { color: var(--ink); }

#login-button { width: 100%; margin-top: 22px; }

.foot { color: var(--muted); font-size: 12px; margin-top: 20px; text-align: center; }

/* ---------- App / editor ---------- */
.app-shell { min-height: 100%; display: flex; flex-direction: column; }

.app-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 20px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.header-actions { display: flex; align-items: center; gap: 14px; }
.meta { color: var(--muted); font-size: 12px; }

.app-main { flex: 1; display: flex; justify-content: center; padding: 20px; }

.panel {
  width: 100%; max-width: 920px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 20px; display: flex; flex-direction: column; gap: 14px;
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 18px; }
.hint { color: var(--muted); font-size: 13px; }

textarea {
  width: 100%; min-height: 48vh; resize: vertical;
  padding: 14px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--field); color: var(--ink);
  font: 14px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  tab-size: 4;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }

.message { min-height: 1.4em; margin: 2px 0 0; white-space: pre-line; font-size: 14px; }
.message.ok { color: var(--ok); }
.message.warn { color: var(--warn); }
.message.error { color: var(--error); }

@media (max-width: 820px) {
  .login-layout { grid-template-columns: 1fr; }
  .brand-panel { padding: 28px 24px; gap: 18px; }
  .brand-copy h2 { font-size: 24px; }
  .brand-points { margin: 4px 0 0; }
}
