:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #687386;
  --line: #dce2ea;
  --brand: #1267d8;
  --brand-dark: #0b4fa8;
  --ok: #13795b;
  --warn: #9a4b00;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(30, 42, 62, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(245, 247, 251, 0.92)),
    radial-gradient(circle at 20% 0%, rgba(18, 103, 216, 0.12), transparent 34%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

a {
  color: var(--brand);
  text-decoration: none;
}

h1,
h2,
h3,
p {
  margin: 0;
}

input,
select,
button {
  font: inherit;
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-panel,
.upload-panel,
.edit-panel,
.error-panel {
  width: min(100%, 520px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-panel {
  display: grid;
  gap: 22px;
}

.app-shell {
  width: min(1540px, calc(100% - 16px));
  margin: 0 auto;
  padding: 24px 0 44px;
}

.app-shell.narrow {
  width: min(820px, calc(100% - 36px));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

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

.topbar h1,
.auth-panel h1,
.error-panel h1 {
  margin-top: 4px;
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1.05;
}

.eyebrow {
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.stack,
.edit-panel {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: #31405a;
  font-size: 14px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

input:focus,
select:focus {
  border-color: var(--brand);
  outline: 3px solid rgba(18, 103, 216, 0.16);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  white-space: nowrap;
}

.button.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.button.primary:hover {
  background: var(--brand-dark);
}

.button.ghost {
  background: transparent;
}

.language-switcher {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.lang-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  min-height: 32px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.lang-link.active {
  background: var(--brand);
  color: #fff;
}

.danger-button {
  border-color: rgba(180, 35, 24, 0.25);
  color: var(--danger);
}

.upload-panel {
  width: 100%;
  margin-bottom: 22px;
}

.upload-form {
  display: grid;
  grid-template-columns: 1fr minmax(260px, 380px) auto;
  align-items: center;
  gap: 18px;
}

.drop-zone {
  display: grid;
  min-height: 86px;
  align-content: center;
  gap: 5px;
  padding: 16px;
  border: 1px dashed #9aabc1;
  border-radius: 8px;
  background: #f8fafc;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.drop-zone:hover,
.drop-zone.dragging {
  border-color: var(--brand);
  background: rgba(18, 103, 216, 0.06);
}

.drop-zone.has-file {
  border-style: solid;
  border-color: rgba(19, 121, 91, 0.35);
  background: rgba(19, 121, 91, 0.06);
}

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

.drop-title {
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}

.drop-name {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lessons-list {
  display: grid;
  gap: 12px;
}

.lesson-row {
  display: grid;
  grid-template-columns: minmax(720px, 1.7fr) minmax(190px, 260px) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
}

.lesson-main {
  min-width: 0;
}

.lesson-main h3 {
  margin-top: 8px;
  font-size: 20px;
}

.path,
.public-link {
  display: block;
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-url {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.share-url .public-link {
  overflow: hidden;
  color: var(--brand);
  font-weight: 700;
  text-overflow: clip;
  white-space: nowrap;
}

.copy-button {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 12px;
}

.copy-button.copied {
  border-color: rgba(19, 121, 91, 0.25);
  color: var(--ok);
}

.lesson-meta {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.actions,
.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.actions {
  flex-wrap: nowrap;
  align-items: flex-end;
}

.availability-form {
  display: flex;
  align-items: end;
  gap: 8px;
}

.availability-form label {
  display: grid;
  gap: 4px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.availability-form input {
  width: 184px;
  padding: 9px 10px;
  font-size: 13px;
}

.status,
.type-badge,
.badges span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2f7;
  color: #41506a;
  font-size: 12px;
  font-weight: 800;
}

.status.published {
  background: rgba(19, 121, 91, 0.12);
  color: var(--ok);
}

.status.hidden {
  background: rgba(154, 75, 0, 0.12);
  color: var(--warn);
}

.status.expired {
  background: rgba(180, 35, 24, 0.12);
  color: var(--danger);
}

.type-badge {
  margin-left: 6px;
  background: rgba(18, 103, 216, 0.1);
  color: var(--brand);
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.notice,
.alert,
.empty {
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.notice {
  margin-bottom: 18px;
  border-color: rgba(19, 121, 91, 0.25);
  color: var(--ok);
}

.alert {
  border-color: rgba(180, 35, 24, 0.25);
  color: var(--danger);
}

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

.expired-access-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 32px;
}

.expired-access-panel {
  width: min(100%, 920px);
  padding: 54px 64px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  box-shadow: var(--shadow);
}

.expired-access-panel h1 {
  margin-top: 10px;
  font-size: clamp(40px, 4.4vw, 64px);
  line-height: 1;
  letter-spacing: -0.045em;
  white-space: nowrap;
}

.expired-access-message {
  max-width: 680px;
  margin-top: 20px;
  color: var(--muted);
  font-size: 17px;
}

.expired-access-card,
.expired-access-meta {
  display: grid;
  gap: 6px;
  margin-top: 24px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.expired-access-meta {
  margin-top: 12px;
}

.expired-access-card span,
.expired-access-meta span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.expired-access-card strong,
.expired-access-meta strong {
  font-size: 18px;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.details-grid div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.details-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.details-grid strong,
.details-grid a {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.danger {
  margin-top: 16px;
}

@media (max-width: 760px) {
  .expired-access-panel {
    padding: 34px 24px;
  }

  .expired-access-panel h1 {
    white-space: normal;
  }
}

@media (max-width: 820px) {
  .topbar,
  .upload-form,
  .lesson-row {
    grid-template-columns: 1fr;
  }

  .topbar,
  .actions,
  .availability-form,
  .form-actions,
  .topbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .availability-form input {
    width: 100%;
  }

  .share-url {
    grid-template-columns: 1fr;
  }

  .lesson-row {
    align-items: stretch;
  }

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