:root {
  --ink: #202123;
  --muted: #6e6e80;
  --line: #e5e5e5;
  --paper: #f7f7f8;
  --panel: #ffffff;
  --soft: #f1f1f2;
  --accent: #10a37f;
  --accent-strong: #0e8f70;
  --warn: #9a6a12;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.login-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(247, 247, 248, 0.94);
  backdrop-filter: blur(18px);
}

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

.login-box {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
}

.login-brand {
  margin-bottom: 6px;
}

.topbar {
  min-height: 68px;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 247, 248, 0.88);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand,
.top-actions,
.prompt-row,
.task-top,
.task-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  min-width: 0;
}

.mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 850;
}

.brand strong {
  display: block;
  line-height: 1.1;
}

.brand p,
.hero-copy p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

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

.credit-pill {
  min-height: 34px;
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  white-space: nowrap;
}

.credit-pill span {
  font-weight: 850;
}

.credit-pill small {
  color: var(--muted);
  font-size: 12px;
}

.user-pill {
  max-width: 220px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e8f5f0;
  color: #087058;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge.running,
.badge.queued {
  background: #fff5dd;
  color: var(--warn);
}

.badge.failed,
.badge.expired,
.badge.cancelled {
  background: #fde8e7;
  color: var(--danger);
}

.ghost-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

.primary-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.primary-button:disabled,
.ghost-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.hero {
  width: min(900px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 92px 0 34px;
  display: grid;
  gap: 26px;
  align-content: center;
}

.hero-copy {
  text-align: center;
}

.hero-copy h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1.1;
  letter-spacing: 0;
  font-weight: 760;
}

.prompt-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 10px;
}

.prompt-row {
  gap: 8px;
}

.quick-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 6px 2px;
}

.estimate-label {
  margin: 2px 8px 4px;
  color: var(--muted);
  font-size: 12px;
}

.chip {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #52525d;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 750;
}

.chip:hover {
  border-color: #c9c9d0;
  background: #fafafa;
}

.chip.is-active {
  border-color: #b9e0d4;
  background: #e8f5f0;
  color: #087058;
}

#prompt {
  flex: 1;
  min-width: 0;
  height: 52px;
  border: 0;
  outline: 0;
  border-radius: 12px;
  padding: 0 10px;
  color: var(--ink);
  background: transparent;
}

#prompt::placeholder {
  color: #9a9aa3;
}

.round-button,
.send-button {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 850;
}

.round-button {
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--ink);
}

.round-button.is-open {
  background: #e8f5f0;
  color: #087058;
  border-color: #b9e0d4;
}

.send-button {
  border: 0;
  background: var(--ink);
  color: #fff;
  font-size: 20px;
  line-height: 1;
}

.send-button:hover {
  background: #000;
}

.send-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.custom-panel {
  border-top: 1px solid var(--line);
  margin-top: 10px;
  padding-top: 14px;
}

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

label {
  display: grid;
  gap: 7px;
  color: #4a4a55;
  font-size: 12px;
  font-weight: 750;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

input:focus,
select:focus {
  outline: 3px solid rgba(16, 163, 127, 0.18);
  border-color: var(--accent);
}

.toggle {
  grid-template-columns: auto 1fr;
  align-items: center;
  align-content: end;
}

.toggle input {
  width: 18px;
  height: 18px;
  min-height: 0;
}

.file-control {
  grid-column: span 2;
}

.history {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto 56px;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-kicker {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.section-head h2 {
  margin: 3px 0 0;
  font-size: 20px;
  letter-spacing: 0;
}

.task-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.empty {
  margin: 0;
  color: var(--muted);
  padding: 20px;
  border: 1px dashed #d7d7dc;
  border-radius: 12px;
  background: #fff;
  text-align: center;
}

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

.task-top,
.task-actions {
  justify-content: space-between;
  gap: 12px;
}

time {
  color: var(--muted);
  font-size: 12px;
}

.task-prompt {
  margin: 0;
  line-height: 1.45;
  color: #303038;
}

.task-cost {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin: 0;
}

dt {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 800;
}

dd {
  margin: 2px 0 0;
  font-size: 13px;
  overflow-wrap: anywhere;
}

video {
  display: none;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #101014;
  border-radius: 8px;
}

.task-card.has-video video {
  display: block;
}

.error {
  display: none;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.task-card.has-error .error {
  display: block;
}

.video-link {
  display: none;
  color: var(--accent-strong);
  font-weight: 800;
}

.task-card.has-video .video-link {
  display: inline-flex;
}

.delete-button {
  border: 1px solid #efc5c1;
  color: var(--danger);
  background: #fff;
  border-radius: 8px;
  padding: 8px 10px;
}

.buy-dialog {
  width: min(520px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0;
  box-shadow: var(--shadow);
}

.buy-dialog::backdrop {
  background: rgba(0, 0, 0, 0.28);
}

.buy-dialog form {
  padding: 18px;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.dialog-head strong {
  display: block;
  font-size: 18px;
}

.dialog-head p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.package-list {
  display: grid;
  gap: 10px;
}

.wallet-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafafa;
}

.wallet-panel p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

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

.package-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  text-align: left;
}

.package-card:hover {
  border-color: #b9e0d4;
  background: #f6fbf9;
}

.package-card strong {
  display: block;
}

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

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

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }

  .hero {
    padding-top: 58px;
  }

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

@media (max-width: 560px) {
  .brand p,
  .top-actions > .ghost-button {
    display: none;
  }

  .hero-copy h1 {
    font-size: 30px;
  }

  .prompt-card {
    border-radius: 14px;
  }

  .quick-toggles {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
  }

  .chip {
    white-space: nowrap;
  }

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

  .file-control {
    grid-column: span 1;
  }
}
