:root {
  color-scheme: dark;
  --bg: #10110f;
  --panel: #181b16;
  --ink: #f2f0e8;
  --muted: #a8afa0;
  --line: rgba(242, 240, 232, 0.16);
  --green: #8bd45e;
  --amber: #e1b04a;
  --coral: #ed7b61;
  --cyan: #79cac5;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(139, 212, 94, 0.08), transparent 32rem),
    radial-gradient(circle at 84% 12%, rgba(237, 123, 97, 0.12), transparent 21rem),
    var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button,
select,
input,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 12, 10, 0.72);
  color: var(--ink);
}

button {
  min-height: 36px;
  min-width: 0;
  padding: 0 12px;
  cursor: pointer;
  overflow-wrap: anywhere;
}

button:hover,
button:focus-visible {
  border-color: rgba(139, 212, 94, 0.62);
  outline: none;
}

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

textarea,
input,
select {
  width: 100%;
  min-width: 0;
}

textarea {
  min-height: 360px;
  resize: vertical;
  padding: 12px;
  line-height: 1.65;
}

input,
select {
  min-height: 38px;
  padding: 0 10px;
}

input[type="range"] {
  padding: 0;
  accent-color: var(--green);
}

.ll-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px clamp(16px, 3vw, 36px);
  border-bottom: 1px solid var(--line);
  background: rgba(16, 17, 15, 0.78);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.ll-kicker {
  margin: 0 0 2px;
  color: var(--amber);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.15;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 5vw, 46px);
}

h2 {
  font-size: 18px;
}

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

.ll-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.ll-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.04);
}

.ll-nav a:hover,
.ll-nav a:focus-visible {
  border-color: rgba(121, 202, 197, 0.68);
  outline: none;
}

.ll-shell {
  display: grid;
  grid-template-columns: minmax(280px, 0.82fr) minmax(360px, 1.18fr) minmax(220px, 0.52fr);
  gap: 14px;
  padding: 14px clamp(12px, 2vw, 22px) 22px;
}

.ll-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(24, 27, 22, 0.9);
  box-shadow: var(--shadow);
}

.ll-source,
.ll-output,
.ll-rack {
  min-height: calc(100vh - 108px);
}

.ll-source {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
}

.ll-panel-head,
.ll-output-toolbar,
.ll-tabs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ll-field {
  display: grid;
  gap: 6px;
}

.ll-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.ll-field-grow {
  flex: 1;
  min-height: 0;
}

.ll-field-grow textarea {
  height: 100%;
}

.ll-distill-field textarea {
  min-height: 150px;
}

