@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=JetBrains+Mono:wght@400;600&display=swap");

/* Wygląd jak krngg.dev: ciemne tło z siatką, róż, szklane panele. */
:root {
  color-scheme: dark;
  --pink: #ff3d9a;
  --pink-2: #ff8cc4;
  --pink-3: #ffd1e6;
  --ink: #1c0612;
  --bg: #0c0709;
  --panel: #170f14;
  --glass: #170f14e6;
  --fg: #fdf0f6;
  --muted: #c3a6b5;
  --dim: #8a7280;
  --line: #ffffff14;
  --line-2: #ff3d9a55;
  --field: #ffffff0d;
  --active: #ff3d9a1f;
  --ok: #5cf2a0;
  --warn: #ffb067;
  --danger: #ff5470;
  --accent: var(--pink);
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  /* nietoperz krngg jako znak marki */
  --bat: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cg transform='translate(0 9)' fill='%23ff3d9a'%3E%3Cpath d='M84 86C66 70 40 58 12 60c10 14 12 30 8 48 10-8 22-8 28 2 6-10 18-12 24-2 4-8 10-10 14-4z'/%3E%3Cpath d='M116 86c18-16 44-28 72-26-10 14-12 30-8 48-10-8-22-8-28 2-6-10-18-12-24-2-4-8-10-10-14-4z'/%3E%3Cpath d='M80 72l3-30 14 20z' stroke='%23ff3d9a' stroke-width='6' stroke-linejoin='round'/%3E%3Cpath d='M120 72l-3-30-14 20z' stroke='%23ff3d9a' stroke-width='6' stroke-linejoin='round'/%3E%3Crect x='76' y='58' width='48' height='80' rx='24'/%3E%3Cellipse cx='91' cy='84' rx='5' ry='6' fill='%231c0612'/%3E%3Cellipse cx='109' cy='84' rx='5' ry='6' fill='%231c0612'/%3E%3Cpath d='M94 97l2.5 7 2.5-7zM101 97l2.5 7 2.5-7z' fill='%23fdf0f6'/%3E%3C/g%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--fg);
  font: 15px/1.5 "Space Grotesk", system-ui, "Segoe UI", sans-serif;
  background:
    radial-gradient(900px 500px at 85% -10%, #ff3d9a1f, transparent 70%),
    linear-gradient(#ffffff07 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(90deg, #ffffff07 1px, transparent 1px) 0 0 / 32px 32px,
    var(--bg);
  background-attachment: fixed;
}
::selection { background: var(--pink); color: var(--ink); }
:focus-visible { outline: 2px solid var(--pink-2); outline-offset: 2px; }
h1 { margin: 0; font-size: 32px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--pink-2); }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 8px; }

/* ---------- układ ---------- */
.shell { min-height: 100vh; display: flex; flex-wrap: wrap; align-items: stretch; gap: 16px; padding: 16px; }
.side {
  flex: 1 1 230px;
  max-width: 100%;
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 18px;
  backdrop-filter: blur(16px);
}
@media (min-width: 820px) {
  .side { flex: 0 0 250px; position: sticky; top: 16px; height: calc(100vh - 32px); }
}
.content {
  flex: 999 1 560px;
  min-width: 0;
  padding: 36px clamp(18px, 4vw, 56px) 64px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 18px;
  backdrop-filter: blur(16px);
  position: relative;
}
.content::before {
  content: "";
  position: absolute;
  top: 16px;
  left: 18px;
  width: 52px;
  height: 12px;
  background:
    radial-gradient(circle at 6px 6px, var(--pink) 5px, transparent 5.5px),
    radial-gradient(circle at 26px 6px, var(--pink-2) 5px, transparent 5.5px),
    radial-gradient(circle at 46px 6px, var(--pink-3) 5px, transparent 5.5px);
  opacity: .85;
}
#view { max-width: 820px; margin-top: 8px; }
#view.wide { max-width: 1040px; }

