:root {
  --bg: #111814;
  --panel: #18221e;
  --line: #2a3832;
  --text: #e7efe9;
  --muted: #8fa399;
  --green: #3ecf8e;
  --amber: #e0b35a;
  --red: #e57a6a;
  --blue: #5ec8ff;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(700px 320px at 50% -80px, rgba(62, 207, 142, 0.12), transparent),
    var(--bg);
}

.app {
  width: min(480px, 100%);
  margin: 0 auto;
  padding: 14px 12px 36px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 14px 12px 16px;
}

.label {
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.section-gap { margin: 16px 0 8px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 8px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.idle-note {
  font-size: 0.68rem;
  color: var(--muted);
}

.link {
  appearance: none;
  border: none;
  background: none;
  color: var(--muted);
  text-decoration: underline;
  font: inherit;
  cursor: pointer;
  padding: 0;
}

.open-btn {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 20px 16px;
  border-radius: 16px;
  border: none;
  font: inherit;
  font-weight: 700;
  font-size: 1.25rem;
  text-align: left;
  cursor: pointer;
}

.open-btn.free {
  background: linear-gradient(135deg, #2a9b68, var(--green));
  color: #062416;
  box-shadow: 0 10px 28px rgba(62, 207, 142, 0.25);
}

.open-btn.yours,
.open-btn.busy {
  background: linear-gradient(135deg, #2a6fad, #5ec8ff);
  color: #041018;
  animation: blue-btn-pulse 1.8s ease-in-out infinite;
}

.open-btn.disabled {
  background: #24302b;
  color: var(--muted);
  cursor: not-allowed;
}

.open-sub {
  font-size: 0.82rem;
  font-weight: 500;
  opacity: 0.9;
}

.pending {
  margin-top: 12px;
  padding: 12px;
  border-radius: 14px;
  border: 2px solid var(--red);
  background: rgba(229, 122, 106, 0.22);
  display: grid;
  gap: 8px;
  color: #ffe8e4;
}

.pending strong {
  color: #ffb4a8;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

.pending .hint { margin: 0; color: #f0c4bc; font-size: 0.85rem; }

.pending.blink {
  animation: pending-blink 1.1s ease-in-out infinite;
}

@keyframes pending-blink {
  0%, 100% { background-color: rgba(229, 122, 106, 0.18); }
  50% { background-color: rgba(229, 122, 106, 0.55); }
}

.book { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }

.hint-line {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
  min-height: 1.2em;
}

.err {
  min-height: 1.2em;
  margin: 8px 0 0;
  color: var(--red);
  font-size: 0.85rem;
}

.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; margin-top: 10px; }

button.min, button.go, a.go, .people button, .admin button, #pendingBtns button, .ctl {
  appearance: none;
  border: 1px solid var(--line);
  background: #121a17;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
}

a.go,
a.go:visited,
a.go:hover,
a.go:active {
  text-decoration: none;
  color: inherit;
  box-sizing: border-box;
}

button.min.active {
  border-color: rgba(62, 207, 142, 0.5);
  background: rgba(62, 207, 142, 0.15);
  color: var(--green);
}

button.go {
  background: var(--green);
  border-color: transparent;
  color: #062416;
}

button.go.high {
  background: transparent;
  border-color: rgba(229, 122, 106, 0.55);
  color: var(--red);
}

button.go.chat-btn,
button.chat-btn {
  background: #2a6fad;
  border-color: transparent;
  color: #041018;
}

button.go.quiet {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

a.go {
  display: inline-block;
}

a.go.quiet {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* CURRENT block */
.current-block {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #121a17;
}

.current-block.free {
  border-color: rgba(62, 207, 142, 0.45);
  background: rgba(62, 207, 142, 0.1);
}

.current-block.free .current-name,
.current-block.free .current-right {
  color: var(--green);
}

@keyframes blue-working-pulse {
  0%, 100% { background: rgba(94, 200, 255, 0.08); }
  50% { background: rgba(94, 200, 255, 0.32); }
}

@keyframes blue-btn-pulse {
  0%, 100% { background: #2a6fad; }
  50% { background: #5ec8ff; }
}

.current-block.active,
.current-block.busy {
  border-color: rgba(94, 200, 255, 0.5);
  background: rgba(94, 200, 255, 0.1);
  animation: blue-working-pulse 1.8s ease-in-out infinite;
}

.current-block.active .current-name,
.current-block.busy .current-name,
.current-block.active .current-right,
.current-block.busy .current-right {
  color: #5ec8ff;
}

.current-name {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.current-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.current-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  font-size: 1.1rem;
  font-weight: 700;
  white-space: nowrap;
}

.cur-free-dur {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.2;
}

.cur-free-until {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  margin-top: 2px;
}

.current-actions {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
}

.current-actions.hidden { display: none; }

.cur-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.cur-lab {
  color: var(--muted);
  font-size: 0.75rem;
  min-width: 3.5em;
}

.cur-val {
  min-width: 5.5em;
  text-align: left;
  font-weight: 700;
  font-size: 1.1rem;
}

.cur-val.cur-range {
  min-width: 0;
  flex: 1;
  font-size: 1.1rem;
}

.cur-current-tag {
  color: #5ec8ff;
  font-weight: 700;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  margin: 0 2px;
  font-family: var(--sans, "DM Sans", sans-serif);
}

.cur-arrows {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cur-shift {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.ctl.icon.arrow-blue {
  color: #5ec8ff;
  border-color: rgba(94, 200, 255, 0.45);
  padding: 4px 8px;
  min-width: 32px;
  font-size: 0.75rem;
  line-height: 1;
}

.current-actions .end-early {
  justify-self: start;
}

/* Queue rows */
.queue-list {
  display: grid;
  gap: 10px;
}

.queue-list:empty::after {
  content: "Queue empty — tap + Book to add yourself";
  color: var(--muted);
  font-size: 0.9rem;
  display: block;
  padding: 8px 2px;
}

.qrow {
  padding: 14px;
  border-radius: 14px;
  background: #121a17;
  border: 1px solid var(--line);
  display: grid;
  gap: 10px;
}

.qrow.next { border-color: rgba(224, 179, 90, 0.4); }
.qrow.mine { box-shadow: inset 0 0 0 1px rgba(94, 200, 255, 0.3); }
.qrow.high { border-color: rgba(229, 122, 106, 0.45); }

.qrow.gap {
  background: transparent;
  border-style: dashed;
  border-color: rgba(143, 167, 156, 0.35);
  opacity: 0.92;
}

.qrow.gap .qn {
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  font-size: 0.95rem;
}

.qrow.gap .qtag {
  color: var(--muted);
  border-color: rgba(143, 167, 156, 0.25);
}

.qrow.gap .qnum.gap-num {
  background: transparent;
  border-style: dashed;
  color: var(--muted);
}

/* 24h horizon tail — informational, not a gap between bookings */
.qrow.gap.gap-tail {
  opacity: 0.52;
  border-color: rgba(143, 163, 153, 0.18);
  background: rgba(0, 0, 0, 0.12);
}

.qrow.gap.gap-tail .qn,
.qrow.gap.gap-tail .qm,
.qrow.gap.gap-tail .qd,
.qrow.gap.gap-tail .qnum.gap-num {
  color: rgba(143, 163, 153, 0.72);
  font-weight: 500;
}

.qrow.gap.gap-tail .qm {
  font-size: 0.9rem;
}

.qrow.gap.gap-tail .qd {
  font-size: 0.82rem;
}

.qrow.gap.gap-tail .qtag {
  color: rgba(143, 163, 153, 0.55);
  border-color: transparent;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
}

.qrow.draggable {
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.qrow.draggable:active {
  cursor: grabbing;
}

.qrow.dragging {
  opacity: 0.45;
  pointer-events: none;
}

.qrow.drop-before {
  box-shadow: inset 0 3px 0 0 rgba(94, 200, 255, 0.85);
}

.qrow.drop-after {
  box-shadow: inset 0 -3px 0 0 rgba(94, 200, 255, 0.85);
}

.qrow.drop-on {
  border-color: rgba(94, 200, 255, 0.7);
  background: rgba(94, 200, 255, 0.08);
}

.qrow-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 80;
  pointer-events: none;
  opacity: 0.9;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  transform: translate(-9999px, -9999px);
}

.qrow-top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
}

.qnum {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #0d1411;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--muted);
}

.qn { font-weight: 700; font-size: 1.15rem; }
.qn-you { font-size: 0.75rem; font-weight: 500; color: var(--muted); }

.qmid { min-width: 0; }

.qtime-row,
.qdur-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.qdur-col .cur-arrows {
  margin-left: 2px;
}

.qm {
  font-family: var(--mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.qd {
  font-family: var(--mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  min-width: 4.2em;
  text-align: center;
}

.qdur-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.qtag {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 4px;
}

.qrow.next .qtag {
  color: var(--amber);
}

.ctl.icon {
  padding: 6px 9px;
  min-width: 34px;
  font-size: 0.9rem;
  line-height: 1;
  border-radius: 10px;
}

.ctl.danger {
  color: var(--red);
  border-color: rgba(229, 122, 106, 0.4);
}

.mono { font-family: var(--mono); }

.people {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.people button { border-radius: 14px; padding: 16px 12px; }

.pin-row {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}
.pin-row input, .url-row input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0d1411;
  color: var(--text);
  padding: 12px;
  font: inherit;
}

.admin {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.admin button.danger {
  border-color: color-mix(in srgb, var(--red) 55%, transparent);
  color: var(--red);
}

.url-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  margin-bottom: 8px;
}

.url-row input { flex: 1 1 180px; }

.chat-panel {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0 8px;
}

.chat-head .label {
  margin: 0;
}

.chat-refresh {
  flex-shrink: 0;
  font-size: 0.82rem;
}

.chat-panel .chat-log {
  max-height: min(52vh, 420px);
  min-height: 220px;
}

.chat {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.chat-log {
  margin-top: 8px;
  max-height: 160px;
  overflow-y: auto;
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #0d1411;
  border: 1px solid var(--line);
}

.chat-log.is-empty { padding: 12px; }

.chat-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

.chat-line { font-size: 0.85rem; line-height: 1.35; }
.chat-line .n { font-weight: 700; color: var(--green); }
.chat-line .t {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.65rem;
  margin-left: 6px;
}

.chat-alert {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(229, 122, 106, 0.45);
  background: rgba(229, 122, 106, 0.12);
  color: var(--text);
  font-weight: 600;
  font-size: 0.88rem;
  line-height: 1.35;
}

.chat-alert.blink {
  border-color: var(--red);
  background: rgba(229, 122, 106, 0.28);
  color: #ffe8e4;
  animation: pending-blink 1.1s ease-in-out infinite;
}

.chat-alert .t {
  display: block;
  margin-top: 4px;
  font-weight: 500;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.65rem;
}

.chat-form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.chat-form input {
  flex: 1;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0d1411;
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
}

.hidden { display: none !important; }

.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: max(12px, env(safe-area-inset-top)) 12px 24px;
  overflow-y: auto;
}

.settings-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: -1;
}

body.settings-open {
  overflow: hidden;
}

.settings-panel {
  width: min(480px, 100%);
  margin: 0 0 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #121c18;
}

.settings-panel .field-lab {
  display: block;
  margin: 10px 0 4px;
  font-size: 0.78rem;
  color: var(--muted);
}

.settings-panel input[type="text"],
.settings-panel input[type="password"],
.settings-panel input[type="time"] {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0d1411;
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
}

.settings-panel input[type="time"] {
  width: auto;
  min-width: 8.5rem;
}

.settings-actions {
  margin-top: 10px;
}

.settings-close {
  margin-top: 14px;
  width: 100%;
}

.label.subsection {
  margin-top: 12px;
  font-size: 0.72rem;
}

.notify-grid {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
  cursor: pointer;
}

.chat-btn {
  position: relative;
}

.chat-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  pointer-events: none;
}

.tg-steps {
  list-style: none;
  margin: 8px 0 10px;
  padding: 0;
  display: grid;
  gap: 10px;
}

.tg-step {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--panel) 80%, #000);
}

.tg-step.done {
  border-color: color-mix(in srgb, var(--green) 45%, var(--line));
}

.tg-step.done .tg-step-title::before,
.tg-step.done .field-lab::before {
  content: "✓ ";
  color: var(--green);
}

.tg-step-btn {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
  color: var(--muted);
}

.tg-step-title {
  margin: 0 0 4px;
  font-size: 0.92rem;
  color: var(--text);
}

.tg-step-note {
  margin: 6px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}

.tg-howto {
  margin: 6px 0 0;
  padding-left: 1.1rem;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}

.tg-howto strong {
  color: var(--text);
  font-weight: 600;
}

.tg-step-paste .field-lab {
  margin-top: 0;
}

.tg-status.linked {
  color: var(--green);
}

.tg-summary {
  margin-top: 4px;
  font-weight: 600;
}

.tg-summary.ready {
  color: var(--green);
}

.tz-roster {
  display: grid;
  gap: 6px;
  margin-top: 6px;
}

.tz-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--muted);
}

.tz-row .name {
  color: var(--text);
  font-weight: 600;
}

.tz-row .clock {
  font-family: var(--mono);
  font-size: 0.8rem;
}

.admin-people {
  margin-top: 4px;
}

.admin-user-list {
  display: grid;
  gap: 6px;
  margin: 8px 0 10px;
}

.admin-user-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.9rem;
}

.admin-user-row .meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.admin-user-row button.danger {
  border-color: color-mix(in srgb, var(--red) 55%, transparent);
  color: var(--red);
  flex-shrink: 0;
}

.admin-maintain .go.danger {
  border-color: color-mix(in srgb, var(--red) 55%, transparent);
  color: var(--red);
}

.admin-confirm {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-confirm #adminConfirmPin {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0d1411;
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  margin: 4px 0 8px;
}

.admin-confirm-actions {
  margin-top: 8px;
}

.admin-confirm-actions .go.danger {
  border-color: color-mix(in srgb, var(--red) 55%, transparent);
  color: var(--red);
  background: color-mix(in srgb, var(--red) 12%, transparent);
}

#newUserName {
  flex: 1 1 140px;
  min-width: 120px;
}

.their-time {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  width: min(420px, calc(100% - 24px));
  background: #24332c;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  z-index: 5;
}
