/* Shared surfaces and control states across the workspace. */
:root {
  --canvas: #f4f6f8;
  --surface: #fff;
  --surface-soft: #f7f9fa;
  --ink: #172431;
  --muted: #505e6c;
  --border: #dbe2e8;
  --control: #aab7c3;
  --accent: #08756a;
  --accent-hover: #075e57;
  --accent-soft: #e6f4f0;
  --nav: #152431;
  --danger: #a3313a;
  --focus: #087e76;
  --radius: 10px;
  --ease: 150ms ease;
}
* {
  box-sizing: border-box;
}
html {
  color-scheme: light;
}
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font:
    16px/1.5 "DM Sans",
    "Segoe UI",
    "Microsoft YaHei",
    sans-serif;
}
button,
input,
textarea,
select {
  font: inherit;
}
button,
a.btn {
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 8px 15px;
  font-weight: 600;
  text-decoration: none;
  transition:
    background-color var(--ease),
    border-color var(--ease),
    color var(--ease);
}
button:hover,
a.btn:hover {
  background: var(--surface-soft);
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.primary:hover {
  background: var(--accent-hover);
}
.danger {
  color: var(--danger);
}
input,
select,
textarea {
  min-width: 0;
  border: 1px solid var(--control);
  padding: 9px 12px;
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
}
input:not([type="checkbox"]),
select,
textarea {
  width: 100%;
}
textarea {
  resize: vertical;
}
label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: clamp(24px, 2.4vw, 31px);
  line-height: 1.2;
  letter-spacing: -0.025em;
}
h2 {
  font-size: 19px;
}
h3 {
  font-size: 17px;
}
.shell {
  padding: 16px clamp(12px, 1.6vw, 32px) 60px;
}
.bar {
  background: var(--nav);
  color: white;
  padding: 9px clamp(12px, 1.6vw, 32px);
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 750;
  white-space: nowrap;
}
.logo {
  display: inline-flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 8px;
  background: var(--accent);
}
.logo i {
  width: 2px;
  height: 8px;
  background: #effffa;
  border-radius: 2px;
}
.logo i:nth-child(2),
.logo i:nth-child(4) {
  height: 13px;
}
.logo i:nth-child(3) {
  height: 19px;
}
.bar nav,
.row,
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.bar nav {
  flex: 1;
}
.bar button {
  background: transparent;
  color: #c8d4df;
  border: 0;
  padding: 6px 10px;
}
.bar button.active,
.bar button:hover {
  background: #294252;
  color: white;
}
.card,
.line {
  padding: 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}
