:root {
  --bg: #f4f7f2;
  --card: #ffffff;
  --ink: #182018;
  --accent: #1d7a49;
  --accent-2: #145734;
  --muted: #6f7d6f;
  --line: #dbe4d9;
  --danger: #b33030;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #eef4ea 0%, #f8fbf7 100%);
  color: var(--ink);
}

.topbar {
  position: sticky;
  top: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.72)),
    url('/back.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 12px 20px;
  padding-right: 280px;
  z-index: 10;
}

.topbar > h1 {
  margin: 0 0 10px;
}

.menu {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.mobile-only {
  display: none;
}

.authbar {
  display: flex;
  gap: 10px;
  align-items: center;
  position: absolute;
  top: 12px;
  right: 20px;
}

.hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 900px) {
  .topbar {
    padding-right: 20px;
  }

  .authbar {
    position: static;
    margin-bottom: 10px;
  }
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.month-nav h1 {
  font-size: 20px;
  margin: 0;
  min-width: 250px;
}

button {
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  padding: 8px 12px;
  cursor: pointer;
}

button:hover {
  background: var(--accent-2);
}

button.secondary {
  background: #8d9a8d;
}

button.danger {
  background: var(--danger);
}

main {
  padding: 18px;
}

.calendar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.day {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.day-head {
  padding: 8px 10px;
  font-weight: 700;
  background: #eef5ec;
  border-bottom: 1px solid var(--line);
}

.slot-table {
  width: 100%;
  border-collapse: collapse;
}

.slot-table td {
  border-bottom: 1px solid var(--line);
  padding: 5px 8px;
  font-size: 13px;
}

.slot-table tr:last-child td {
  border-bottom: 0;
}

.slot-time {
  width: 52px;
  color: var(--muted);
}

.slot-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--ink);
  border-radius: 8px;
  padding: 4px 6px;
}

.slot-btn.free {
  color: #7f8a7f;
}

.slot-btn.busy {
  color: #0d4c2b;
  background: #e8f7ef;
}

dialog {
  border: none;
  border-radius: 14px;
  padding: 0;
  width: min(460px, calc(100vw - 24px));
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

dialog.wide {
  width: min(960px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow-y: auto;
}

.stream-video {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 46vh;
  background: #0d1a12;
  border-radius: 8px;
}

.stream-status {
  color: var(--muted);
  font-size: 14px;
}

.stream-status.live {
  color: var(--accent);
}

form {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.mobile-menu-grid {
  display: grid;
  gap: 8px;
}

.inline-create {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f7faf5;
}

.manage-list {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.manage-list table {
  width: 100%;
  border-collapse: collapse;
}

.manage-list td,
.manage-list th {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
}

.manage-list tr:last-child td {
  border-bottom: 0;
}

.manage-list button {
  padding: 5px 8px;
  font-size: 12px;
}

.manage-list tr.selectable-row {
  cursor: pointer;
}

.manage-list tr.selectable-row:hover td {
  background: #eef7f1;
}

label {
  display: grid;
  gap: 5px;
  font-size: 14px;
}

input,
select {
  width: 100%;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0;
  margin: 8px 0 0;
}

.hidden {
  display: none;
}

@media (max-width: 900px) {
  .calendar {
    grid-template-columns: 1fr;
  }

  main {
    padding: 10px;
  }
}

@media (max-width: 700px) {
  .mobile-only {
    display: inline-block;
    margin-bottom: 10px;
  }

  .menu,
  .authbar {
    display: none;
  }

  .month-nav h1 {
    min-width: 0;
    font-size: 18px;
  }

  .topbar > h1 {
    font-size: 20px;
  }
}

.stream-timeline {
  display: grid;
  gap: 4px;
}

.stream-track {
  position: relative;
  height: 30px;
  background: var(--line);
  border-radius: 8px;
  cursor: pointer;
  overflow: hidden;
  touch-action: manipulation;
}

.stream-track:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.stream-seg {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--accent);
  opacity: 0.55;
}

.stream-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  margin-left: -1px;
  background: var(--accent-2);
  box-shadow: 0 0 0 1px #fff;
  pointer-events: none;
}

.stream-hover {
  position: absolute;
  top: 2px;
  transform: translateX(-50%);
  padding: 2px 6px;
  font-size: 12px;
  color: #fff;
  background: rgba(24, 32, 24, 0.85);
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
}

.stream-ticks {
  position: relative;
  height: 16px;
  font-size: 12px;
  color: var(--muted);
}

.stream-tick {
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}

.stream-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.stream-clock {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.stream-spacer {
  flex: 1 1 0;
}

.stream-goto {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
}

.stream-goto label {
  flex: 1 1 220px;
}

.live-site {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0;
}

.live-site legend {
  font-weight: 600;
  padding: 0 4px;
}

.live-site-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.live-site-modes label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.live-site-state {
  margin: 8px 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.live-site-modes input {
  width: auto;
  margin: 0;
}