.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px; font-size: 22px; font-weight: 700; letter-spacing: -0.04em; }
.mark { width: 34px; height: 34px; background: var(--bat) center / contain no-repeat; filter: drop-shadow(0 0 14px #ff3d9a66); }

nav { display: flex; flex-direction: column; gap: 2px; }
nav a {
  display: flex;
  align-items: center;
  height: 42px;
  padding: 0 12px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  transition: background .15s, color .15s;
}
nav a::before { content: "›"; width: 14px; color: transparent; font-family: var(--mono); transition: color .15s; }
nav a:hover { background: #ffffff08; color: var(--fg); }
nav a[aria-current="page"] { background: var(--active); color: var(--fg); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line-2); }
nav a[aria-current="page"]::before { color: var(--pink); }

.status { margin-top: auto; padding: 14px 12px 0; border-top: 1px solid var(--line); font-family: var(--mono); font-size: 12px; }
.status #guild { margin-top: 2px; }
.status-line { display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dim); }
.dot.on { background: var(--ok); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 #5cf2a066; } 50% { box-shadow: 0 0 0 5px #5cf2a000; } }

/* ---------- treść ---------- */
header.page { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; padding-top: 12px; }
header.page p { margin-top: 6px; color: var(--muted); }
section { margin-top: 36px; }
section > h2::before { content: "// "; color: var(--pink); font-family: var(--mono); font-size: 13px; font-weight: 400; }
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: 14px 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: 14px 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(--line);
  border-radius: 12px;
  background: var(--field);
  color: var(--fg);
  font: inherit;
  transition: border-color .15s, background .15s;
}
input, select { height: 44px; padding: 0 14px; }
textarea { padding: 10px 14px; resize: vertical; min-height: 84px; }
input:hover, select:hover, textarea:hover { border-color: #ffffff2a; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--pink); background: #ff3d9a0d; }
select option { background: var(--panel); color: var(--fg); }
select:disabled { color: var(--dim); }
::placeholder { color: var(--dim); }

button { font: inherit; cursor: pointer; color: inherit; }
.primary, .secondary { height: 44px; padding: 0 20px; border-radius: 999px; font-weight: 700; transition: background .15s, transform .1s; }
.primary { border: 0; background: var(--pink); color: var(--ink); }
.primary:hover:not(:disabled) { background: var(--pink-2); }
.primary:active:not(:disabled) { transform: translateY(1px); }
.secondary { border: 1px solid var(--line-2); background: transparent; color: var(--pink-3); font-weight: 500; }
.secondary:hover:not(:disabled) { background: var(--active); }
.danger-text { color: var(--danger); }
.primary:disabled, .secondary:disabled { opacity: .5; cursor: default; }
.wide { width: 100%; margin-top: 12px; }
.link { height: 44px; padding: 0; border: 0; background: transparent; color: var(--dim); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--pink-2); }
.link.accent { color: var(--pink-2); 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 16px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--active); color: var(--pink-3); }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 12px; background: var(--field); font-size: 18px; }
.stepper button:hover { border-color: var(--pink); color: var(--pink); }
.stepper output { width: 48px; text-align: center; font: 600 16px var(--mono); }
.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: #ffffff1f; position: relative; transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--fg); transition: left .2s var(--ease); }
.switch[aria-checked="true"] span { background: var(--pink); }
.switch[aria-checked="true"] span::after { left: 23px; background: var(--ink); }

.split { display: flex; flex-wrap: wrap; gap: 24px 40px; margin-top: 36px; 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: 42px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.split .list button:hover { background: #ffffff08; color: var(--fg); }
.split .list button[aria-pressed="true"] { background: var(--active); color: var(--fg); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line-2); }
.split .list button.add { color: var(--pink-2); }
.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(--line); border-radius: 12px; background: var(--field); color: var(--muted); }
.question button:hover { border-color: var(--danger); color: var(--danger); }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 28px; }
.tabs button { height: 38px; padding: 0 16px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--muted); font-size: 14px; }
.tabs button:hover { color: var(--fg); border-color: #ffffff2a; }
.tabs button[aria-pressed="true"] { border-color: var(--pink); background: var(--pink); color: var(--ink); font-weight: 700; }
.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; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; min-width: 680px; border-collapse: collapse; }
th { padding: 12px 16px; border-bottom: 1px solid var(--line); background: #ffffff05; color: var(--dim); font: 500 11px var(--mono); letter-spacing: .1em; text-transform: uppercase; text-align: left; }
td { height: 50px; padding: 6px 16px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #ffffff05; }
.transcript { margin-top: 28px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 14px; background: #0c0709b3; }
.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: 600 13px var(--mono); color: var(--pink-2); }
.line p { margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- logowanie ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 40px 16px; }
.login {
  width: 100%;
  max-width: 400px;
  padding: 34px 30px 28px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 22px;
  backdrop-filter: blur(16px);
  box-shadow: 0 40px 100px #000a, 0 0 80px #ff3d9a14;
  animation: pop .4s var(--ease);
}
.login .brand { padding: 0; flex-direction: column; gap: 8px; text-align: center; }
.login .mark { width: 76px; height: 76px; filter: drop-shadow(0 0 30px #ff3d9a88); animation: bob 3s ease-in-out infinite; }
.login h1 { margin-top: 22px; text-align: center; font-size: 26px; }
.login p.muted { margin-top: 6px; font-size: 13px; text-align: center; }
.login label { display: block; margin: 22px 0 8px; font-weight: 500; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

/* Logowanie przez Discord */
.discord-btn { display: flex; align-items: center; justify-content: center; gap: 10px; height: 46px; margin-top: 26px; border-radius: 999px; background: #5865f2; color: #fff; font-weight: 700; text-decoration: none; transition: background .15s; }
.discord-btn:hover { background: #4752c4; }
.or { display: flex; align-items: center; gap: 12px; margin: 22px 0 0; color: var(--dim); font: 12px var(--mono); }
.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: 13px "Space Grotesk", sans-serif; }
.me img { width: 26px; height: 26px; border-radius: 50%; box-shadow: 0 0 0 2px var(--line-2); }
.me .badge { margin-left: auto; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--warn); color: var(--warn); font: 11px var(--mono); }
.readonly-note { max-width: 820px; margin: 8px 0 20px; padding: 10px 14px; border: 1px solid #ffb06755; border-radius: 12px; background: #ffb0670f; color: var(--warn); font-size: 13px; }
body.readonly #view :is(input, select, textarea, button.primary, button.danger, #save) { pointer-events: none; opacity: .5; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 560px) {
  .shell { padding: 10px; gap: 10px; }
  .content { padding: 34px 16px 48px; }
  h1 { font-size: 26px; }
}