.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.bar .account {
  border: 1px solid #526171;
  border-radius: 20px;
  max-width: 42vw;
  overflow-wrap: anywhere;
}
.layout {
  display: grid;
  grid-template-columns: clamp(160px, 13vw, 220px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.stack,
.card,
.line {
  display: grid;
  gap: 12px;
}
.card {
  align-content: start;
}
.project-list,
.project-settings {
  padding: 14px;
}
.project-list button,
.project-settings h2 {
  overflow-wrap: anywhere;
}
.project-list h2 {
  color: var(--muted);
  font-size: 14px;
}
.project-list .listbtn:not(.current-project) {
  border-color: transparent;
}
.project-list > [data-act="voice"] {
  border-style: dashed;
}
.project-meta button {
  font-size: 14px;
  padding: 5px 10px;
}
.project-controls {
  justify-content: space-between;
}
.toolbar-edit,
.toolbar-output {
  gap: 8px;
}
.toolbar-output {
  margin-inline-start: auto;
}
.line-overview {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0 0;
}
.line-overview h2 {
  font-size: 17px;
}
.project-list .current-project {
  background: var(--accent-soft);
  border-color: #a5cec4;
}
.work-area {
  container-type: inline-size;
}
.project-controls label {
  display: flex;
  align-items: center;
  gap: 8px;
}
.project-controls select {
  width: clamp(110px, 14vw, 220px);
}
#lines {
  display: grid;
  gap: 0;
}
.line-head,
.line {
  grid-template-columns:
    34px minmax(128px, 18cqw) minmax(112px, 1.4fr)
    clamp(88px, 8.5cqw, 102px)
    clamp(88px, 8.5cqw, 102px) minmax(108px, 1fr) 108px 28px 44px;
  align-items: start;
  gap: 8px;
  padding: 8px 10px;
}
.line {
  border-radius: 0;
}
.line + .line {
  border-top: 0;
}
.line:first-child {
  border-radius: var(--radius) var(--radius) 0 0;
}
.line:last-child {
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}
.line:focus-within {
  background: #f6fbfa;
}
.line-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #edf2f5;
  font-size: 14px;
  font-weight: 600;
}
.line-head > button {
  grid-column: 7 / -1;
  justify-self: start;
  white-space: nowrap;
}
.line-head label {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.line-head label select {
  flex: 1;
}
.line-head button,
.line-head select,
.line-head input {
  padding: 4px 6px;
}
.head-number {
  justify-self: center;
}
.line-number {
  padding-top: 5px;
  font-variant-numeric: tabular-nums;
  font-size: 16px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}
.line-text,
.line-choices,
.line-actions,
.line-audio {
  min-width: 0;
}
.line-text textarea {
  min-height: calc(2 * var(--choice-height) + var(--choice-gap));
  font-size: 1rem;
  font-weight: 400;
}
.line-choices {
  grid-column: span 2;
  display: grid;
  gap: var(--choice-gap);
}
.line-choices select {
  height: var(--choice-height);
}
.line {
  --choice-height: 34px;
  --choice-gap: 5px;
}
.line-style {
  min-height: calc(2 * var(--choice-height) + var(--choice-gap));
}
.line-choices label {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 6px;
}
.line input,
.line select,
.line textarea {
  padding: 5px 8px;
}
.line input,
.line select,
.line button,
.line a.btn,
.line-style {
  font-size: 14px;
}
.line button,
.line a.btn {
  padding: 4px 8px;
}
.line-actions,
.line-delete {
  display: grid;
  gap: 5px;
}
.line-tools {
  display: grid;
  grid-template-columns: 28px;
  gap: 4px;
}
.line-delete {
  padding-left: 6px;
  border-left: 1px solid var(--border);
  align-self: stretch;
}
.line .line-delete button {
  background: #fcf6f6;
}
.line .line-delete button:hover {
  background: #f8e4e6;
  border-color: #d5a7ae;
}
.line-actions .line-generate {
  color: var(--accent);
}
.line .line-tools button,
.line .line-delete button {
  padding: 0;
  min-height: 30px;
  font-size: 18px;
  line-height: 1;
}
.line-delete button,
.clip [data-act="deleteVersion"] {
  color: var(--danger);
}
.clip [data-act="deleteVersion"] {
  padding-inline: 6px;
}
.line textarea {
  scroll-margin-top: 108px;
}
.line-tools [data-act="insertLine"] {
  color: var(--accent);
}
.line-audio {
  display: grid;
  justify-items: start;
  gap: 5px;
}
.line-audio audio {
  width: 100%;
  grid-column: 1 / -1;
}
.line .version-trigger {
  font-size: 13px;
  padding: 3px 7px;
  white-space: nowrap;
}
.line .version-trigger:hover {
  border-color: var(--accent);
}
.changed-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 2px;
  border-radius: 50%;
  vertical-align: 2px;
  background: #a5531b;
}
#versionList {
  display: grid;
  gap: 8px;
}
#versionList .clip {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.clip-error {
  grid-column: 1 / -1;
  overflow-wrap: anywhere;
}
.tag[data-status="queued"],
.tag[data-status="running"] {
  background: #fff0d1;
  color: #74461d;
}
.tag[data-status="failed"] {
  background: #f9e6e6;
  color: #8b3537;
}
.tag[data-status="idle"],
.tag[data-status="cancelled"] {
  background: #eef2f1;
  color: var(--muted);
}
.listbtn {
  text-align: left;
  width: 100%;
}
.muted,
small {
  color: var(--muted);
}
.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.toolbar {
  justify-content: space-between;
}
.clip {
  display: flex;
  width: 100%;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}