.ll-production-route {
  display: grid;
  gap: 9px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.ll-production-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.ll-production-route output {
  min-width: 0;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 800;
  overflow-wrap: anywhere;
  text-align: right;
}

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

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

.ll-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.ll-actions-library {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ll-actions-distill {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ll-primary {
  border-color: rgba(139, 212, 94, 0.58);
  background: linear-gradient(180deg, rgba(139, 212, 94, 0.24), rgba(139, 212, 94, 0.08));
}

.ll-status {
  min-height: 18px;
  margin: 0;
  color: var(--cyan);
  font-size: 12px;
}

.ll-output {
  display: grid;
  grid-template-rows: auto auto 1fr;
  overflow: hidden;
}

.ll-tabs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  justify-content: flex-start;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.12);
}

.ll-tab {
  min-height: 34px;
  width: 100%;
  padding: 0 8px;
  color: var(--muted);
}

.ll-tab.is-active {
  border-color: rgba(225, 176, 74, 0.65);
  color: var(--ink);
  background: rgba(225, 176, 74, 0.12);
}

.ll-output-toolbar {
  min-height: 48px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

#ll-output-label {
  color: var(--amber);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.ll-output-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.ll-output-context {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.ll-source-link {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid rgba(121, 202, 197, 0.36);
  border-radius: 8px;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
}

.ll-source-link:hover,
.ll-source-link:focus-visible {
  border-color: rgba(121, 202, 197, 0.72);
  outline: none;
}

.ll-source-link[hidden] {
  display: none;
}

.ll-output-tools [hidden] {
  display: none;
}

.ll-output-toolbar[hidden] {
  display: none;
}

.ll-view {
  display: none;
  margin: 0;
  padding: 18px;
  overflow: auto;
  white-space: pre-wrap;
  color: #f7f3e8;
  font: 14px/1.72 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.ll-view.is-active {
  display: block;
}

.ll-final-editor {
  width: 100%;
  min-height: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  outline: none;
  resize: none;
}

.ll-final-editor.is-active {
  display: block;
}

.ll-library-view {
  overflow: auto;
  font: inherit;
}

.ll-rack {
  padding: 14px;
  overflow: auto;
}

.ll-rack-group {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.ll-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.ll-chip {
  max-width: 100%;
  padding: 6px 8px;
  border: 1px solid rgba(242, 240, 232, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--ink);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.ll-chip[data-kind="hook"] {
  border-color: rgba(139, 212, 94, 0.42);
}

.ll-chip[data-kind="mantra"] {
  border-color: rgba(237, 123, 97, 0.42);
}

.ll-chip[data-kind="image"] {
  border-color: rgba(121, 202, 197, 0.36);
}

.ll-chip[data-kind="distill"] {
  border-color: rgba(225, 176, 74, 0.42);
  background: rgba(225, 176, 74, 0.055);
}

.ll-library-list {
  display: grid;
  gap: 7px;
}

.ll-library-head,
.ll-library-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ll-library-head {
  justify-content: space-between;
}

.ll-library-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ll-new-draft {
  min-height: 34px;
  border-color: rgba(139, 212, 94, 0.52);
  background: rgba(139, 212, 94, 0.1);
}

.ll-library-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(104px, auto);
  align-content: start;
  grid-auto-rows: max-content;
  height: max-content;
}

.ll-library-count {
  color: var(--cyan);
  font-size: 11px;
  font-weight: 800;
}

.ll-library-list-main {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  margin-top: 10px;
}

.ll-library-view .ll-library-tools {
  grid-template-columns: minmax(0, 1fr) minmax(132px, auto);
}

.ll-library-cloud-tools {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(160px, 1fr) auto;
  align-content: start;
  align-items: center;
  gap: 10px;
  grid-auto-rows: max-content;
  height: max-content;
  padding: 10px;
  border: 1px solid rgba(242, 240, 232, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
}

.ll-cloud-state {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.ll-cloud-state span,
.ll-token-field span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.ll-cloud-state strong {
  color: var(--ink);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.ll-library-cloud-tools[data-state="connected"] .ll-cloud-state strong {
  color: var(--green);
}

.ll-library-cloud-tools[data-state="error"] .ll-cloud-state strong {
  color: var(--coral);
}

.ll-cloud-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, auto));
  gap: 6px;
}

.ll-cloud-settings {
  display: grid;
  align-self: start;
  gap: 8px;
  grid-column: 1 / -1;
  min-width: 0;
}

.ll-cloud-settings-toggle {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  min-height: 38px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.ll-cloud-settings .ll-token-field {
  display: none;
}

.ll-cloud-settings[data-open="true"] .ll-token-field {
  display: grid;
}

.ll-token-field {
  display: grid;
  gap: 4px;
}

.ll-library-cloud-tools input {
  min-height: 36px;
}

.ll-library-cloud-tools button {
  min-height: 36px;
  white-space: nowrap;
}

.ll-library-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(78px, auto) 32px;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(242, 240, 232, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  padding: 5px;
}

.ll-library-item[data-active="true"] {
  border-color: rgba(139, 212, 94, 0.52);
}

.ll-library-item[data-status="fixed"] {
  border-color: rgba(225, 176, 74, 0.58);
  background: rgba(225, 176, 74, 0.07);
}

.ll-library-card {
  align-content: start;
  align-items: stretch;
  grid-template-columns: 1fr;
  min-height: 196px;
  overflow: hidden;
  padding: 12px;
}

.ll-library-card-top,
.ll-library-card-footer {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.ll-library-load {
  min-height: 30px;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ll-library-card .ll-library-load {
  min-height: auto;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
  white-space: normal;
}

.ll-library-meta {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ll-library-shelf-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}

.ll-library-tag {
  max-width: 100%;
  padding: 4px 6px;
  border: 1px solid rgba(242, 240, 232, 0.12);
  border-radius: 999px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.ll-library-tag[data-kind="scene"] {
  border-color: rgba(139, 212, 94, 0.4);
  color: var(--green);
}

.ll-library-tag[data-kind="fixed"] {
  border-color: rgba(225, 176, 74, 0.5);
  color: var(--amber);
}

.ll-library-tag[data-kind="production"] {
  border-color: rgba(121, 202, 197, 0.5);
  color: var(--cyan);
}

.ll-library-preview,
.ll-library-scene {
  margin: 0;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ll-library-preview {
  min-height: 58px;
}

.ll-library-scene {
  border-left: 2px solid rgba(139, 212, 94, 0.4);
  padding-left: 8px;
  color: var(--muted);
}

.ll-library-date {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.ll-library-card-footer .ll-library-delete {
  width: auto;
}

.ll-library-delete {
  min-height: 30px;
  padding: 0 8px;
  color: var(--muted);
}

.ll-library-card-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.ll-library-source-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid rgba(121, 202, 197, 0.4);
  border-radius: 8px;
  color: var(--cyan);
  font-size: 12px;
  text-decoration: none;
}

.ll-library-source-link:hover,
.ll-library-source-link:focus-visible {
  border-color: rgba(121, 202, 197, 0.72);
  outline: none;
}

.ll-library-open-button {
  border-color: rgba(139, 212, 94, 0.52);
  background: rgba(139, 212, 94, 0.1);
}

.ll-library-empty {
  color: var(--muted);
  font-size: 12px;
}

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

  .ll-rack {
    grid-column: 1 / -1;
    min-height: 0;
  }
}

@media (max-width: 760px) {
  .ll-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .ll-nav {
    justify-content: flex-start;
  }

  .ll-shell {
    grid-template-columns: 1fr;
  }

  .ll-source,
  .ll-output,
  .ll-rack {
    min-height: auto;
  }

  textarea {
    min-height: 280px;
  }

  .ll-control-grid,
  .ll-actions {
    grid-template-columns: 1fr;
  }

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

  .ll-output-toolbar,
  .ll-output-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .ll-output-tools button {
    width: 100%;
  }

  .ll-output[data-view="final"] .ll-output-tools {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .ll-output[data-view="final"] .ll-output-tools button {
    min-height: 44px;
  }

  .ll-output[data-view="final"] .ll-final-editor {
    min-height: clamp(440px, 62vh, 680px);
  }

  .ll-library-tools {
    grid-template-columns: 1fr;
  }

  .ll-library-view .ll-library-tools {
    grid-template-columns: 1fr;
  }

  .ll-library-cloud-tools {
    grid-template-columns: 1fr;
    gap: 9px;
    padding: 12px;
  }

  .ll-cloud-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ll-cloud-actions button {
    min-height: 44px;
    white-space: normal;
  }

  .ll-library-list-main {
    grid-template-columns: 1fr;
  }

  .ll-library-card {
    gap: 10px;
    min-height: 0;
    padding: 14px;
  }

  .ll-library-card-top,
  .ll-library-card-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .ll-library-shelf-tags {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .ll-library-tag {
    border-radius: 6px;
    line-height: 1.2;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .ll-library-shelf-tags .ll-library-tag:nth-child(n+5) {
    display: none;
  }

  .ll-library-preview,
  .ll-library-scene {
    display: -webkit-box;
    min-height: 0;
    overflow: hidden;
    -webkit-box-orient: vertical;
  }

  .ll-library-preview {
    -webkit-line-clamp: 5;
  }

  .ll-library-scene {
    -webkit-line-clamp: 2;
  }

  .ll-library-card-footer .ll-library-meta {
    white-space: normal;
  }

  .ll-library-card-actions button,
  .ll-library-card-actions a {
    min-height: 42px;
  }

  .ll-library-card-footer {
    align-items: end;
  }

  .ll-library-card-footer .ll-library-meta {
    display: none;
  }

  .ll-library-preview {
    -webkit-line-clamp: 4;
  }

  .ll-library-scene {
    display: none;
  }

  .ll-rack-shelf {
    display: none;
  }
}
