:root {
  color-scheme: dark;
  --bg: oklch(20.2% 0.0042 308.23);
  --header: hsl(76, 10%, 5%);
  --panel: oklch(24.27% 0.0081 308.09);
  --panel-soft: oklch(27% 0.008 308.09);
  --field: oklch(30.5% 0.0093 303.91);
  --field-strong: oklch(35.31% 0.0123 298.81);
  --line: oklch(32.62% 0.0097 312.14);
  --line-soft: oklch(32.62% 0.0097 312.14);
  --text: oklch(100% 0 0);
  --muted: oklch(71.19% 0.0129 286.07);
  --muted-2: oklch(58% 0.0129 286.07);
  --green: oklch(91.96% 0.2367 126.86);
  --green-dark: oklch(78.65% 0.1965 125.71);
  --red: oklch(63.68% 0.2078 25.33);
  --red-bg: color-mix(in oklab, var(--red) 18%, transparent);
  --accent: oklch(18.27% 0 0);
  --radius: 12px;
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.26), 0 1px 2px -1px rgba(0, 0, 0, 0.26);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: oklch(100% 0 0);
  --header: #ffffff;
  --panel: oklch(97.64% 0 0);
  --panel-soft: oklch(96.76% 0.0013 286.37);
  --field: #ffffff;
  --field-strong: oklch(90.72% 0.0011 17.18);
  --line: oklch(91.97% 0.004 286.32);
  --line-soft: oklch(91.97% 0.004 286.32);
  --text: oklch(14.05% 0.0044 285.82);
  --muted: oklch(55.19% 0.0137 285.94);
  --muted-2: #7e7d88;
  --red-bg: #fee2e2;
  --shadow: 0 16px 40px rgba(20, 20, 24, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
}

.site-header {
  min-height: 64px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--header);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1280px, 100%);
  min-height: 64px;
  margin: 0 auto;
  padding: 0 16px;
  gap: 24px;
}

.site-title {
  color: var(--text);
  font-size: 30px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0;
  text-decoration: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.powered-by {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 8px;
  color: var(--text);
  font-size: 16px;
  font-weight: 400;
  font-family: Poppins, ui-sans-serif, system-ui, sans-serif;
  white-space: nowrap;
}

.getrekt-logo {
  display: block;
  width: 160px;
  height: auto;
  flex: 0 0 auto;
}

.notice {
  width: min(1280px, 100%);
  margin: 18px auto 0;
  padding: 11px 14px;
  border: 1px solid rgba(166, 255, 0, 0.25);
  border-radius: 10px;
  background: rgba(166, 255, 0, 0.08);
  color: var(--text);
}

.page-frame {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 64px 16px 76px;
}

.page-heading {
  margin-bottom: 32px;
}

.page-heading h1,
.page-title-row h1,
.auth-panel h1 {
  margin: 0;
  color: var(--text);
  font-size: 30px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0;
}

.page-heading p,
.page-subtitle,
.panel-copy,
.auth-panel p,
.admin-card p {
  color: var(--muted);
  line-height: 1.45;
}

.page-heading p,
.page-subtitle {
  margin: 8px 0 0;
  font-size: 14px;
}

.admin-card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

.admin-card-grid-two {
  max-width: 820px;
  margin-right: auto;
  margin-left: auto;
}

.admin-card,
.panel,
.controls-panel {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.admin-card {
  display: flex;
  min-height: 144px;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  color: var(--text);
  text-decoration: none;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.admin-card:hover {
  border-color: var(--line-soft);
  background: var(--panel);
  box-shadow: 0 10px 18px -10px rgba(0, 0, 0, 0.45), var(--shadow);
}

.admin-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: -8px;
  font-size: 16px;
  line-height: 1.5;
  font-weight: 500;
}

.admin-card p {
  margin: 0;
  font-size: 14px;
}

.card-icon {
  display: block;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: var(--muted);
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.card-icon * {
  vector-effect: non-scaling-stroke;
}

.page-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.page-subtitle {
  margin: -6px 0 30px;
}

.panel,
.controls-panel {
  padding: 24px;
}

.panel + .panel {
  margin-top: 24px;
}

.panel h2,
.controls-panel h2 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 500;
}

.panel-copy {
  margin: 0 0 20px;
  font-size: 14px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
}

input,
select {
  width: 100%;
  height: 38px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  color: var(--text);
  padding: 0 14px;
  font-weight: 500;
  outline: none;
}

input::placeholder {
  color: var(--muted-2);
}

input:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(166, 255, 0, 0.13);
}

select {
  appearance: none;
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

input[type="checkbox"] {
  width: 16px;
  min-height: 16px;
  accent-color: var(--green);
}

.primary-button,
.secondary-button,
.nav-button,
.danger-button,
.back-button,
.icon-button,
.effect-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  min-height: 32px;
  border: 0;
  border-radius: 8px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease, opacity 140ms ease, transform 140ms ease;
}

.primary-button {
  background: var(--green);
  color: var(--bg);
}

.primary-button:hover {
  background: color-mix(in oklab, var(--green) 82%, transparent);
}

.secondary-button,
.nav-button,
.back-button,
.icon-button {
  border: 1px solid var(--line-soft);
  background: #1a1a1f;
  color: var(--text);
}

:root[data-theme="light"] .secondary-button,
:root[data-theme="light"] .nav-button,
:root[data-theme="light"] .back-button,
:root[data-theme="light"] .icon-button {
  background: #f5f5f7;
}

.back-button {
  min-height: 32px;
  padding-inline: 11px;
}

.danger-button {
  border: 1px solid rgba(224, 49, 49, 0.2);
  background: var(--red-bg);
  color: var(--red);
}

.danger-button.compact {
  min-height: 32px;
}

.secondary-button:hover,
.nav-button:hover,
.back-button:hover,
.icon-button:hover {
  border-color: var(--line);
  background: var(--field-strong);
}

.danger-button:hover {
  border-color: rgba(224, 49, 49, 0.4);
  background: rgba(224, 49, 49, 0.18);
}

button:disabled,
.primary-button:disabled,
.secondary-button:disabled,
.danger-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.wide {
  width: 100%;
}

.icon-button {
  position: relative;
  width: 38px;
  height: 38px;
  min-width: 38px;
  padding: 0;
}

.icon-button.small {
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
}

.icon-button[data-theme-toggle]::before {
  content: "";
  width: 13px;
  height: 13px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  box-shadow: -4px -2px 0 -1px var(--field-strong);
}

.copy-icon::before,
.copy-icon::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--muted);
  border-radius: 3px;
}

