:root {
  color-scheme: dark;
  --bg: #081421;
  --ink: #fffaf1;
  --muted: #c8d1dc;
  --line: #314966;
  --panel: #132236;
  --accent: #16847d;
  --accent-ink: #ffffff;
  --deep: #06264b;
  --danger: #ff6b58;
  --warn: #ffc24b;
  --ok: #69d494;
  --hot: #ff563e;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f7fb;
  --ink: #111827;
  --muted: #4d5a68;
  --line: #c8d4e5;
  --panel: #ffffff;
  --accent: #147f77;
  --deep: #0b3565;
  --hot: #dd3d2a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #081421 0%, var(--bg) 42%, #07111d 100%);
  color: var(--ink);
}

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

button,
.button {
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.9rem 1.05rem;
  border-radius: 10px;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  font-weight: 800;
}

button:disabled,
.disabled {
  opacity: 0.48;
  pointer-events: none;
}

.ghost,
.icon-btn {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.topbar {
  min-height: 74px;
  padding: 1rem clamp(1.25rem, 7vw, 2.65rem);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  border-bottom: 1px solid rgb(255 255 255 / 0.06);
}

.topbar h1,
.panel h2 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 0.2rem;
  color: var(--hot);
  font-size: 0.77rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 900;
}

.top-actions,
.action-row,
.inline-form {
  display: flex;
  align-items: end;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.48rem 0.72rem;
  color: var(--muted);
}

.shell {
  width: min(1060px, calc(100% - 1.25rem));
  margin: 0 auto 2rem;
}

body.auth-active .topbar {
  display: none;
}

body.auth-active .shell {
  width: min(524px, calc(100% - 2rem));
  margin-left: clamp(1rem, 7vw, 2.65rem);
  margin-right: auto;
}

.panel,
.reader {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 1.4rem;
}

.auth-view {
  display: grid;
  grid-template-columns: minmax(280px, 524px);
  gap: 1.15rem;
  align-items: stretch;
  padding: 0.35rem 0 2rem;
}

.auth-block {
  display: grid;
  gap: 0.95rem;
  align-content: start;
  min-height: 0;
}

.primary-auth {
  border-color: #3c5a80;
  box-shadow: none;
}

.auth-block h2 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.35rem, 4.7vw, 1.62rem);
  line-height: 1.07;
}

.auth-message {
  min-height: 1.2rem;
  margin: 0;
  color: var(--danger);
  line-height: 1.35;
}

.auth-message.ok {
  color: var(--ok);
}

.hero-copy {
  padding: 0.3rem 0 0.35rem;
}

.hero-copy h1 {
  max-width: 9.8ch;
  margin: 0.35rem 0 0.7rem;
  font-size: clamp(3.05rem, 10vw, 5.25rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.hero-copy p:last-child {
  max-width: 34rem;
  margin: 0;
  color: var(--muted);
  font-size: clamp(1rem, 3vw, 1.12rem);
  line-height: 1.45;
  font-weight: 650;
}

.paypal-box {
  min-height: 132px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1rem;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  background: #091522;
  color: #fffaf1;
  border-radius: 14px;
  padding: 1rem;
  min-width: 0;
  caret-color: #fffaf1;
  -webkit-text-fill-color: #fffaf1;
}

input::placeholder,
textarea::placeholder {
  color: rgb(255 250 241 / 0.45);
  -webkit-text-fill-color: rgb(255 250 241 / 0.45);
  opacity: 1;
}

input:-webkit-autofill,
input:-webkit-autofill:focus,
input:-webkit-autofill:hover,
select:-webkit-autofill,
textarea:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px #091522 inset;
  -webkit-text-fill-color: #fffaf1;
  caret-color: #fffaf1;
}

textarea {
  width: 100%;
  min-height: 330px;
  resize: vertical;
  line-height: 1.5;
}

.segment-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0.9rem 0;
}

.segments-list {
  display: grid;
  gap: 0.85rem;
}

.segment-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.85rem;
  background: rgb(255 255 255 / 0.025);
}

.segment-card textarea {
  min-height: 210px;
}

.segment-head {
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) auto;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.7rem;
}

.mini-button {
  min-height: 34px;
  padding: 0.42rem 0.58rem;
  border-radius: 8px;
  font-size: 0.82rem;
}

.mini-button.danger {
  color: var(--danger);
}

.text-label {
  color: var(--ink);
}

.muted {
  color: var(--muted);
}

.status {
  min-height: 1.5rem;
  margin: 0.8rem 0;
  color: var(--muted);
}

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

.status.warn {
  color: var(--warn);
}

.status.ok {
  color: var(--ok);
}

.player {
  width: 100%;
}

.side {
  display: grid;
  gap: 1rem;
  align-content: start;
}

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

.history {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.7rem;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem;
  color: var(--ink);
  text-decoration: none;
  display: grid;
  gap: 0.55rem;
}

.history-title {
  display: grid;
  gap: 0.2rem;
  min-height: 0;
  padding: 0;
  text-align: left;
  justify-content: stretch;
  background: transparent;
  color: var(--ink);
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.history-item span,
.history-item small {
  color: var(--muted);
  font-size: 0.82rem;
}

.hidden {
  display: none !important;
}

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

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

  .toolbar {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}

@media (max-width: 620px) {
  .topbar {
    display: none;
  }

  .shell {
    width: min(524px, calc(100% - 2rem));
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar,
  .inline-form {
    grid-template-columns: 1fr;
    display: grid;
  }

  .action-row {
    align-items: stretch;
  }

  .action-row button,
  .action-row .button {
    flex: 1 1 100%;
  }

  .segment-head {
    grid-template-columns: 1fr;
  }
}
