:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #697586;
  --line: #d9dee7;
  --accent: #0877ee;
  --accent-dark: #055ebd;
  --shadow: 0 8px 26px rgba(17, 24, 39, 0.12);
}

html[data-theme="dark"] {
  --bg: #101418;
  --panel: #171d23;
  --ink: #eef2f6;
  --muted: #a5b0bd;
  --line: #2b3540;
  --accent: #58a6ff;
  --accent-dark: #8fc2ff;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.34);
}

* { box-sizing: border-box; }

html,
body {
  min-height: 100%;
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

button,
input { font: inherit; }

.directory-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
}

.directory-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 62px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand {
  display: inline-flex;
  align-items: center;
  min-width: 110px;
}

.brand img {
  max-width: 138px;
  max-height: 48px;
  display: block;
}

.directory-title {
  min-width: 0;
  text-align: center;
}

.directory-title h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.15;
}

.directory-title p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.theme-toggle-container {
  display: flex;
  align-items: center;
  min-width: 54px;
  justify-content: flex-end;
}

.theme-toggle-small {
  position: relative;
  display: inline-block;
  width: 54px;
  height: 28px;
  cursor: pointer;
  margin: 0;
  padding: 0;
}

.theme-toggle-input {
  position: absolute;
  width: 0;
  height: 0;
  margin: 0;
  padding: 0;
  opacity: 0;
}

.toggle-slider-small {
  position: absolute;
  inset: 0;
  cursor: pointer;
  border: 1px solid rgba(17, 24, 39, 0.12);
  border-radius: 28px;
  background: #eef2f6;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.theme-toggle-input:checked + .toggle-slider-small {
  background: var(--accent);
  border-color: rgba(8, 119, 238, 0.35);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 8px rgba(88, 166, 255, 0.38);
}

.toggle-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  margin: 0;
  padding: 0;
  font-size: 14px;
  line-height: 1;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toggle-icon-moon { opacity: 1; }
.toggle-icon-sun { opacity: 0; transform: translate(-50%, -50%) scale(0); }
.theme-toggle-input:checked + .toggle-slider-small .toggle-icon-moon { opacity: 0; transform: translate(-50%, -50%) scale(0); }
.theme-toggle-input:checked + .toggle-slider-small .toggle-icon-sun { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.directory-main {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(280px, 390px) minmax(0, 1fr);
  gap: 14px;
}

.create-panel,
.rooms-panel {
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.create-panel {
  align-self: start;
  padding: 16px;
}

.create-panel h2,
.rooms-panel h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
}

.create-panel p {
  margin: 8px 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.room-form {
  display: grid;
  gap: 10px;
}

.room-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

html[data-theme="dark"] .room-form input {
  background: #11171d;
  color: var(--ink);
  border-color: #354251;
}

.room-form button,
.room-card a {
  border: 0;
  border-radius: 8px;
  padding: 11px 14px;
  font-weight: 900;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

.room-form button:hover,
.room-card a:hover {
  background: var(--accent-dark);
}

.hint {
  min-height: 18px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.rooms-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.rooms-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 50px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.rooms-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.count-pop {
  animation: count-pop 420ms ease;
}

@keyframes count-pop {
  0% { transform: scale(1); }
  38% { transform: scale(1.14); color: var(--accent); }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .count-pop {
    animation: none;
  }
}

.rooms-list {
  min-height: 0;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 10px;
}

.room-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 90%, var(--bg));
}

.room-name {
  min-width: 0;
  font-size: 15px;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-meta {
  margin-top: 3px;
  display: flex;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.empty-state {
  padding: 24px 12px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

@media (max-width: 760px) {
  .directory-shell {
    gap: 10px;
    padding: 10px;
  }

  .directory-header {
    min-height: 46px;
    padding: 6px 8px;
    gap: 8px;
  }

  .brand {
    min-width: 92px;
  }

  .brand img {
    max-width: 92px;
    max-height: 34px;
  }

  .directory-title h1 {
    font-size: 15px;
  }

  .directory-title p {
    display: none;
  }

  .theme-toggle-container {
    min-width: 45px;
  }

  .theme-toggle-small {
    width: 45px;
    height: 22px;
  }

  .toggle-icon {
    font-size: 12px;
  }

  .directory-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }
}
