:root {
  --ink: #174950;
  --muted: rgba(23, 73, 80, 0.68);
  --paper: #ECEFD0;
  --panel: #fffdf4;
  --line: rgba(23, 73, 80, 0.18);
  --rose: #F2552C;
  --rose-dark: #c23f20;
  --sage: #174950;
  --gold: #F2552C;
  --shadow: 0 24px 70px rgba(23, 73, 80, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body:has(.login-shell) {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 64px;
}

body:has(.login-shell) main {
  width: 100%;
  min-height: 100vh;
  padding: 0;
}

.login-shell {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 16px;
  background:
    linear-gradient(rgba(236, 239, 208, 0.18), rgba(236, 239, 208, 0.34)),
    var(--asset-login-background, url("assets/background.png")) center / cover no-repeat;
}

.login-panel {
  width: min(430px, calc(100vw - 32px));
  background: color-mix(in srgb, var(--paper) 92%, #ffffff 8%);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 36px;
}

.login-logo {
  display: block;
  width: min(260px, 80%);
  margin: 0 auto 30px;
}

.login-language {
  display: flex;
  justify-content: flex-end;
  margin: -18px -18px 18px 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(16px, 5vw, 48px);
  background: var(--topbar-background, var(--panel));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand img {
  width: 156px;
  display: block;
}

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

.topbar a,
.link-button {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.topbar a.active {
  color: var(--rose-dark);
}

.link-button {
  border: 0;
  background: none;
  cursor: pointer;
}

.menu-wrap {
  position: relative;
}

.menu-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(35, 31, 32, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 22px rgba(57, 40, 30, 0.08);
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.menu-button:hover,
.menu-wrap.open .menu-button {
  background: #fff;
  box-shadow: 0 12px 28px rgba(57, 40, 30, 0.14);
  transform: translateY(-1px);
}

.menu-button img {
  width: 22px;
  height: 22px;
  display: block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: min(320px, calc(100vw - 28px));
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), color-mix(in srgb, var(--paper) 96%, #ffffff 4%)),
    var(--paper);
  box-shadow: 0 24px 64px rgba(57, 40, 30, 0.18);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.98);
  transform-origin: top right;
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
}

.menu-wrap.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.dropdown-menu::before {
  content: "";
  position: absolute;
  top: -6px;
  right: 18px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-left: 1px solid var(--line);
  border-top: 1px solid var(--line);
  transform: rotate(45deg);
}

.menu-section {
  display: grid;
  gap: 4px;
  padding: 8px;
}

.menu-section + .menu-section {
  border-top: 1px solid var(--line);
}

.menu-section span {
  padding: 4px 8px 6px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.dropdown-menu a,
.dropdown-logout {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  text-align: left;
}

.dropdown-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.dropdown-menu a:hover,
.dropdown-menu a.active,
.dropdown-logout:hover {
  background: #efe3d4;
  color: var(--rose-dark);
}

.dropdown-menu form {
  margin: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.language-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px;
  width: 86px;
  padding: 3px;
  border: 1px solid rgba(35, 31, 32, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: inset 0 1px 2px rgba(57, 40, 30, 0.08);
}

.language-switch button {
  min-height: 28px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

.language-switch button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(57, 40, 30, 0.16);
}

.stack {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 13px;
  background: #fffdf9;
  color: var(--ink);
}

textarea {
  min-height: 110px;
  resize: vertical;
}

.primary-button,
.secondary-button,
.tiny-button,
.danger-button,
.success-button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
}

.primary-button {
  padding: 13px 18px;
  background: var(--rose);
  color: white;
}

.loading-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.loading-button.is-loading {
  cursor: wait;
  opacity: 0.88;
}

.loading-button.is-loading::before {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.46);
  border-top-color: #fff;
  border-radius: 50%;
  animation: button-spin 700ms linear infinite;
}

@keyframes button-spin {
  to {
    transform: rotate(360deg);
  }
}

.secondary-button {
  padding: 12px 18px;
  background: #efe3d4;
  color: var(--ink);
}

.tiny-button {
  padding: 7px 10px;
  background: var(--sage);
  color: #fff;
  font-size: 12px;
}

.danger-button {
  min-height: 42px;
  padding: 0 14px;
  background: #8f2f37;
  color: #fff;
}

.success-button {
  min-height: 42px;
  padding: 0 14px;
  background: #557052;
  color: #fff;
}

.icon-button-text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.icon-button-text img {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.video-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.video-actions .icon-button-text {
  min-width: 150px;
}

.wide {
  width: 100%;
  margin-top: 10px;
}

.code-login-form {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.code-input {
  text-align: center;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 8px;
}

.notice {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 6px;
  background: #edf3e9;
  color: #384c35;
  font-weight: 700;
}

.notice.error {
  background: #f6e3e1;
  color: #7b2d31;
}

.page-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 22px;
}

.page-title h1,
.empty-state h1,
.episode-copy h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 52px);
  line-height: 1.04;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 22px;
}

.video-card,
.settings-panel,
.table-panel,
.empty-state,
.metric-grid > div,
.admin-video {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(57, 40, 30, 0.06);
}

.video-card {
  overflow: hidden;
}

.video-card-media img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}

.video-card div {
  padding: 16px;
}

.video-card-category,
.eyebrow {
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.video-card h2 {
  margin: 7px 0 8px;
  font-size: 20px;
}

.video-card p,
.episode-copy p,
.rich-description,
.empty-state p,
.help-text,
.settings-panel p {
  color: var(--muted);
  line-height: 1.55;
}

.card-description {
  margin: 0;
  color: #000;
  font-size: 15px;
  font-weight: 400;
  font-style: normal;
  line-height: 1.55;
  text-transform: none;
  letter-spacing: 0;
}

.card-description span {
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  text-transform: none;
  letter-spacing: 0;
}

.text-link,
.rich-description a,
.card-description a {
  color: var(--brand-orange);
  font-weight: 700;
  overflow-wrap: anywhere;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.social-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 2px;
  color: var(--brand-teal);
  font-weight: 800;
  text-decoration: none;
  vertical-align: -3px;
}

.social-link img {
  width: 16px;
  height: 16px;
  display: block;
}

.social-link span {
  color: inherit;
}

.rich-description {
  white-space: normal;
}

.card-description.is-collapsed .description-full {
  display: none;
}

.card-description.is-expanded .description-short {
  display: none;
}

.card-description.is-short .description-short {
  display: inline;
}

.description-more {
  border: 0;
  background: transparent;
  color: var(--rose-dark);
  cursor: pointer;
  font-weight: 900;
  padding: 0 2px;
}

.episode {
  display: grid;
  gap: 26px;
}

.episode-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.episode-heading h1 {
  margin: 0;
}

.like-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 0 15px;
  border: 1px solid color-mix(in srgb, var(--brand-teal) 18%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand-cream) 70%, #ffffff 30%);
  color: var(--brand-teal);
  cursor: pointer;
  font-weight: 850;
  line-height: 1;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.like-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(23, 73, 80, 0.14);
}

.like-button.is-liked {
  border-color: color-mix(in srgb, var(--brand-orange) 34%, transparent);
  background: color-mix(in srgb, var(--brand-orange) 12%, #ffffff 88%);
  color: var(--brand-orange);
}

.like-button.is-loading {
  opacity: 0.72;
  cursor: wait;
}

.like-button.has-error {
  animation: modal-shake 260ms ease;
}

@keyframes modal-shake {
  25% {
    transform: translateX(-3px);
  }

  50% {
    transform: translateX(3px);
  }

  75% {
    transform: translateX(-2px);
  }
}

.like-button-icon {
  width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
}

.like-button-icon img {
  width: 19px;
  height: 19px;
  display: block;
}

.like-button-label {
  font-size: 14px;
}

.like-button-count {
  min-width: 24px;
  padding-left: 8px;
  border-left: 1px solid currentColor;
  font-size: 14px;
  text-align: center;
}

@media (max-width: 640px) {
  .episode-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}

.video-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #111;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.video-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.watermark {
  position: absolute;
  right: 14px;
  bottom: 12px;
  padding: 6px 9px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.46);
  color: rgba(255, 255, 255, 0.76);
  font-size: 12px;
  pointer-events: none;
}

.back-link {
  display: inline-block;
  margin-bottom: 18px;
  color: var(--rose-dark);
  font-weight: 800;
}

.empty-state,
.settings-panel,
.table-panel {
  padding: 24px;
}

.empty-state {
  max-width: 620px;
  margin: 70px auto;
  text-align: center;
}

.empty-state form {
  display: inline-block;
  margin: 8px;
}

.details {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 14px 22px;
  margin: 28px 0 24px;
}

.details dt {
  color: var(--muted);
  font-weight: 800;
}

.details dd {
  margin: 0;
}

.account-profile {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.avatar-upload {
  min-height: 220px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 18px;
  border: 2px dashed color-mix(in srgb, var(--brand-teal) 42%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--paper) 72%, #ffffff 28%);
  color: var(--ink);
  cursor: pointer;
  text-align: center;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.avatar-upload:hover,
.avatar-upload:focus-within,
.avatar-upload.is-dragging,
.avatar-upload.is-uploading {
  border-color: var(--brand-orange);
  background: color-mix(in srgb, var(--brand-cream) 62%, #ffffff 38%);
  transform: translateY(-1px);
}

.avatar-upload.is-uploading {
  cursor: wait;
  opacity: 0.82;
}

.avatar-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.avatar-circle {
  width: 118px;
  height: 118px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--brand-teal);
  color: #fff;
  box-shadow: 0 12px 28px rgba(23, 73, 80, 0.18);
  font-size: 42px;
  font-weight: 900;
}

.avatar-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-upload strong {
  font-size: 14px;
}

.avatar-upload small {
  max-width: 180px;
  color: var(--muted);
  line-height: 1.4;
}

.danger-zone {
  margin-top: 22px;
  border-color: color-mix(in srgb, var(--brand-orange) 36%, var(--line));
}

.community-panel {
  margin-bottom: 22px;
}

.community-panel h2 {
  margin-top: 0;
}

.table-scroll {
  overflow-x: auto;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-root[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 73, 80, 0.34);
  opacity: 0;
  transition: opacity 180ms ease;
}

.modal-dialog {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 28px 80px rgba(23, 73, 80, 0.24);
  opacity: 0;
  transform: translateY(10px) scale(0.98);
  transition: opacity 180ms ease, transform 180ms ease;
}

.modal-root.open .modal-backdrop,
.modal-root.open .modal-dialog {
  opacity: 1;
}

.modal-root.open .modal-dialog {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 22px 10px;
}

.modal-header h2 {
  margin: 0;
  font-size: 22px;
}

.modal-x {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--brand-pink) 44%, #ffffff 56%);
  color: var(--ink);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.modal-body {
  margin: 0;
  padding: 0 22px 20px;
  color: var(--muted);
  line-height: 1.55;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px 22px;
  border-top: 1px solid var(--line);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: #efe3d4;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.pill-active,
.pill-trialing {
  background: #e1edda;
  color: #355131;
}

.pill-canceled,
.pill-unpaid,
.pill-none {
  background: #f3dedb;
  color: #7b2d31;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 22px;
}

.metric-grid > div {
  padding: 22px;
}

.metric-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 38px;
}

.admin-actions,
.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.admin-actions a {
  padding: 12px 15px;
  border-radius: 6px;
  background: var(--sage);
  color: #fff;
  font-weight: 800;
}

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

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.video-list {
  display: grid;
  gap: 18px;
  margin-top: 22px;
}

.admin-video {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 18px;
  padding: 18px;
}

.admin-video-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
}

.admin-video-body {
  display: grid;
  gap: 12px;
}

@media (max-width: 760px) {
  main {
    width: min(100% - 22px, 1180px);
  }

  .topbar {
    height: auto;
    padding: 14px;
    align-items: flex-start;
    gap: 14px;
  }

  .topnav {
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .brand img {
    width: 120px;
  }

  .metric-grid,
  .admin-video,
  .account-profile {
    grid-template-columns: 1fr;
  }

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

  .login-panel {
    padding: 26px;
  }
}
