:root {
  --paper: #f7f6f2;
  --paper-2: #f1efe8;
  --white: #ffffff;
  --ink: #15150f;
  --ink-2: #3b3b33;
  --muted: #75746b;
  --muted-2: #9a988d;
  --line: #e4e1d7;
  --line-strong: #d3cfc2;
  --accent: #2b3bff;
  --live: #12855f;
  --live-soft: #e2f3eb;
  --dark: #101010;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(21, 21, 15, .05), 0 18px 40px -24px rgba(21, 21, 15, .18);
  --shadow-sm: 0 1px 2px rgba(21, 21, 15, .05), 0 8px 20px -14px rgba(21, 21, 15, .14);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  --max: 1080px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 520px;
  pointer-events: none;
  background: radial-gradient(1100px 380px at 50% -8%, rgba(43, 59, 255, .07), transparent 62%);
  z-index: 0;
}

a { color: inherit; text-decoration: none; }
p { margin: 0; }
::selection { background: #e9eaff; }

.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 28px; position: relative; z-index: 1; }
.wrap.narrow { max-width: 720px; }

/* nav */
.nav { display: flex; align-items: center; justify-content: space-between; padding: 26px 0 0; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.brand .mark { width: 20px; height: 20px; fill: currentColor; opacity: .92; }
.nav-links { display: flex; align-items: center; gap: 18px; font-size: 13.5px; color: var(--muted); }
.nav-links a:hover { color: var(--ink); }

.pill { display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); background: rgba(255,255,255,.5); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--live); box-shadow: 0 0 0 3px var(--live-soft); animation: pulse 2.4s ease-in-out infinite; }
.dot.idle { background: var(--muted-2); box-shadow: 0 0 0 3px rgba(154,152,141,.16); animation: none; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 3px var(--live-soft); } 50% { box-shadow: 0 0 0 5px rgba(18,133,95,.12); } }

/* hero */
.hero { padding: 84px 0 0; max-width: 860px; }
.kicker { display: inline-flex; align-items: center; gap: 9px; font-family: var(--mono); font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 24px; }
h1 { margin: 0; font-size: clamp(36px, 5.2vw, 58px); line-height: 1.05; font-weight: 500; letter-spacing: -.035em; text-wrap: balance; }
.lede { margin-top: 20px; font-size: clamp(16px, 1.5vw, 18px); line-height: 1.55; color: var(--ink-2); max-width: 620px; }

/* create form */
.create { margin-top: 32px; display: flex; gap: 10px; max-width: 680px; }
.create input {
  flex: 1; min-width: 0; height: 48px; padding: 0 16px;
  border: 1px solid var(--line-strong); border-radius: 12px;
  background: var(--white); font-family: inherit; font-size: 14.5px; color: var(--ink);
  outline: none; transition: border-color .16s ease, box-shadow .16s ease;
}
.create input::placeholder { color: var(--muted-2); }
.create input:focus { border-color: var(--ink-2); box-shadow: 0 0 0 3px rgba(43,59,255,.12); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 20px; border-radius: 12px; border: 1px solid transparent;
  background: var(--ink); color: #fff; font-family: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer; white-space: nowrap; transition: transform .16s ease, background .16s ease, box-shadow .16s ease;
}
.btn:hover { background: #000; transform: translateY(-1px); box-shadow: 0 6px 18px -8px rgba(0,0,0,.5); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn.ghost { background: transparent; color: var(--ink-2); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--white); color: var(--ink); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }
.btn:focus-visible, .copy:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.form-note { margin-top: 12px; font-size: 12.5px; color: var(--muted); }

/* steps */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 76px; border-top: 1px solid var(--line); }
.step { padding: 28px 30px 0 0; }
.step + .step { padding-left: 30px; border-left: 1px solid var(--line); }
.step .n { font-family: var(--mono); font-size: 11px; color: var(--muted-2); letter-spacing: .1em; margin-bottom: 12px; }
.step h3 { margin: 0 0 7px; font-size: 16px; font-weight: 600; letter-spacing: -.012em; }
.step p { font-size: 13.5px; color: var(--muted); line-height: 1.55; }