.copy-icon::before {
  top: 11px;
  left: 13px;
}

.copy-icon::after {
  top: 8px;
  left: 10px;
  background: transparent;
}

.copy-icon.is-copied {
  border-color: rgba(166, 255, 0, 0.28);
  background: rgba(166, 255, 0, 0.12);
}

.copy-icon.is-copied::before,
.copy-icon.is-copied::after {
  border-color: var(--green);
}

.icon-button.small.copy-icon::before {
  top: 10px;
  left: 12px;
}

.icon-button.small.copy-icon::after {
  top: 7px;
  left: 9px;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 22px;
}

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

th,
td {
  height: 40px;
  padding: 8px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  color: var(--text);
  font-weight: 500;
}

td {
  color: var(--text);
}

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

.table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.streamer-table {
  table-layout: fixed;
}

.streamer-table th:nth-child(1),
.streamer-table td:nth-child(1) {
  width: 30%;
}

.streamer-table th:nth-child(2),
.streamer-table td:nth-child(2) {
  width: 38%;
}

.streamer-table th:nth-child(3),
.streamer-table td:nth-child(3) {
  width: 32%;
}

.streamer-table td:nth-child(2) .id-pill {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.id-pill,
.role-select {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--field-strong);
  color: var(--text);
  padding: 0 10px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  font-weight: 500;
}

.role-select {
  min-width: 154px;
  justify-content: space-between;
  font-family: inherit;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  background: var(--green);
  color: var(--bg);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 500;
}

.empty-cell {
  height: 92px;
  color: var(--muted);
  text-align: center;
}

.muted-cell {
  color: var(--muted);
}

.management-card {
  overflow: hidden;
}

.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;
}

main.streamer-dashboard {
  width: min(1228px, calc(100% - 36px));
  margin: 0 auto;
  padding: 96px 0 76px;
}

.streamer-heading {
  margin-bottom: 34px;
}

.streamer-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.streamer-title-row h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
}

.streamer-heading p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: var(--field-strong);
  color: var(--text);
  padding: 0 11px;
  font-size: 12px;
  font-weight: 500;
}

.category-tabs {
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  height: 36px;
  min-height: 36px;
  margin-bottom: 16px;
  padding: 3px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--field);
}

.category-tab {
  display: grid;
  place-items: center;
  height: 30px;
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}

.category-tab:hover,
.category-tab.is-active {
  color: var(--text);
}

.category-tab.is-active {
  background: color-mix(in oklab, var(--field) 58%, var(--bg));
}

.dashboard-section {
  display: none;
}

.dashboard-section.is-active {
  display: block;
}

.dashboard-grid {
  display: grid;
  align-items: stretch;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 0.98fr);
  gap: 16px;
}

.setup-grid {
  gap: 16px;
}

.dashboard-grid > .panel {
  height: 100%;
}

.dashboard-grid > .panel + .panel {
  margin-top: 0;
}

.controls-grid {
  grid-template-columns: minmax(0, 1fr);
}

.setup-grid {
  grid-template-columns: minmax(0, 1fr);
}

.active-panel {
  min-height: 360px;
}

.active-panel .danger-button {
  margin-top: 24px;
}

.control-actions,
.section-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.control-actions {
  justify-content: flex-end;
}

