:root {
  --ink: #18181b;
  --muted: #63636e;
  --line: #ececef;
  --field: #d4d4d9;
  --side: #fafafa;
  --active: #efeff1;
  --accent: #2f4bd8;
  --danger: #b4231f;
}

* { box-sizing: border-box; }
body { margin: 0; background: #fff; color: var(--ink); font: 14px/1.45 Inter, system-ui, "Segoe UI", sans-serif; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
h1 { margin: 0; font-size: 26px; font-weight: 600; }
h2 { margin: 0; font-size: 15px; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 8px; }

.shell { min-height: 100vh; display: flex; flex-wrap: wrap; align-items: stretch; }
.side { flex: 1 1 220px; padding: 24px 16px; background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 24px; }
.content { flex: 999 1 560px; min-width: 0; padding: 40px clamp(20px, 5vw, 64px) 64px; }
#view { max-width: 760px; }
#view.wide { max-width: 960px; }

.brand { display: flex; align-items: center; gap: 10px; padding: 0 12px; font-size: 17px; font-weight: 600; }
.mark { width: 20px; height: 20px; border-radius: 5px; background: var(--ink); }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { display: flex; align-items: center; height: 44px; padding: 0 12px; border-radius: 8px; color: #3f3f46; text-decoration: none; }
nav a:hover { color: var(--ink); }
nav a[aria-current="page"] { background: var(--active); color: var(--ink); font-weight: 600; }
.status { margin-top: auto; padding: 0 12px; }
.status-line { display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #8a8a94; }
.dot.on { background: var(--accent); }

header.page { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px; }
header.page p { margin-top: 6px; color: var(--muted); }
section { margin-top: 40px; }
section > h2 + p { margin: 4px 0 14px; color: var(--muted); font-size: 13px; }
section > h2 + .row { margin-top: 14px; }

.row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 32px; padding: 12px 0; border-top: 1px solid var(--line); }
.row .label { flex: 1 1 240px; min-width: 0; }
.row .label label, .row .label .title { display: block; font-weight: 500; }
.row .label .muted { margin-top: 2px; }
.row .control { flex: 0 1 300px; min-width: 0; }
.stack { padding: 12px 0; border-top: 1px solid var(--line); }
.stack label, .field-title { display: block; margin-bottom: 8px; font-weight: 500; }

input, select, textarea { width: 100%; border: 1px solid var(--field); border-radius: 8px; background: #fff; color: var(--ink); font: inherit; }
input, select { height: 44px; padding: 0 10px; }
textarea { padding: 10px 12px; resize: vertical; min-height: 84px; }
select:disabled { color: var(--muted); background: var(--side); }

button { font: inherit; cursor: pointer; }
.primary, .secondary { height: 44px; padding: 0 18px; border-radius: 8px; font-weight: 600; }
.primary { border: 0; background: var(--accent); color: #fff; }
.secondary { border: 1px solid var(--field); background: #fff; color: var(--ink); font-weight: 500; }
.danger-text { color: var(--danger); }
.primary:disabled, .secondary:disabled { opacity: .6; cursor: default; }
.wide { width: 100%; margin-top: 12px; }
.link { height: 44px; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 13px; text-decoration: underline; }
.link.accent { color: var(--accent); font-size: 14px; font-weight: 500; text-decoration: none; }
.buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }

.notice { margin-top: 20px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 44px; height: 44px; border: 1px solid var(--field); border-radius: 8px; background: #fff; font-size: 18px; }
.stepper output { width: 48px; text-align: center; font-size: 15px; font-weight: 600; }
.switch { width: 52px; height: 44px; padding: 0; border: 0; background: transparent; display: flex; align-items: center; }
.switch span { display: block; width: 44px; height: 24px; border-radius: 12px; background: #8a8a94; position: relative; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; }
.switch[aria-checked="true"] span { background: var(--accent); }
.switch[aria-checked="true"] span::after { left: 22px; }

.split { display: flex; flex-wrap: wrap; gap: 24px 40px; margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line); }
.split .list { flex: 1 1 180px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.split .list h2 { margin-bottom: 10px; }
.split .list button { height: 44px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.split .list button[aria-pressed="true"] { background: var(--active); font-weight: 600; }
.split .list button.add { color: #52525b; }
.split .editor { flex: 3 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.editor label { display: block; margin-bottom: 8px; font-weight: 500; }
.question { display: flex; gap: 8px; margin-bottom: 8px; }
.question input { flex: 1 1 auto; min-width: 0; }
.question button { flex: 0 0 44px; height: 44px; border: 1px solid var(--field); border-radius: 8px; background: #fff; color: #52525b; }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 32px; border-bottom: 1px solid var(--line); }
.tabs button { height: 44px; padding: 0 12px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: #52525b; }
.tabs button[aria-pressed="true"] { border-bottom-color: var(--accent); color: var(--ink); font-weight: 600; }
.search { max-width: 360px; margin-top: 20px; }
.search label { display: block; margin-bottom: 8px; font-weight: 500; }
.table-box { margin-top: 20px; overflow-x: auto; }
table { width: 100%; min-width: 680px; border-collapse: collapse; }
th { padding: 10px 16px 10px 0; border-bottom: 1px solid var(--field); color: var(--muted); font-size: 13px; font-weight: 500; text-align: left; }
td { height: 48px; padding: 4px 16px 4px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.transcript { margin-top: 28px; }
.transcript header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.line { padding: 12px 0; border-top: 1px solid var(--line); }
.line strong { font-size: 13px; }
.line p { margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; }

.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.login { width: 100%; max-width: 360px; }
.login .brand { padding: 0; }
.login h1 { margin-top: 32px; }
.login p.muted { margin-top: 6px; font-size: 14px; }
.login label { display: block; margin: 28px 0 8px; font-weight: 500; }

/* Logowanie przez Discord */
.discord-btn { display: flex; align-items: center; justify-content: center; gap: 10px; height: 44px; margin-top: 28px; border-radius: 8px; background: #5865f2; color: #fff; font-weight: 500; text-decoration: none; }
.discord-btn:hover { background: #4752c4; }
.or { display: flex; align-items: center; gap: 12px; margin: 24px 0 0; color: var(--muted); font-size: 13px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Zalogowany użytkownik i tryb podglądu */
.me { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; }
.me img { width: 24px; height: 24px; border-radius: 50%; }
.me .badge { margin-left: auto; padding: 1px 8px; border-radius: 999px; background: var(--active); color: var(--muted); font-size: 12px; }
.readonly-note { margin-bottom: 24px; padding: 10px 14px; border-radius: 8px; background: var(--active); color: var(--muted); font-size: 13px; }
body.readonly #view :is(input, select, textarea, button.primary, button.danger, #save) { pointer-events: none; opacity: .55; }
