:root {
  color-scheme: light dark;
  --canvas: #f1f0ec;
  --surface: #f8f7f3;
  --surface-raised: #ebe9e2;
  --text: #20211f;
  --muted: #66675f;
  --line: #d4d1c7;
  --accent: #315d50;
  --accent-strong: #24493f;
  --accent-text: #f5f8f4;
  --danger: #9b443d;
  --warning: #8a6327;
  --focus: #4d7d70;
  --radius: 10px;
  --shadow: 0 12px 30px rgb(41 43 38 / 0.08);
  font-family: "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
  font-synthesis: none;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #171916;
    --surface: #1d201c;
    --surface-raised: #272b25;
    --text: #e8e9e3;
    --muted: #a5a89f;
    --line: #373c34;
    --accent: #80ad9d;
    --accent-strong: #9cc3b5;
    --accent-text: #14201c;
    --danger: #e58b81;
    --warning: #d7ad69;
    --focus: #9bc3b5;
    --shadow: 0 12px 30px rgb(5 7 5 / 0.28);
  }
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  background: var(--canvas);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus), transparent 35%);
  outline-offset: 2px;
}

.topbar {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px clamp(18px, 3vw, 42px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface), transparent 6%);
}

.topbar h1,
.topbar p,
.workspace-heading h2,
.workspace-heading p,
.control-section h2 {
  margin: 0;
}

.topbar h1 {
  font-size: 17px;
  line-height: 1.25;
  font-weight: 680;
  letter-spacing: -0.01em;
}

.topbar p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.system-status {
  max-width: 42ch;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.system-status.is-ready {
  color: var(--accent-strong);
}

.system-status.is-error {
  color: var(--danger);
}

.account-status {
  display: flex;
  align-items: center;
  gap: 14px;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, var(--canvas), transparent 4%);
}

.login-screen[hidden] {
  display: none;
}

