:root {
  color-scheme: light;
  --ink: #151615;
  --muted: #626860;
  --line: #d9ded6;
  --panel: #ffffff;
  --page: #f4f6f1;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --soft: #e7f1ee;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
}

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

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

.hidden {
  display: none !important;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 14px 32px rgba(39, 47, 36, 0.08);
}

.auth-panel {
  max-width: 520px;
  margin: 12vh auto 0;
}

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

h1 {
  font-size: clamp(28px, 5vw, 48px);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  font-size: 20px;
  margin-bottom: 16px;
}

h3 {
  font-size: 18px;
}

h4 {
  font-size: 16px;
}

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

.auth-panel p,
.topbar p {
  margin-top: 8px;
}

.stack {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

label {
  display: grid;
  gap: 7px;
  color: #30362f;
  font-weight: 700;
}

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

textarea {
  resize: vertical;
}

button,
.actions a {
  border: 0;
  border-radius: 6px;
  padding: 11px 14px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

button.secondary {
  color: var(--ink);
  background: #e9eee5;
}

button:hover,
.actions a:hover {
  background: var(--accent-dark);
}

button.secondary:hover {
  background: #dbe3d7;
}

button:disabled {
  cursor: progress;
  opacity: 0.7;
}

.workspace {
  display: grid;
  gap: 20px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
}

.topbar button {
  background: #24342f;
}

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

.storage-meter {
  display: grid;
  grid-template-columns: repeat(2, minmax(96px, 1fr));
  gap: 8px;
}

.storage-meter > div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fbfcfa;
}

.storage-meter span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.storage-meter strong {
  display: block;
  margin-top: 2px;
  font-size: 15px;
  line-height: 1.2;
  white-space: nowrap;
}

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

.library,
.videos {
  display: grid;
  gap: 14px;
}

.topic-group {
  display: grid;
  gap: 10px;
}

.topic-group > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.topic-group > header h4 {
  font-size: 15px;
  color: #26342f;
}

.topic-group > header span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.topic-videos {
  display: grid;
  gap: 10px;
}

.course {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.course:first-child {
  border-top: 0;
  padding-top: 0;
}

.course > header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.course-actions {
  display: flex;
  align-items: start;
  gap: 8px;
}

.course-actions span {
  height: 28px;
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--soft);
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.course-actions button {
  padding: 6px 10px;
  font-size: 13px;
}

.video-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.origins {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  color: var(--muted);
}

.video-meta {
  margin-top: 4px;
  font-size: 13px;
}

code {
  border-radius: 5px;
  padding: 3px 7px;
  background: #ecf0e8;
}

.actions {
  display: flex;
  align-items: start;
  gap: 8px;
}

.actions button,
.actions a {
  padding: 8px 10px;
  font-size: 13px;
  white-space: nowrap;
}

.video-card textarea {
  grid-column: 1 / -1;
  min-height: 78px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  background: #f1f4ee;
}

.edit-form {
  display: grid;
  grid-column: 1 / -1;
  gap: 12px;
  margin: 6px 0 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.edit-actions button {
  padding: 9px 12px;
}

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

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  border-radius: 8px;
  padding: 12px 14px;
  color: #fff;
  background: #24342f;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}

@media (max-width: 760px) {
  .app {
    width: min(100% - 20px, 1180px);
    padding: 18px 0;
  }

  .grid,
  .video-card {
    grid-template-columns: 1fr;
  }

  .topbar,
  .course > header,
  .course-actions,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

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

  .topbar button,
  .actions button,
  .actions a {
    width: 100%;
    text-align: center;
  }
}
