:root {
  color-scheme: dark;
  --bg: #05070a;
  --surface: #10151c;
  --surface-2: #161d27;
  --line: #263241;
  --text: #f8fbff;
  --muted: #aab7c7;
  --accent: #47c7ff;
  --accent-2: #ffd166;
  --danger: #ff6b6b;
  --ok: #53e6a5;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

html:has(.shell.is-glasses),
html:has(.shell.is-glasses) body {
  background: transparent;
}

body {
  display: grid;
  place-items: center;
}

button,
input {
  font: inherit;
}

.shell {
  width: min(100vw, 600px);
  min-height: min(100vh, 600px);
  padding: 24px;
  display: grid;
  grid-template-rows: auto auto auto auto auto 1fr;
  gap: 14px;
  background:
    radial-gradient(circle at 50% -20%, rgba(71, 199, 255, 0.18), transparent 34%),
    var(--bg);
}

.shell.is-glasses {
  width: min(100vw, 600px);
  height: min(100vh, 600px);
  min-height: 0;
  padding: 0;
  gap: 0;
  grid-template-rows: 1fr;
  overflow: hidden;
  background: transparent;
}

.shell.is-glasses .phone-only {
  display: none;
}

.shell.is-glasses .status-bar,
.shell.is-glasses .notice,
.shell.is-glasses .current-copy,
.shell.is-glasses .actions,
.shell.is-glasses .history-panel {
  display: none;
}

.status-bar,
.section-heading,
.actions,
.input-row,
.room-row {
  display: flex;
  align-items: center;
}

.status-bar {
  justify-content: space-between;
  gap: 16px;
}

.eyebrow,
.meta,
.video-id,
.section-heading span {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
}

.eyebrow {
  color: var(--accent);
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.05;
}

h2 {
  margin-top: 8px;
  font-size: 24px;
  line-height: 1.12;
}

h3 {
  font-size: 16px;
}

.pill {
  flex: 0 0 auto;
  min-width: 72px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.pill.is-live {
  color: var(--ok);
  border-color: rgba(83, 230, 165, 0.42);
}

.pill.is-error {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.46);
}

.notice {
  padding: 10px 12px;
  border: 1px solid rgba(255, 209, 102, 0.45);
  border-radius: 8px;
  background: rgba(255, 209, 102, 0.1);
  color: var(--accent-2);
  font-size: 14px;
  font-weight: 700;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.room-row {
  gap: 8px;
}

.room-row input {
  min-width: 0;
  flex: 1 1 140px;
}

.room-row .action-button {
  flex: 0 0 auto;
  min-height: 42px;
  padding-inline: 12px;
}

.current-layout {
  display: grid;
  grid-template-columns: 178px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.shell.is-glasses .current-layout {
  position: relative;
  width: 100%;
  height: 100%;
  grid-template-columns: 1fr;
  gap: 0;
  align-self: center;
}

.shell.is-glasses .thumbnail-frame {
  position: absolute;
  max-height: none;
  border: 0;
  background: transparent;
  border-radius: 0;
  transition:
    left 160ms ease,
    top 160ms ease,
    width 160ms ease,
    transform 160ms ease;
}

.shell.is-glasses .thumbnail-frame[data-layout="center"] {
  left: 50%;
  top: 50%;
  width: 100%;
  transform: translate(-50%, -50%);
}

.shell.is-glasses .thumbnail-frame[data-layout="top-left"],
.shell.is-glasses .thumbnail-frame[data-layout="top-right"],
.shell.is-glasses .thumbnail-frame[data-layout="bottom-right"],
.shell.is-glasses .thumbnail-frame[data-layout="bottom-left"] {
  width: 42%;
  transform: none;
}

.shell.is-glasses .thumbnail-frame[data-layout="top-left"] {
  left: 0;
  top: 0;
}

.shell.is-glasses .thumbnail-frame[data-layout="top-right"] {
  right: 0;
  top: 0;
}

.shell.is-glasses .thumbnail-frame[data-layout="bottom-right"] {
  right: 0;
  bottom: 0;
}

.shell.is-glasses .thumbnail-frame[data-layout="bottom-left"] {
  left: 0;
  bottom: 0;
}

.shell.is-glasses .thumbnail-frame:focus,
.shell.is-glasses .thumbnail-frame:focus-visible,
.shell.is-glasses .thumbnail-frame.is-selected {
  outline: none;
  border: 0;
  box-shadow: none;
}

.shell.is-glasses .thumbnail-frame .player-slot,
.shell.is-glasses .thumbnail-frame iframe {
  background: transparent;
}

.shell.is-glasses .empty-thumbnail {
  display: none !important;
}

.thumbnail-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
  display: block;
  padding: 0;
  cursor: pointer;
}

.thumbnail-frame img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.thumbnail-frame .player-slot,
.thumbnail-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: none;
  background: #000;
}

.shell.is-glasses .thumbnail-frame iframe {
  pointer-events: none;
}

.shell.is-glasses .thumbnail-frame[data-provider="niconico"] iframe {
  pointer-events: auto;
}

.thumbnail-frame.is-playing img,
.thumbnail-frame.is-playing .empty-thumbnail {
  display: none;
}

.thumbnail-frame.is-playing .player-slot,
.thumbnail-frame.is-playing iframe {
  display: block;
}

.thumbnail-frame img[src=""] {
  display: none;
}

.empty-thumbnail {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(248, 251, 255, 0.34);
  font-size: 32px;
  font-weight: 900;
}

.current-copy {
  min-width: 0;
}

.video-id {
  margin-top: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}

.input-row {
  gap: 10px;
}

.input-row input {
  width: 100%;
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.icon-button,
.action-button {
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 800;
}

.icon-button {
  width: 48px;
  flex: 0 0 48px;
  font-size: 28px;
  line-height: 1;
}

.actions {
  gap: 10px;
}

.action-button {
  flex: 1 1 0;
  padding: 0 12px;
  font-size: 14px;
}

.focusable:focus,
.focusable:focus-visible,
.history-item:focus,
.history-item:focus-visible,
.is-selected {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.is-selected {
  border-color: rgba(71, 199, 255, 0.72);
  box-shadow: 0 0 0 2px rgba(71, 199, 255, 0.16);
}

.history-panel {
  min-height: 0;
  padding-top: 2px;
}

.section-heading {
  justify-content: space-between;
  margin-bottom: 8px;
}

.history-list {
  height: 100%;
  max-height: 184px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
  display: grid;
  gap: 8px;
}

.history-item {
  width: 100%;
  min-height: 56px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  text-align: left;
}

.history-title {
  display: block;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-meta {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

@media (max-width: 520px), (max-height: 560px) {
  .shell {
    min-height: 100vh;
    padding: 18px;
    gap: 12px;
  }

  .current-layout {
    grid-template-columns: 1fr;
  }

  .thumbnail-frame {
    max-height: 190px;
  }

  h1 {
    font-size: 26px;
  }

  h2 {
    font-size: 22px;
  }
}
