:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --ink: #18202f;
  --muted: #667085;
  --line: #d9deea;
  --accent: #116a7b;
  --accent-strong: #0c5664;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --shadow: 0 18px 50px rgba(23, 31, 46, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(17, 106, 123, 0.12), transparent 35%),
    linear-gradient(315deg, rgba(207, 84, 70, 0.1), transparent 38%),
    var(--bg);
  font-family:
    Inter, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 16px;
  color: var(--ink);
  background: var(--panel);
  cursor: pointer;
  transition:
    transform 0.15s ease,
    border-color 0.15s ease,
    background 0.15s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: #9ca8ba;
}

button:disabled {
  color: #98a2b3;
  cursor: not-allowed;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 20px;
  width: min(1180px, calc(100vw - 32px));
  min-height: calc(100vh - 32px);
  margin: 16px auto;
}

.room-panel,
.call-stage {
  border: 1px solid rgba(217, 222, 234, 0.92);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.room-panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
  align-self: stretch;
  border-radius: 8px;
  padding: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.65rem, 1.2rem + 1vw, 2.25rem);
  line-height: 1.12;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.field input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(17, 106, 123, 0.13);
}

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

.primary-button {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
  font-weight: 800;
}

.primary-button:hover:not(:disabled) {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.secondary-button {
  font-weight: 700;
}

.status-box {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 12px;
  align-items: start;
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcff;
}

.status-dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 50%;
  background: #98a2b3;
}

.status-dot.online {
  background: #12b76a;
}

.status-dot.warning {
  background: #f79009;
}

.status-box p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.status-box time {
  display: block;
  margin-top: 6px;
  color: #8a95a7;
  font-size: 0.82rem;
  line-height: 1.4;
}

.call-stage {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 14px;
  overflow: hidden;
  border-radius: 8px;
  padding: 14px;
}

.video-grid {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
}

.video-tile {
  position: relative;
  overflow: hidden;
  min-height: 280px;
  border: 1px solid #111827;
  border-radius: 8px;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.1), transparent 34%),
    #101828;
}

.video-tile video {
  width: 100%;
  height: 100%;
  min-height: inherit;
  object-fit: cover;
  display: block;
  background: #101828;
}

.local-tile {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 2;
  width: min(30vw, 320px);
  min-width: 190px;
  min-height: 126px;
  aspect-ratio: 16 / 10;
  border-color: rgba(255, 255, 255, 0.68);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.25);
}

.local-tile video {
  min-height: 126px;
}

.video-label {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 24px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 8px 10px;
  color: #fff;
  background: rgba(16, 24, 40, 0.72);
  backdrop-filter: blur(10px);
}

.video-label span {
  color: #d0d5dd;
  font-size: 0.82rem;
}

.video-label strong {
  min-width: 0;
  overflow: hidden;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.88);
}

.toolbar button {
  font-weight: 800;
}

.toolbar button.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(17, 106, 123, 0.1);
}

.danger-button {
  border-color: #fecdca;
  color: var(--danger);
  background: var(--danger-bg);
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(560px, 1fr);
    width: min(100vw - 20px, 720px);
    min-height: calc(100vh - 20px);
    margin: 10px auto;
  }

  .room-panel {
    padding: 18px;
  }

  .room-actions,
  .toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .local-tile {
    right: 18px;
    bottom: 18px;
    width: min(44vw, 260px);
  }
}

@media (max-width: 520px) {
  .app-shell {
    grid-template-rows: auto minmax(500px, 1fr);
  }

  .room-actions,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .call-stage {
    padding: 10px;
  }

  .local-tile {
    right: 16px;
    bottom: 16px;
    width: min(58vw, 220px);
    min-width: 150px;
  }
}
