:root {
  --bg: #f5faf8;
  --panel: #ffffff;
  --panel-soft: #f6faf9;
  --panel-tint: #edf6f2;
  --text: #14211f;
  --muted: #64736f;
  --line: #d7e2de;
  --line-strong: #b8cac4;
  --focus: #28776f;
  --focus-dark: #1f5e58;
  --blue-focus: #4d6fa8;
  --shadow: 0 18px 44px rgba(20, 33, 31, 0.1);
  --shadow-soft: 0 8px 24px rgba(20, 33, 31, 0.055);
  --neutral: #7b8480;
  --red: #c45b65;
  --orange: #ca7451;
  --yellow: #d0a83f;
  --green: #5b9565;
  --teal: #2d8a80;
  --blue: #4d78b8;
  --purple: #7d6bb2;
  --pink: #bd6b91;
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea {
  font: inherit;
}

button,
.link-button {
  align-items: center;
  border: 1px solid var(--focus);
  border-radius: 7px;
  background: var(--focus);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  min-height: 38px;
  padding: 0 13px;
  text-decoration: none;
  white-space: nowrap;
}

button:hover,
.link-button:hover {
  background: var(--focus-dark);
}

button svg,
.link-button svg {
  fill: none;
  height: 20px;
  pointer-events: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 20px;
}

.icon-action {
  border-radius: 10px;
  min-height: 42px;
  min-width: 42px;
  padding: 0;
}

.icon-action.primary {
  background: var(--focus);
  color: #fff;
}

.icon-action.danger {
  background: #fff;
}

.wide-action {
  width: 100%;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button.secondary,
button.icon-btn,
.link-button.secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}

button.secondary:hover,
button.icon-btn:hover,
.link-button.secondary:hover {
  border-color: var(--line-strong);
  background: var(--panel-soft);
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input {
  min-height: 40px;
  padding: 0 12px;
}

textarea {
  min-height: 220px;
  resize: vertical;
  padding: 13px;
  line-height: 1.55;
}

input:focus,
textarea:focus,
button:focus-visible {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(40, 119, 111, 0.16);
}

.app-shell {
  display: grid;
  grid-template-columns: 304px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
  padding: 24px;
  overflow-y: auto;
}

.brand-row h1,
.topbar h2,
.panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.brand-row h1 {
  font-size: 22px;
}

.brand-row p {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.quick-create {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin: 22px 0 18px;
}

.album-list,
.unit-tree,
.frame-strip {
  display: grid;
  gap: 8px;
}

.album-item,
.unit-item,
.frame-pill {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.album-item {
  display: grid;
  grid-template-columns: 8px 1fr;
  overflow: hidden;
  text-align: left;
  color: var(--text);
  padding: 0;
}

.album-item.active {
  border-color: var(--focus);
  box-shadow: 0 0 0 2px rgba(40, 119, 111, 0.12);
}

.album-color {
  background: var(--teal);
}

.album-body {
  padding: 12px;
}

.album-title {
  display: block;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.album-meta {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-top: 3px;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar,
.player,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar {
  margin-bottom: 18px;
}

.topbar h2 {
  font-size: 28px;
}

.top-actions,
.player-actions,
.inline-actions,
.frame-nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.compact-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.player {
  border: 1px solid #bfd4d0;
  border-radius: 8px;
  background: #f4fbfa;
  box-shadow: var(--shadow-soft);
  margin-bottom: 16px;
  padding: 12px 14px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(260px, 30%) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-soft);
  min-width: 0;
  overflow: hidden;
}

.panel-head {
  border-bottom: 1px solid var(--line);
  padding: 14px;
}

.curriculum-panel,
.frames-panel {
  min-height: 520px;
}

.unit-tree {
  padding: 8px;
}

.unit-item {
  background: transparent;
  border: 0;
  border-left: 3px solid var(--blue);
  border-radius: 0;
  padding: 5px 0 5px 10px;
}

.unit-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.unit-main > .secondary {
  background: transparent;
  border: 0;
  border-radius: 8px;
  display: grid;
  gap: 2px;
  justify-content: flex-start;
  min-height: 46px;
  padding: 6px 9px;
  text-align: left;
  width: 100%;
}

.unit-main > .secondary:hover {
  background: var(--panel-soft);
}

.unit-item.active {
  border-left-color: var(--focus);
  box-shadow: none;
}

.unit-item.active .unit-main > .secondary {
  background: var(--panel-tint);
}

.unit-title {
  display: block;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.unit-meta {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-top: 3px;
}

.frame-strip {
  grid-auto-flow: column;
  grid-auto-columns: minmax(150px, 190px);
  overflow-x: auto;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 250, 249, 0.76);
}

.frame-pill {
  border-left: 6px solid var(--teal);
  color: var(--text);
  display: grid;
  gap: 3px;
  min-height: 68px;
  padding: 10px;
  text-align: left;
}

.frame-pill.active {
  background: var(--panel-tint);
  border-color: var(--focus);
  border-left-color: var(--focus);
}

.frame-pill strong {
  display: block;
  overflow-wrap: anywhere;
}

.frame-pill span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 5px;
}

.editor {
  padding: 0;
}

.empty-state {
  align-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  display: flex;
  justify-content: center;
  min-height: 160px;
  padding: 22px;
  text-align: center;
}

.empty-state.compact {
  min-height: 76px;
  padding: 14px;
}

.focus-editor {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.frame-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.frame-title-block {
  min-width: 0;
}

.frame-title-input {
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  font-size: 24px;
  font-weight: 750;
  min-height: 44px;
  padding: 0;
}

.frame-title-input:focus {
  box-shadow: none;
  border-bottom-color: var(--focus);
}

.nav-button {
  min-width: 74px;
}

.focus-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
  align-items: stretch;
}

.stage-media {
  align-items: center;
  background: #091513;
  border: 1px solid #0f1d1a;
  border-radius: 8px;
  cursor: copy;
  display: flex;
  justify-content: center;
  min-height: 420px;
  overflow: hidden;
  position: relative;
}

.stage-media:hover,
.stage-media:focus {
  border-color: #67b8ad;
  box-shadow: 0 0 0 3px rgba(103, 184, 173, 0.16);
}

.stage-image {
  display: block;
  height: auto;
  max-height: min(68vh, 760px);
  max-width: 100%;
  object-fit: contain;
  width: auto;
}

.stage-empty {
  color: #c7d8d3;
  padding: 24px;
  text-align: center;
}

.stage-side {
  background: rgba(246, 250, 249, 0.82);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 16px;
  align-content: start;
  padding: 14px;
}

.field-stack {
  display: grid;
  gap: 10px;
}

.field-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.thumbnail-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 132px;
  gap: 10px;
  overflow-x: auto;
}

.image-thumb {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.image-thumb.active {
  border-color: var(--focus);
  box-shadow: 0 0 0 2px rgba(40, 119, 111, 0.14);
}

.image-thumb button:first-child {
  background: #fff;
  border: 0;
  border-radius: 0;
  display: block;
  height: 86px;
  min-height: 86px;
  padding: 0;
  width: 100%;
}

.image-thumb img {
  display: block;
  height: 86px;
  object-fit: cover;
  width: 100%;
}

.thumb-delete {
  background: #fff;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  color: #b34848;
  min-height: 30px;
  width: 100%;
}

.thumb-delete svg {
  height: 16px;
  width: 16px;
}

.thumb-delete:hover {
  background: #fff2f2;
}

.thumb-upload {
  background: var(--panel-soft);
  border: 1px dashed var(--line-strong);
  color: var(--text);
  min-height: 118px;
}

.thumb-upload:hover {
  background: var(--panel-tint);
}

.note-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.asset-grid {
  display: grid;
  gap: 10px;
}

.image-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

.image-asset {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.image-asset img {
  aspect-ratio: 16 / 10;
  display: block;
  object-fit: contain;
  width: 100%;
  background: #eef3f1;
}

.asset-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px;
}

.asset-footer span {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audio-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 8px;
  background: #fff;
}

.audio-row audio {
  width: 100%;
}

.markdown-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  min-height: 180px;
  padding: 14px;
  line-height: 1.6;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3 {
  margin: 0.4em 0;
}

.markdown-preview p {
  margin: 0 0 0.8em;
}

.markdown-preview code {
  background: #e9f0ee;
  border-radius: 4px;
  padding: 1px 4px;
}

.color-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.swatch {
  border: 2px solid transparent;
  border-radius: 999px;
  height: 26px;
  min-height: 26px;
  padding: 0;
  width: 26px;
}

.swatch.active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(20, 33, 31, 0.18);
}

.color-neutral {
  border-left-color: var(--neutral);
}

.color-red {
  border-left-color: var(--red);
}

.color-orange {
  border-left-color: var(--orange);
}

.color-yellow {
  border-left-color: var(--yellow);
}

.color-green {
  border-left-color: var(--green);
}

.color-teal {
  border-left-color: var(--teal);
}

.color-blue {
  border-left-color: var(--blue);
}

.color-purple {
  border-left-color: var(--purple);
}

.color-pink {
  border-left-color: var(--pink);
}

[data-bg="neutral"] {
  background: var(--neutral);
}

[data-bg="red"] {
  background: var(--red);
}

[data-bg="orange"] {
  background: var(--orange);
}

[data-bg="yellow"] {
  background: var(--yellow);
}

[data-bg="green"] {
  background: var(--green);
}

[data-bg="teal"] {
  background: var(--teal);
}

[data-bg="blue"] {
  background: var(--blue);
}

[data-bg="purple"] {
  background: var(--purple);
}

[data-bg="pink"] {
  background: var(--pink);
}

.hidden-input {
  display: none;
}

.danger {
  border-color: #c45b65;
  color: #b34848;
}

.danger:hover {
  background: #fff2f2;
}

@media (max-width: 1180px) {
  .content-grid,
  .focus-stage,
  .note-grid {
    grid-template-columns: 1fr;
  }

  .stage-media {
    min-height: 360px;
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 16px;
  }

  .frame-toolbar {
    grid-template-columns: 1fr;
  }

  .album-list {
    grid-auto-columns: minmax(190px, 72vw);
    grid-auto-flow: column;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .brand-row p {
    display: none;
  }
}

@media (max-width: 640px) {
  .workspace,
  .sidebar {
    padding: 12px;
  }

  .quick-create {
    margin: 14px 0 12px;
  }

  .workspace {
    padding-bottom: 88px;
  }

  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .inline-actions,
  .frame-nav-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .top-actions button,
  .top-actions .link-button,
  .inline-actions button,
  .frame-nav-actions button {
    width: 100%;
  }

  .topbar h2 {
    font-size: 22px;
  }

  .frame-title-input {
    font-size: 20px;
  }

  .stage-media {
    min-height: 260px;
  }

  .stage-side {
    padding: 12px;
  }

  .thumbnail-strip {
    grid-auto-columns: 92px;
  }

  .thumb-upload {
    min-height: 92px;
  }

  .image-thumb button:first-child,
  .image-thumb img {
    height: 68px;
    min-height: 68px;
  }

  textarea,
  .markdown-preview {
    min-height: 170px;
  }
}