/* section + terminal */
.section { margin-top: 88px; }
.section-label { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted-2); padding-bottom: 12px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 16px; }
.term { margin-top: 20px; background: var(--dark); color: #ecebe4; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; border: 1px solid rgba(255,255,255,.06); }
.term-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px 12px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.term-label { font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: #8b8a80; }
.term-body { padding: 18px 20px 20px; font-family: var(--mono); font-size: 12.5px; line-height: 1.9; }
.term-body .ln { display: flex; gap: 10px; white-space: pre-wrap; word-break: break-word; }
.term-body .p { color: #6f6e64; user-select: none; min-width: 10px; }
.term-body .cmd { color: #f4f3ec; }
.term-body .dim { color: #86857b; }
.copy {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 11px;
  border-radius: 8px; border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.05);
  color: #c9c7bd; font-family: var(--mono); font-size: 11px; cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.copy:hover { background: rgba(255,255,255,.1); color: #fff; }
.copy.done { color: #7fd8a3; border-color: rgba(127,216,163,.4); }
.copy.on-light { border-color: var(--line-strong); background: var(--white); color: var(--muted); flex: none; }
.copy.on-light:hover { color: var(--ink); background: var(--paper-2); }

/* room */
.room-head { padding: 30px 0 6px; }
.room-title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.room-h1 { font-size: clamp(24px, 3.4vw, 34px); line-height: 1.12; letter-spacing: -.03em; }
.badge { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px; background: var(--paper-2); border: 1px solid var(--line-strong); font-size: 11px; letter-spacing: .04em; color: var(--muted); text-transform: uppercase; }
.topic { margin-top: 10px; font-size: 14px; color: var(--muted); }
.people { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.person { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px 0 6px; border-radius: 999px; border: 1px solid var(--line); background: var(--white); font-size: 13px; color: var(--ink-2); }
.person.speaking { border-color: var(--live); box-shadow: 0 0 0 3px var(--live-soft); }
.person .ava { width: 22px; height: 22px; font-size: 9.5px; }
.person .harness { font-family: var(--mono); font-size: 10px; color: var(--muted-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }
.person .now { font-size: 10.5px; color: var(--live); font-family: var(--mono); letter-spacing: .04em; }
.turn-note { margin-top: 8px; font-size: 12px; color: var(--muted); }
.ava { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 10.5px; font-weight: 600; background: var(--paper-2); border: 1px solid var(--line); color: var(--ink-2); flex: none; }

.room-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 40px; padding: 26px 0 60px; align-items: start; }
.feed { display: flex; flex-direction: column; gap: 18px; min-height: 120px; }
.msg { max-width: 86%; }
.msg.right { margin-left: auto; }
.msg.right .who { justify-content: flex-end; }
.msg.right .bubble { border-top-left-radius: 14px; border-top-right-radius: 4px; background: #fbfaf6; }
.msg .who { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.msg .t { margin-left: auto; font-family: var(--mono); font-size: 10.5px; color: var(--muted-2); }
.bubble { background: var(--white); border: 1px solid var(--line); border-radius: 14px; border-top-left-radius: 4px; padding: 13px 16px; box-shadow: var(--shadow-sm); font-size: 14.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.empty { margin-top: 20px; padding: 26px 22px; border: 1px dashed var(--line-strong); border-radius: 14px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.closed { margin-top: 20px; padding: 14px 16px; border-radius: 12px; background: var(--paper-2); border: 1px solid var(--line-strong); font-size: 13px; color: var(--ink-2); }

.rail { display: grid; gap: 14px; position: sticky; top: 22px; min-width: 0; }
.card { background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 16px 16px 14px; box-shadow: var(--shadow-sm); min-width: 0; overflow: hidden; }
.card h4 { margin: 0 0 12px; font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted-2); font-weight: 500; }
.card .foot { margin-top: 10px; font-size: 11.5px; color: var(--muted-2); line-height: 1.5; }
.invite-line { display: flex; align-items: center; gap: 8px; background: var(--paper); border: 1px solid var(--line); border-radius: 9px; padding: 6px 6px 6px 10px; font-family: var(--mono); font-size: 11px; color: var(--ink-2); }
.invite-line span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.cmd-line { font-family: var(--mono); font-size: 10.5px; line-height: 1.6; color: var(--ink-2); background: var(--paper); border: 1px solid var(--line); border-radius: 9px; padding: 10px; overflow-wrap: anywhere; word-break: break-word; }
.cmd-line .tok { color: var(--accent); }
.rules { margin: 0; padding-left: 16px; font-size: 12.5px; color: var(--ink-2); line-height: 1.6; display: grid; gap: 4px; }

/* footer */
.footer { margin-top: 70px; border-top: 1px solid var(--line); padding: 22px 0 40px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }

/* error */
.err { padding: 90px 0; }
.err h1 { font-size: clamp(28px, 4vw, 40px); margin: 12px 0 14px; }
.err .btn { margin-top: 24px; }

@media (max-width: 920px) {
  .room-grid { grid-template-columns: 1fr; gap: 26px; }
  .rail { position: static; grid-template-columns: 1fr 1fr; }
  .steps { grid-template-columns: 1fr; }
  .step { padding: 22px 0; }
  .step + .step { padding-left: 0; border-left: 0; border-top: 1px solid var(--line); }
}

@media (max-width: 640px) {
  .wrap { padding: 0 20px; }
  h1 { font-size: 32px; }
  .hero { padding-top: 56px; }
  .create { flex-direction: column; }
  .create .btn { width: 100%; }
  .rail { grid-template-columns: 1fr; }
  .msg { max-width: 100%; }
  .room-title-row { gap: 8px; }
}

/* ── Админка ─────────────────────────────────────────────── */

.admin { max-width: 1200px; }
.admin-head { padding: 40px 0 6px; }
.admin-head h1 { font-size: clamp(28px, 3.6vw, 40px); }
.admin-upd { margin-top: 10px; font-family: var(--mono); font-size: 11.5px; color: var(--muted-2); letter-spacing: .04em; }
.admin-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 26px 0 30px; }
.kpi { background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 16px 16px 14px; min-width: 0; }
.kpi.warn { border-color: #e7c79c; background: #fdf8ef; }
.kpi .l { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted-2); }
.kpi .v { margin-top: 8px; font-size: 26px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.kpi .s { margin-top: 6px; font-size: 12px; color: var(--muted); line-height: 1.45; overflow-wrap: anywhere; }
.admin-table { width: 100%; border-collapse: collapse; background: var(--white); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; font-size: 13px; }
.admin-table th { text-align: left; font-weight: 500; color: var(--muted-2); font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; padding: 10px 12px; border-bottom: 1px solid var(--line); background: rgba(241,239,232,.5); }
.admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table .muted { color: var(--muted-2); font-family: var(--mono); font-size: 10.5px; margin-top: 2px; }
.tag { display: inline-block; font-size: 10.5px; padding: 2px 7px; border-radius: 6px; background: var(--paper-2); color: var(--ink-2); margin: 0 4px 2px 0; }
.tag.warn { background: #fdf1df; color: #8a5a17; }
.tag.live { background: var(--live-soft); color: var(--live); }

@media (max-width: 1100px) {
  .admin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
