:root {
  color-scheme: light;
  --bg: #f3f6f8;
  --panel: #ffffff;
  --ink: #132432;
  --muted: #667786;
  --line: #d9e2e8;
  --blue: #045fc4;
  --cyan: #00a5c8;
  --green: #108060;
  --danger: #b42318;
  --navy: #071722;
}

* {
  box-sizing: border-box;
}

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

.hidden {
  display: none !important;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: #eaf0f4;
}

.login-panel {
  display: grid;
  gap: 16px;
  width: min(440px, 100%);
  padding: 30px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(14, 31, 44, 0.14);
}

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

.product-lockup strong {
  display: block;
  font-size: 18px;
}

.nc-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: #fff;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  border-radius: 8px;
  font-size: 14px;
  font-weight: 950;
}

.shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  padding: 22px;
  background: var(--navy);
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  color: #fff;
  text-decoration: none;
}

.brand .nc-mark {
  flex: 0 0 auto;
}

.brand-copy {
  display: grid;
  gap: 2px;
}

.brand-copy small {
  color: rgba(255, 255, 255, 0.58);
  font-size: 12px;
  font-weight: 800;
}

.sidebar nav {
  display: grid;
  align-content: start;
  gap: 8px;
  margin-top: 30px;
}

.nav-item,
.ghost {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  color: rgba(255, 255, 255, 0.72);
  background: transparent;
  font: inherit;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.nav-item.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

.workspace {
  width: min(1320px, 100%);
  padding: 26px;
}

.topbar,
.panel-heading,
.actions,
.clip-actions,
.clip-links {
  display: flex;
  align-items: center;
}

.topbar,
.panel-heading {
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 20px;
}

.context-selectors {
  display: grid;
  grid-template-columns: 220px 260px;
  gap: 12px;
}

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 32px;
}

h2 {
  font-size: 21px;
}

.muted {
  color: var(--muted);
  line-height: 1.5;
}

.view {
  display: none;
}

.active-view {
  display: grid;
  gap: 16px;
}

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

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

.operation-grid {
  grid-template-columns: minmax(360px, 0.78fr) 1fr;
}

.panel {
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(14, 31, 44, 0.07);
}

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

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

input[type="range"] {
  padding: 0;
}

button,
.secondary-link {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  color: #fff;
  background: var(--blue);
  font: inherit;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
}

button.secondary,
.secondary-link {
  display: inline-flex;
  align-items: center;
  color: var(--ink);
  background: #e7edf2;
}

button.small {
  min-height: 34px;
  font-size: 13px;
}

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

.record-toggle {
  min-width: 116px;
  gap: 10px;
  background: var(--danger);
}

.record-toggle.recording {
  background: var(--navy);
}

.record-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
}

.record-toggle.recording .record-dot {
  border-radius: 3px;
}

.source-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 12px;
  margin-top: 16px;
}

.actions {
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.message {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--muted);
  font-weight: 800;
}

.message.error {
  color: var(--danger);
}

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

.badge.live {
  color: #fff;
  background: var(--green);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 18px;
}

.metrics div {
  padding: 14px;
  background: #f5f8fa;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.metrics strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
}

.instagram-mock {
  width: min(390px, 100%);
  margin: 14px auto 0;
  overflow: hidden;
  background: #05070a;
  border: 10px solid #111820;
  border-radius: 34px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.25);
}

.ig-top,
.ig-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 18px;
  color: #fff;
  background: #05070a;
}

.ig-top span {
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.46);
}

.ig-top span:nth-child(1) {
  width: 84px;
}

.ig-top span:nth-child(2) {
  width: 36px;
}

.ig-top span:nth-child(3) {
  width: 64px;
}

.ig-bottom span:first-child {
  display: inline-flex;
  align-items: center;
  width: 210px;
  height: 34px;
  padding: 0 14px;
  color: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.ig-bottom span:last-child {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
}

.preview-frame {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 9 / 16;
  min-height: auto;
  margin-top: 0;
  overflow: hidden;
  background: #07141d;
  touch-action: none;
}

.preview-frame img {
  display: block;
}

#previewImage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #061522;
}

.preview-frame.layout-full #previewImage {
  object-fit: contain;
}

.preview-frame.layout-crop #previewImage {
  object-fit: cover;
}

.mock-overlay-asset {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.format-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 4;
  padding: 5px 8px;
  color: #fff;
  background: rgba(5, 7, 10, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
}

.mock-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: auto;
  touch-action: none;
}

.mock-headline,
.mock-subheadline {
  position: absolute;
  left: 18px;
  right: 18px;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.65);
}

.safe-area {
  position: absolute;
  inset: 44px 22px;
  border: 1px dashed rgba(255, 255, 255, 0.32);
  border-radius: 14px;
  pointer-events: none;
}

.drag-item {
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.drag-item::after {
  position: absolute;
  right: -9px;
  bottom: -9px;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.78);
  border-radius: 50%;
  background: var(--cyan);
  content: "";
  opacity: 0;
}

.drag-item:hover,
.drag-item.dragging {
  outline: 1px solid rgba(255, 255, 255, 0.78);
  outline-offset: 5px;
}