.clip audio,
.clip-error {
  flex-basis: 100%;
}
#previewAudio {
  width: 100%;
}
.tag {
  background: var(--accent-soft);
  color: #215d46;
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 13px;
}
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--canvas);
  padding: 24px;
}
.login .card {
  max-width: 430px;
  width: 100%;
  padding: clamp(22px, 5vw, 36px);
  gap: 18px;
  box-shadow: 0 12px 32px #15243112;
}
.login .brand {
  color: var(--accent);
}
.subtle {
  border: 0;
  background: transparent;
  color: var(--accent);
}
.form-error {
  color: var(--danger);
  background: #fcf0f1;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
}
::selection {
  background: #c7e8e0;
  color: var(--ink);
}
::placeholder {
  color: var(--muted);
  opacity: 1;
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.bar :focus-visible {
  outline-color: #83dfcd;
}
button:not(:disabled):active,
a.btn:active {
  filter: brightness(0.94);
}
input,
select,
textarea {
  caret-color: var(--accent);
}
select {
  cursor: pointer;
}
@media (prefers-reduced-motion: reduce) {
  button,
  a.btn {
    transition: none;
  }
}
.notice,
#notice:not(:empty) {
  background: var(--nav);
  color: white;
  padding: 10px 18px;
  border-radius: 8px;
}
#notice {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  max-width: 90%;
  pointer-events: none;
}
dialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(540px, calc(100% - 24px));
  padding: 0;
  max-height: 88dvh;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 18px 52px #15243133;
  overflow-wrap: anywhere;
}
dialog::backdrop {
  background: #15243180;
}
.dialog-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.dialog-header .close {
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 21px;
  line-height: 1;
}
.dialog-body {
  padding: 18px 20px;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
dialog > .dialog-actions {
  padding: 12px 20px;
}
.dialog-notice:not(:empty) {
  display: block;
  margin: 0 20px 16px;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--ink);
}
.danger-primary {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}
.danger-primary:hover {
  background: #872b33;
  border-color: #872b33;
}
@media (pointer: coarse) {
  .dialog-header .close {
    width: 44px;
    height: 44px;
  }
}
audio {
  max-width: 100%;
  height: 36px;
}
meter {
  width: 100%;
}
.warn {
  color: #9b4b15;
}
.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(290px, 100%), 1fr));
  gap: 16px;
}
.adminitem {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.adminitem button {
  font-size: 14px;
}
.sr {
  position: absolute;
  left: -9999px;
}
@media (max-width: 730px) {
  .shell {
    padding: 16px 12px 64px;
  }
  .bar {
    padding: 10px 12px;
    gap: 5px;
    flex-wrap: wrap;
  }
  .bar nav {
    order: 3;
    flex-basis: 100%;
  }
  .layout,
  .pair {
    grid-template-columns: 1fr;
  }
  .card {
    padding: 16px;
  }
  .hero {
    gap: 10px;
  }
  .bar .brand {
    flex: 1;
  }
}
@container (max-width: 868px) {
  .line-head {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .line-head > button {
    grid-column: auto;
    justify-self: end;
  }
  .head-number,
  .head-audio,
  .head-text {
    display: none;
  }
  .line {
    grid-template-columns: 32px repeat(2, minmax(0, 1fr)) 40px;
    grid-template-areas:
      "number audio audio delete"
      ". text text delete"
      ". choices choices delete"
      ". style actions delete"
      ". tools tools delete";
  }
  .line-number {
    grid-area: number;
  }
  .line-audio {
    grid-area: audio;
  }
  .line-text {
    grid-area: text;
  }
  .line-choices {
    grid-area: choices;
  }
  .line-style {
    grid-area: style;
  }
  .line-actions {
    grid-area: actions;
  }
  .line-tools {
    grid-area: tools;
    justify-self: end;
  }
  .line-delete {
    grid-area: delete;
  }
}

@media (hover: none) and (pointer: coarse) {
  .bar button,
  .project-controls button,
  .line button,
  .line a.btn {
    min-height: 44px;
  }
}
@media (max-width: 560px) {
  .project-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .project-list h2 {
    grid-column: 1 / -1;
  }
  .project-list button,
  .project-controls button {
    font-size: 14px;
    padding-inline: 8px;
  }
  .project-controls {
    gap: 8px;
    justify-content: start;
  }
  .project-controls label {
    flex: 1 1 100%;
  }
  .project-controls select {
    width: auto;
    flex: 1;
  }
  .toolbar-output {
    margin-inline-start: 0;
  }
  .project-controls :is(.toolbar-edit, .toolbar-output) {
    gap: 6px;
  }
}