.obs-actions {
  align-items: center;
  justify-content: flex-end;
}

.obs-actions .status-line {
  margin: 0;
}

.obs-action-stack {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}

.obs-action-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.section-toolbar {
  margin-bottom: 18px;
}

.section-toolbar h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

.section-toolbar .panel-copy {
  margin-bottom: 0;
}

.setup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.obs-form {
  display: grid;
  grid-template-columns: minmax(220px, 0.82fr) 132px minmax(220px, 1fr);
  align-items: end;
  gap: 14px;
}

.obs-host-field {
  grid-column: 1 / 2;
}

.obs-port-field {
  grid-column: 2 / 3;
}

.obs-password-field {
  grid-column: 3 / 4;
}

.obs-form label,
.obs-selector-grid label {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.obs-selector-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.obs-form .check-row {
  display: flex;
  grid-column: 1 / 2;
  grid-template-columns: none;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  color: var(--muted);
  font-weight: 400;
}

.obs-form .control-actions {
  grid-column: 2 / 4;
  align-self: center;
}

.obs-status[data-state="connected"],
.active-scene-status[data-state="connected"] {
  color: var(--green);
}

.obs-status[data-state="pending"],
.active-scene-status[data-state="pending"] {
  color: var(--text);
}

.obs-status[data-state="error"],
.active-scene-status[data-state="error"] {
  color: var(--red);
}

.effect-group + .effect-group {
  margin-top: 18px;
}

.group-title {
  margin-bottom: 10px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.effect-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 182px);
  gap: 12px;
  justify-content: start;
}

.effect-group-shrink-grow .effect-grid {
  grid-template-columns: repeat(auto-fill, 182px);
}

.effect-button {
  justify-content: flex-start;
  width: 182px;
  height: 64px;
  min-height: 64px;
  border: 0;
  border-radius: 8px;
  background: var(--field);
  color: var(--text);
  padding: 14px 12px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: none;
}

.effect-button::after {
  content: "Play";
  margin-left: auto;
  border-radius: 8px;
  background: var(--green);
  color: var(--bg);
  padding: 7px 9px;
  font-size: 13px;
  font-weight: 500;
}

.effect-button:hover {
  background: var(--field-strong);
  transform: translateY(-1px);
}

.effect-button.is-playing {
  background: var(--field-strong);
}

.effect-button.is-playing::after {
  content: "Stop";
  background: var(--red-bg);
  color: var(--red);
}

.reset-position-button::after {
  content: "Reset";
  background: var(--red-bg);
  color: var(--red);
}

.effect-button:active {
  transform: translateY(1px);
}

.status-line {
  display: block;
  margin: 26px 0 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
}

.active-scene-status {
  margin-top: 24px;
}

.active-scene-status + .controls-status {
  margin-top: 8px;
}

.auth-page {
  display: grid;
  place-items: start center;
  min-height: calc(100vh - 65px);
  padding: 64px 16px 76px;
}

.auth-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 24px;
  box-shadow: var(--shadow);
}

.auth-panel p {
  margin: 10px 0 24px;
}

.login-actions {
  display: grid;
  gap: 12px;
}

@media (max-width: 900px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding-top: 16px;
    padding-bottom: 16px;
  }

  .topbar-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .powered-by {
    width: 100%;
  }

  .page-frame,
  .streamer-dashboard {
    padding-top: 46px;
  }

  .page-title-row,
  .section-toolbar,
  .dashboard-grid {
    align-items: flex-start;
    flex-direction: column;
  }

  .dashboard-grid {
    display: flex;
    width: 100%;
  }

  .dashboard-grid > .panel {
    width: 100%;
  }

  .active-panel {
    min-height: 0;
  }

  .inline-form {
    grid-template-columns: 1fr;
  }

  .obs-selector-grid {
    grid-template-columns: 1fr;
  }

  .obs-form {
    grid-template-columns: 1fr;
  }

  .obs-host-field,
  .obs-port-field,
  .check-row,
  .obs-form .control-actions {
    grid-column: 1 / -1;
  }

  .obs-action-stack {
    align-items: flex-start;
    flex-direction: column;
  }

  .control-actions {
    justify-content: flex-start;
  }

  .effect-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .effect-group-burn .effect-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .effect-group-shrink-grow .effect-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 640px) {
  .topbar,
  .page-frame {
    padding-right: 24px;
    padding-left: 24px;
  }

  .auth-page {
    padding-right: 24px;
    padding-left: 24px;
  }
}

@media (min-width: 768px) {
  .admin-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .topbar,
  .page-frame {
    padding-right: 32px;
    padding-left: 32px;
  }
}

@media (min-width: 1280px) {
  .admin-card-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .admin-card-grid-two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .site-title {
    font-size: 26px;
  }

  .getrekt-logo {
    width: 136px;
  }

  .effect-grid {
    grid-template-columns: 1fr;
  }

  .table-actions {
    align-items: flex-start;
    flex-direction: column;
  }
}