.drag-item:hover::after,
.drag-item.dragging::after {
  opacity: 1;
}

.drag-item.dragging {
  cursor: grabbing;
}

.mock-headline {
  top: 28px;
  font-size: 20px;
  font-weight: 900;
}

.mock-subheadline {
  bottom: 28px;
  font-size: 14px;
  line-height: 1.25;
}

.text-top .mock-subheadline {
  top: 60px;
  bottom: auto;
}

.text-bottom .mock-headline {
  top: auto;
  bottom: 68px;
}

.text-bottom .mock-subheadline {
  bottom: 28px;
}

.text-center .mock-headline {
  top: 44%;
}

.text-center .mock-subheadline {
  top: calc(44% + 34px);
  bottom: auto;
}

.mock-logo {
  position: absolute;
  display: grid;
  place-items: center;
  width: 60px;
  aspect-ratio: 2.3 / 1;
  color: #fff;
  background-color: rgba(0, 166, 200, 0.82);
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 900;
}

.logo-top-left { left: 18px; top: 18px; }
.logo-top-right { right: 18px; top: 18px; }
.logo-middle-left { left: 18px; top: 50%; transform: translateY(-50%); }
.logo-center { left: 50%; top: 50%; transform: translate(-50%, -50%); }
.logo-middle-right { right: 18px; top: 50%; transform: translateY(-50%); }
.logo-bottom-left { left: 18px; bottom: 18px; }
.logo-bottom-right { right: 18px; bottom: 18px; }

.clip-composer {
  display: grid;
  align-content: start;
  gap: 14px;
}

.asset-pills {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.visual-control {
  display: grid;
  gap: 8px;
}

.visual-control > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.segmented button,
.position-grid button {
  min-height: 34px;
  color: var(--ink);
  background: #e7edf2;
}

.segmented button.active,
.position-grid button.active {
  color: #fff;
  background: var(--blue);
}

.logo-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.position-grid {
  display: grid;
  grid-template-columns: repeat(3, 34px);
  grid-template-rows: repeat(3, 34px);
  gap: 6px;
}

.position-grid button::before {
  content: "";
  display: block;
  width: 10px;
  height: 10px;
  margin: auto;
  border-radius: 2px;
  background: currentColor;
}

.position-grid button[data-value="top-left"] { grid-column: 1; grid-row: 1; }
.position-grid button[data-value="top-right"] { grid-column: 3; grid-row: 1; }
.position-grid button[data-value="middle-left"] { grid-column: 1; grid-row: 2; }
.position-grid button[data-value="center"] { grid-column: 2; grid-row: 2; }
.position-grid button[data-value="middle-right"] { grid-column: 3; grid-row: 2; }
.position-grid button[data-value="bottom-left"] { grid-column: 1; grid-row: 3; }
.position-grid button[data-value="bottom-right"] { grid-column: 3; grid-row: 3; }

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

.compact-actions {
  margin-top: 0;
}

.asset-pills span {
  padding: 10px;
  color: var(--muted);
  background: #f5f8fa;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
}

.asset-pills strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
}

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

.clips-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

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

.clip-card video {
  width: 100%;
  aspect-ratio: 9 / 16;
  background: #07141d;
}

.clip-meta {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.clip-meta strong,
.clip-meta span {
  overflow-wrap: anywhere;
}

.clip-meta span {
  color: var(--muted);
  font-size: 13px;
}

.clip-links {
  justify-content: space-between;
  gap: 8px;
}

.clip-links a {
  color: var(--green);
  font-weight: 900;
  text-decoration: none;
}

.list,
.upload-form,
.integration-card {
  display: grid;
  gap: 12px;
}

.master-overview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.master-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 10px;
  min-width: min(520px, 100%);
}

.master-stats div {
  padding: 12px;
  background: #f5f8fa;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.master-stats span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.master-stats strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
}

.ai-control {
  align-content: start;
  display: grid;
  gap: 14px;
}

.transcript-box {
  min-height: 180px;
  max-height: 320px;
  overflow: auto;
  padding: 14px;
  color: var(--ink);
  background: #f5f8fa;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.suggestions-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.suggestion-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.suggestion-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.suggestion-card strong {
  line-height: 1.25;
}

.suggestion-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.suggestion-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.suggestion-meta span {
  padding: 6px 8px;
  color: var(--muted);
  background: #f0f4f7;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

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

.asset-selectors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

button.danger {
  color: #fff;
  background: var(--danger);
}

.list {
  margin-top: 14px;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px;
  background: #f7fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.list-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.credential-item strong,
.credential-item span {
  overflow-wrap: anywhere;
}

.credential-item {
  align-items: end;
}

.credential-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.user-edit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 10px;
  width: 100%;
}

.user-edit-grid label {
  min-width: 0;
}

.integration-card {
  max-width: 760px;
}

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

  .sidebar {
    position: static;
    min-height: auto;
  }

  .sidebar nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .context-selectors,
  .two-columns,
  .operation-grid,
  .source-grid,
  .metrics,
  .master-stats,
  .user-edit-grid {
    grid-template-columns: 1fr;
  }

  .master-overview {
    align-items: stretch;
    flex-direction: column;
  }
}
