@font-face { font-family: "Instrument Sans"; src: url(/fonts/instrument-sans-var.woff2) format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url(/fonts/instrument-serif-400.woff2) format("woff2"); font-display: swap; }

:root {
  --navy: #0f1b33; --navy-2: #172744; --navy-line: #24375c; --on-navy: #e8edf7; --on-navy-muted: #9fb0cf;
  --blue: #3b6fe0; --blue-deep: #2f5fcc; --blue-soft: #7fa6ff;
  --bg: #f3f5f9; --card: #ffffff; --text: #111114; --muted: #4a4a52; --line: #dfe3ea; --field: #ffffff;
  --ok: #15803d; --bad: #b42318; --warn: #a15c07; --shadow: 0 1px 2px rgba(15,27,51,.06), 0 4px 14px rgba(15,27,51,.06);
  --serif: "Instrument Serif", Georgia, serif; --sans: "Instrument Sans", system-ui, sans-serif;
  --side: 260px;
}
[data-theme="dark"] {
  --bg: #0b1324; --card: #121d33; --text: #eef1f7; --muted: #a9b3c7; --line: #22314f; --field: #0f1a2e;
  --ok: #4ade80; --bad: #ffb4a8; --warn: #f5b454; --shadow: 0 1px 2px rgba(0,0,0,.3);
  --navy: #070e1c; --navy-2: #0f1a2e; --navy-line: #1c2a47;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--sans); background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--blue-soft); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Wordmark */
.mark { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-size: 26px; letter-spacing: .2px; color: inherit; }
.mark svg { width: 26px; height: 26px; flex: none; }

/* Login: always dark */
.login { min-height: 100%; display: grid; place-items: center; background: #0b1324; color: #eef1f7; padding: 24px; }
.login .box { width: 100%; max-width: 400px; background: #121d33; border: 1px solid #22314f; border-radius: 16px; padding: 32px 28px; }
.login .mark { justify-content: center; font-size: 34px; margin-bottom: 6px; }
.login .mark svg { width: 34px; height: 34px; }
.login .sub { text-align: center; color: #a9b3c7; margin: 0 0 22px; }
.login label { display: block; font-size: 14px; color: #c9d2e3; margin: 14px 0 6px; }
.login input { width: 100%; height: 46px; border-radius: 10px; border: 1px solid #2c3d61; background: #0f1a2e; color: #eef1f7; padding: 0 14px; }
.login .btn { width: 100%; margin-top: 20px; }
.login .links { display: flex; justify-content: space-between; margin-top: 14px; flex-wrap: wrap; gap: 8px; }
.login .link { color: #7fa6ff; background: none; border: 0; padding: 4px 0; cursor: pointer; text-decoration: underline; }
.code { font-family: ui-monospace, monospace; font-size: 22px; letter-spacing: 2px; background: #0f1a2e; border: 1px dashed #7fa6ff; padding: 14px; border-radius: 10px; text-align: center; margin: 12px 0; user-select: all; }

/* Buttons and fields */
.btn { min-height: 44px; padding: 0 18px; border-radius: 10px; border: 0; background: var(--blue); color: #fff; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--blue-deep); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid currentColor; }
.btn[disabled] { opacity: .5; cursor: default; }
.field { display: block; margin: 10px 0; }
.field > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea, .search { width: 100%; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--field); padding: 8px 12px; }
.field textarea { min-height: 90px; resize: vertical; }
.err { color: var(--bad); min-height: 1.4em; margin: 8px 0 0; font-size: 15px; }
.login .err { color: #ffb4a8; }
.ok { color: var(--ok); }
.muted { color: var(--muted); }

/* Shell */
.shell { display: flex; min-height: 100%; }
.side { width: var(--side); flex: none; background: var(--navy); color: var(--on-navy); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; transition: margin-left .25s ease, transform .25s ease; z-index: 20; }
.shell.collapsed .side { margin-left: calc(-1 * var(--side)); }
.side .top { padding: 20px 18px 14px; border-bottom: 1px solid var(--navy-line); }
.side .mark { font-size: 24px; color: #fff; }
.profile { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 22px 16px; border-bottom: 1px solid var(--navy-line); text-align: center; }
.profile .who { font-weight: 600; font-size: 17px; }
.profile .roles { color: var(--on-navy-muted); font-size: 13px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; font-weight: 700; overflow: hidden; flex: none; position: relative; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.big { width: 76px; height: 76px; font-size: 26px; border: 3px solid var(--navy-line); }
.avatar .dot { position: absolute; right: 0; bottom: 0; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--card); background: #9ca3af; }
.avatar .dot.on { background: #22c55e; }
.side nav { padding: 10px 10px 20px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side nav button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 12px; border: 0; background: none; color: var(--on-navy); border-radius: 10px; cursor: pointer; text-align: left; font-size: 15px; }
.side nav button:hover { background: var(--navy-2); }
.side nav button[aria-current="page"] { background: var(--blue); color: #fff; }
.side nav .sep { height: 1px; background: var(--navy-line); margin: 8px 6px; }
.ico { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bar { height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 20px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.bar h1 { font-size: 20px; margin: 0; font-weight: 600; flex: 1; }
.iconbtn { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--text); }
.content { padding: 24px; max-width: 1200px; width: 100%; }
.scrim { display: none; }
@media (max-width: 860px) {
  .side { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); margin-left: 0 !important; }
  .shell.open .side { transform: none; }
  .shell.open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 15; }
  .content { padding: 16px; }
}

/* Home cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.wcard { min-height: 140px; padding: 18px; display: flex; flex-direction: column; justify-content: space-between; cursor: pointer; text-align: left; border: 1px solid var(--line); position: relative; color: var(--text); }
.wcard:hover { border-color: var(--blue); }
.wcard .big { width: 44px; height: 44px; border-radius: 12px; background: color-mix(in srgb, var(--blue) 12%, transparent); color: var(--blue); display: grid; place-items: center; }
[data-theme="dark"] .wcard .big { color: var(--blue-soft); }
.wcard .big .ico { width: 24px; height: 24px; }
.wcard .name { font-weight: 600; font-size: 17px; }
.wcard .live { font-size: 15px; font-weight: 600; color: var(--blue); line-height: 1.3; }
[data-theme="dark"] .wcard .live { color: var(--blue-soft); }
.wcard.hidden-card { opacity: .45; border-style: dashed; }
.wcard .hidebtn { position: absolute; top: 10px; right: 10px; }
.editing .wcard { cursor: grab; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* Lists */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .search { flex: 1; min-width: 200px; }
.rows { display: flex; flex-direction: column; gap: 10px; }
.row { padding: 14px 16px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.row .grow { flex: 1; min-width: 180px; }
.row .t { font-weight: 600; }
.pill { display: inline-block; font-size: 12.5px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.pill.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.pill.good { color: var(--ok); border-color: currentColor; }
.pill.bad { color: var(--bad); border-color: currentColor; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tags button { cursor: pointer; background: none; }
.section { padding: 18px; margin-bottom: 16px; }
.section h2 { font-size: 18px; margin: 0 0 10px; }
.section h3 { font-size: 15px; margin: 16px 0 8px; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
pre.box { white-space: pre-wrap; background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 14px; }
.cols { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; }
.cols > * { min-width: 0; }
@media (max-width: 860px) { .cols { grid-template-columns: minmax(0, 1fr); } .kv { grid-template-columns: 1fr; } }
.chat { display: flex; flex-direction: column; height: 60vh; }
.msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 75%; padding: 8px 12px; border-radius: 12px; background: var(--field); border: 1px solid var(--line); align-self: flex-start; }
.msg.mine { align-self: flex-end; background: var(--blue); color: #fff; border-color: var(--blue); }
.msg img { max-width: 240px; border-radius: 8px; display: block; margin-top: 6px; }
.msg .meta { font-size: 12px; opacity: .75; }
.compose { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px; border-top: 1px solid var(--line); align-items: center; }
.compose input[type=text] { min-width: 0; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--field); padding: 0 12px; }
.compose input[type=file] { max-width: 210px; font-size: 14px; }
.compose input[type=text] { flex: 1 1 100%; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; max-height: 220px; overflow-y: auto; padding: 6px 0; }
.checks label { display: flex; align-items: center; gap: 6px; font-size: 15px; min-height: 32px; }
.checks input { width: 18px; height: 18px; }
dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--text); max-width: 640px; width: calc(100% - 24px); padding: 22px; }
dialog::backdrop { background: rgba(0,0,0,.5); }
.note { font-size: 14px; color: var(--muted); background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 10px; z-index: 50; max-width: 90vw; }