.login-card {
  width: min(410px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-card h2,
.login-card p {
  margin: 0;
}

.login-card h2 {
  margin-bottom: 8px;
  font-size: 26px;
  letter-spacing: -0.025em;
}

.login-card > p:not(.login-eyebrow) {
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 13px;
}

.login-eyebrow {
  margin-bottom: 7px !important;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.12em;
}

.login-card .button {
  width: 100%;
  margin-top: 12px;
}

.login-notice {
  display: block;
  min-height: 18px;
  margin-top: 12px;
  color: var(--danger);
  font-size: 12px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(270px, 330px) minmax(0, 1fr);
  min-height: calc(100dvh - 69px);
}

.app-shell.is-rail-collapsed {
  grid-template-columns: 72px minmax(0, 1fr);
}

.control-rail {
  padding: 26px 22px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.manager-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.manager-heading h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
}

.active-session-id {
  display: block;
  max-width: 22ch;
  margin-top: 5px;
  overflow: hidden;
  color: var(--accent-strong);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 11px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-toggle {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 9px;
  background: var(--surface-raised);
  color: var(--text);
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
}

.rail-toggle:active:not(:disabled) {
  transform: translateY(1px);
}

.session-manager-content {
  padding-top: 22px;
}

.control-rail.is-collapsed {
  padding: 18px 10px;
}

.control-rail.is-collapsed .manager-heading {
  justify-content: center;
  padding-bottom: 0;
  border-bottom: 0;
}

.control-rail.is-collapsed .manager-heading-copy,
.control-rail.is-collapsed .session-manager-content {
  display: none;
}

.control-rail.is-collapsed .rail-toggle {
  width: 100%;
  padding-inline: 4px;
}

.control-section + .control-section,
.run-log {
  margin-top: 30px;
}

.control-section h2 {
  margin-bottom: 15px;
  font-size: 14px;
  font-weight: 680;
}

.session-list {
  display: grid;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
}

.session-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--canvas);
}

.session-row.is-active {
  border-color: color-mix(in srgb, var(--accent), var(--line) 35%);
  background: color-mix(in srgb, var(--accent), var(--surface) 88%);
}

.session-open,
.session-delete {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.session-open {
  min-width: 0;
  padding: 9px 10px;
  text-align: left;
}

.session-open strong,
.session-open span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-open strong {
  color: var(--text);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 11px;
}

.session-open span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.session-delete {
  padding: 0 9px;
  border-left: 1px solid var(--line);
  color: var(--danger);
  font-size: 10px;
  font-weight: 650;
}

.session-open:hover:not(:disabled),
.session-delete:hover:not(:disabled) {
  background: color-mix(in srgb, var(--surface-raised), transparent 12%);
}

.session-list-empty {
  margin: 0;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 7px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.session-list-empty.is-error {
  color: var(--danger);
}

label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--canvas);
  color: var(--text);
}

select:disabled {
  color: var(--muted);
}

.session-id-label {
  margin-top: 14px;
}

input::placeholder {
  color: color-mix(in srgb, var(--muted), transparent 20%);
}

.button-row {
  display: grid;
  grid-template-columns: 0.75fr 1.45fr;
  gap: 8px;
  margin-top: 10px;
}

.button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 9px 13px;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:active:not(:disabled) {
  transform: translateY(0);
}

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

.button.primary {
  background: var(--accent);
  color: var(--accent-text);
}

.button.primary:hover:not(:disabled) {
  background: var(--accent-strong);
}

.button.secondary {
  border-color: var(--line);
  background: var(--surface-raised);
}

.button.danger {
  border-color: var(--danger);
  background: var(--danger);
  color: var(--surface);
}

.field-help {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.setup-summary {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.setup-summary p {
  margin: 0;
}

.setup-summary ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.setup-summary li + li {
  margin-top: 4px;
}

.run-log {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.run-log summary {
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.run-log ol {
  max-height: 220px;
  margin: 12px 0 0;
  padding: 0;
  overflow: auto;
  list-style: none;
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 10px;
  line-height: 1.45;
}

.run-log li + li {
  margin-top: 8px;
}

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

.workspace {
  min-width: 0;
  padding: 28px clamp(20px, 4vw, 58px) 56px;
}

.workspace-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.workspace-heading h2 {
  font-size: clamp(22px, 2.4vw, 32px);
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.workspace-heading p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
}

.text-button {
  border: 0;
  padding: 7px 0;
  background: transparent;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.notice {
  margin-bottom: 18px;
  padding: 11px 13px;
  border-left: 3px solid var(--accent);
  background: var(--surface-raised);
  font-size: 13px;
  line-height: 1.45;
}

.notice.is-error {
  border-left-color: var(--danger);
  color: var(--danger);
}

.sound-list {
  display: grid;
  gap: 14px;
}

.sound-lane {
  display: grid;
  grid-template-columns: 54px minmax(140px, 220px) minmax(0, 1fr) auto;
  gap: clamp(16px, 2.5vw, 34px);
  align-items: stretch;
  min-height: 168px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.lane-index {
  display: grid;
  place-items: center;
  border-right: 1px solid var(--line);
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 12px;
}

.annotation-preview {
  min-width: 0;
  padding: 16px 0;
}

.annotation-preview img {
  display: block;
  width: 100%;
  height: 136px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--canvas);
  object-fit: contain;
}

.annotation-download {
  display: inline-block;
  margin-top: 8px;
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 650;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.revision-content {
  min-width: 0;
  padding: 18px 0;
}

.revision-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
}

.revision-title h3 {
  margin: 0;
  font-size: 16px;
}

.revision-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.revision-picker span {
  color: var(--muted);
  font-size: 10px;
}

.revision-picker select {
  width: auto;
  min-height: 30px;
  padding: 4px 28px 4px 8px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 10px;
}

.revision-content .status {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.revision-content .status.is-failed {
  color: var(--danger);
}

.timing {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 9px 16px;
  margin: 18px 0 12px;
}

.clock {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: clamp(23px, 3vw, 35px);
  font-weight: 640;
  letter-spacing: -0.035em;
}

.timecode,
.duration,
.confidence {
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 11px;
}

.prompt,
.reason,
.error-copy {
  margin: 0;
  max-width: 76ch;
  font-size: 12px;
  line-height: 1.5;
}

.prompt {
  margin-top: 0;
  color: var(--muted);
}

.reason {
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
}

.prompt strong,
.reason strong {
  color: var(--text);
  font-weight: 680;
}

.error-copy {
  margin-top: 18px;
  color: var(--danger);
}

.lane-actions {
  width: 176px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 15px;
  padding: 18px;
  border-left: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-raised), transparent 28%);
}

.lane-actions audio {
  width: 140px;
  height: 32px;
}

.lane-actions .button {
  width: 100%;
}

.download-link {
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 650;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.lane-meta {
  display: grid;
  gap: 7px;
}

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

.sound-lane.is-empty {
  grid-template-columns: 54px minmax(0, 1fr);
  min-height: 96px;
  box-shadow: none;
}

.sound-lane.is-loading {
  box-shadow: none;
}

.skeleton {
  border-radius: 5px;
  background: color-mix(in srgb, var(--surface-raised), var(--line) 18%);
}

.skeleton-preview {
  width: 100%;
  height: 136px;
  border: 1px solid var(--line);
}

.skeleton-title {
  width: min(180px, 55%);
  height: 18px;
}

.skeleton-time {
  width: min(260px, 72%);
  height: 35px;
  margin-top: 24px;
}

.skeleton-line {
  width: min(540px, 90%);
  height: 10px;
  margin-top: 15px;
}

.skeleton-line.is-short {
  width: min(380px, 62%);
  margin-top: 8px;
}

.skeleton-audio {
  width: 140px;
  max-width: 100%;
  height: 32px;
}

.skeleton-button {
  width: 100%;
  height: 42px;
}

.empty-copy {
  align-self: center;
  padding: 17px 22px 17px 0;
}

.empty-copy h3,
.empty-copy p {
  margin: 0;
}

.empty-copy h3 {
  font-size: 14px;
}

.empty-copy p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.delete-dialog {
  width: min(470px, calc(100% - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.delete-dialog::backdrop {
  background: rgb(15 17 15 / 0.52);
}

.delete-dialog form {
  padding: 26px;
}

.delete-dialog h2,
.delete-dialog p {
  margin: 0;
}

.delete-dialog h2 {
  margin-bottom: 10px;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.delete-dialog > form > p:not(.dialog-label) {
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.dialog-label {
  margin-bottom: 6px !important;
  color: var(--danger);
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

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

@media (max-width: 980px) {
  .sound-lane {
    grid-template-columns: 46px minmax(130px, 180px) minmax(0, 1fr);
  }

  .lane-actions {
    width: auto;
    grid-column: 2 / -1;
    flex-direction: row;
    align-items: center;
    padding: 13px 16px;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .lane-actions .button {
    width: auto;
  }
}

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

  .topbar p {
    display: none;
  }

  .system-status {
    font-size: 11px;
  }

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

  .app-shell.is-rail-collapsed {
    grid-template-columns: 1fr;
  }

  .control-rail {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .control-rail.is-collapsed {
    padding: 10px 16px;
  }

  .control-rail.is-collapsed .manager-heading {
    justify-content: flex-start;
  }

  .control-rail.is-collapsed .rail-toggle {
    width: auto;
    min-width: 72px;
  }

  .setup-section,
  .run-log {
    display: none;
  }

  .workspace {
    padding: 24px 16px 42px;
  }

  .sound-lane {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .annotation-preview {
    padding: 14px 14px 0 0;
  }

  .revision-content {
    grid-column: 2;
    padding: 0 14px 14px 0;
  }

  .lane-actions {
    grid-column: 2;
    margin-left: -1px;
    padding: 12px 14px 14px 0;
    background: transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  .button {
    transition: none;
  }
}
