:root {
  color-scheme: light;
  --page: #f7f7f4;
  --surface: #ffffff;
  --soft: #fbfbf8;
  --ink: #151515;
  --muted: #686f6c;
  --line: #e2e0d8;
  --line-strong: #c7c2b7;
  --navy: #111111;
  --navy-dark: #050505;
  --teal: #222222;
  --teal-soft: #f1f0ea;
  --gold: #f3dc19;
  --gold-soft: #fff5d9;
  --red: #b42318;
  --blue: #2457c5;
  --blue-soft: #eef4ff;
  --green: #12805c;
  --green-soft: #eaf8f2;
  --shadow: 0 18px 42px rgba(15, 35, 55, 0.09);
  --shadow-soft: 0 10px 28px rgba(15, 35, 55, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top left, rgba(243, 220, 25, 0.24), transparent 30rem),
    linear-gradient(180deg, #ffffff 0%, #f8f8f4 46%, var(--page) 100%);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

button,
textarea,
input {
  font: inherit;
}

.app-shell {
  width: min(1400px, calc(100vw - 48px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 0 28px;
  display: grid;
  align-content: start;
  gap: 16px;
}

.topbar,
.topbar-title,
.topbar-actions,
.notice-panel,
.login-panel,
.login-form,
.workspace-head,
.panel-head,
.result-head,
.run-panel,
.run-actions,
.dialog-head,
.icon-text-button,
.chat-link {
  display: flex;
  align-items: center;
}

.topbar,
.workspace-head,
.panel-head,
.result-head,
.run-panel,
.dialog-head {
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  padding: 4px 0 6px;
}

.topbar-title,
.topbar-actions,
.notice-panel,
.login-form {
  gap: 10px;
}

.brand-logo {
  width: 58px;
  height: 58px;
  object-fit: contain;
  flex: 0 0 auto;
}

.notice-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--teal-soft);
  color: var(--teal);
}

.notice-icon svg,
button svg,
.chat-link svg,
.file-zone svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.45rem, 2vw, 2rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 1rem;
  line-height: 1.18;
  letter-spacing: 0;
}

.topbar-title p,
.notice-panel p,
.login-panel p,
.dialog-head p,
.run-copy span,
.result-meta,
.file-zone small,
.work-item span,
.work-meta,
.empty-state {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.38;
}

.notice-panel,
.login-panel,
.workspace-panel,
.run-panel,
.result-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-soft);
}

.notice-panel {
  padding: 14px 18px;
  background: linear-gradient(90deg, #fff 0%, #fffdf0 100%);
}

.notice-panel > div:last-child {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(380px, 1fr) minmax(320px, auto);
  align-items: center;
  column-gap: 12px;
  row-gap: 4px;
  width: 100%;
}

.notice-panel h2 {
  color: var(--ink);
  white-space: nowrap;
}

.notice-panel p:not(.notice-warning) {
  max-width: 760px;
}

.notice-warning {
  grid-column: auto;
  justify-self: end;
  max-width: 390px;
  color: #5d625f;
}

.step-tag {
  display: inline-flex;
  margin-bottom: 3px;
  color: var(--blue);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.service-pill,
.status-badge,
.file-counter {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
  white-space: nowrap;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
}

.service-pill.ready .dot {
  background: var(--teal);
}

.service-pill.error .dot {
  background: var(--red);
}

.login-panel {
  width: min(860px, 100%);
  margin: 4px auto 2px;
  padding: 20px;
  display: grid;
  grid-template-columns: 150px minmax(180px, 0.8fr) minmax(360px, 1.45fr);
  gap: 20px;
  align-items: center;
}

.login-brand {
  display: grid;
  place-items: center;
  min-height: 138px;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.login-brand img {
  width: 126px;
  height: auto;
  display: block;
}

.login-copy {
  min-width: 0;
}

.login-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.field {
  min-width: 0;
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-weight: 850;
  font-size: 0.86rem;
}

.field input,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.field input {
  min-height: 40px;
  min-width: 0;
  padding: 0 11px;
}

.field input:focus,
textarea:focus {
  border-color: var(--teal);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(8, 123, 136, 0.13);
}

.form-message {
  grid-column: 1 / -1;
  min-height: 20px;
  color: var(--red);
  font-size: 0.86rem;
  font-weight: 800;
}

.review-form {
  display: grid;
  grid-template-columns: minmax(640px, 1.28fr) minmax(430px, 0.72fr);
  grid-template-rows: minmax(390px, 46vh) auto;
  gap: 14px;
}

.workspace-panel {
  min-height: 0;
  padding: 16px;
  display: grid;
  gap: 14px;
  position: relative;
  overflow: hidden;
}

.workspace-panel::before,
.result-panel::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--gold), #ffef66);
}

.submission-area::before,
#step2Panel::before {
  background: linear-gradient(180deg, var(--blue), #6e94ff);
}

.run-panel {
  grid-column: 1 / -1;
  min-height: 64px;
  padding: 12px 16px;
}

.work-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(250px, 0.82fr) minmax(360px, 1.18fr);
  gap: 12px;
}

.input-panel {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  position: relative;
}

.work-list,
.work-detail,
.answer,
.file-list {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.work-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 8px;
}

.work-item {
  min-height: 66px;
  width: 100%;
  display: grid;
  gap: 5px;
  justify-items: start;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  padding: 11px 12px;
  overflow: hidden;
}

.work-item.active {
  border-color: #d6c24d;
  background: linear-gradient(180deg, #fff9bd, #fffef2);
  box-shadow: inset 3px 0 0 var(--gold);
}

.work-item strong,
.work-item span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.work-item strong {
  font-size: 1rem;
  white-space: nowrap;
}

.work-item span {
  display: block;
  white-space: nowrap;
}

.work-detail {
  min-height: 0;
  overflow: auto;
  border: 1px solid #e4eeec;
  border-radius: 10px;
  background: linear-gradient(180deg, #ffffff, #fbfbf8);
  padding: 16px;
  line-height: 1.58;
  font-size: 0.96rem;
}

.guide-list {
  margin: 10px 0 0;
  padding-left: 1.1rem;
}

.submission-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(190px, 0.78fr);
  gap: 12px;
}

.upload-stack {
  min-height: 0;
  display: grid;
  grid-template-rows: 128px minmax(0, 1fr);
  gap: 12px;
}

textarea {
  width: 100%;
  min-height: 0;
  height: 100%;
  resize: none;
  padding: 16px;
  line-height: 1.5;
  font-size: 1rem;
}

.url-textarea {
  font-size: 0.84rem;
}

.file-zone {
  min-height: 0;
  display: grid;
  place-items: center;
  gap: 4px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: linear-gradient(180deg, var(--blue-soft), #ffffff);
  color: var(--ink);
  cursor: pointer;
  text-align: center;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.file-zone:hover,
.file-zone.dragging {
  border-color: var(--blue);
  background: var(--blue-soft);
  transform: translateY(-1px);
}

.file-zone span {
  font-weight: 900;
  font-size: 1rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.file-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.file-list:empty {
  display: none;
}

.file-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 11px;
  border: 1px solid #e4eeec;
  border-radius: 10px;
  background: linear-gradient(90deg, #fffdf0, #fff);
  color: var(--muted);
  font-size: 0.82rem;
}

.file-list b {
  color: var(--ink);
  font-weight: 800;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.run-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.run-actions {
  justify-content: flex-end;
  gap: 8px;
}

button,
.chat-link {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 0 12px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

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

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

.icon-text-button,
.chat-link {
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
}

.primary-button {
  background: linear-gradient(135deg, #111, #333);
  color: white;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.15);
}

.primary-button:hover:not(:disabled) {
  background: linear-gradient(135deg, #000, #333);
}

.secondary-button {
  border-color: var(--line);
  background: white;
  color: var(--ink);
}

.secondary-button:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: #fffdf0;
}

.icon-button {
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  background: white;
  color: var(--navy);
}

.results-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.result-panel {
  min-height: 280px;
  display: grid;
  grid-template-rows: auto 26px minmax(170px, 1fr);
  padding: 16px;
}

.result-meta {
  min-height: 20px;
  padding-top: 6px;
}

.status-badge.waiting {
  color: var(--muted);
}

.status-badge.running {
  color: #8b5e00;
  border-color: #f0d56b;
  background: linear-gradient(180deg, #fff7cf, #fffdf0);
}

.status-badge.done {
  color: var(--green);
  border-color: #dfd582;
  background: var(--green-soft);
}

.status-badge.error {
  color: var(--red);
  border-color: rgba(180, 35, 24, 0.25);
  background: #fff1f2;
}

.answer {
  min-height: 0;
  overflow: auto;
  overflow-wrap: anywhere;
  border: 1px solid #e4eeec;
  border-radius: 10px;
  background: linear-gradient(180deg, #ffffff, #fbfbf8);
  color: var(--ink);
  padding: 16px;
  line-height: 1.54;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 0.94rem;
}

.answer:empty::before {
  content: "Sin resultado todavia.";
  color: #738489;
}

.gpt-answer h1,
.gpt-answer h2,
.gpt-answer h3,
.gpt-answer h4 {
  margin: 0.8em 0 0.35em;
  line-height: 1.22;
}

.gpt-answer h1:first-child,
.gpt-answer h2:first-child,
.gpt-answer h3:first-child,
.gpt-answer p:first-child,
.gpt-answer ul:first-child,
.gpt-answer ol:first-child {
  margin-top: 0;
}

.gpt-answer p {
  margin: 0.58em 0;
}

.gpt-answer strong,
.gpt-answer b {
  font-weight: 900;
}

.gpt-answer ul,
.gpt-answer ol {
  margin: 0.58em 0;
  padding-left: 1.25rem;
}

.gpt-answer li {
  margin: 0.22em 0;
}

.gpt-answer blockquote {
  margin: 0.7em 0;
  padding: 0.2em 0 0.2em 0.9em;
  border-left: 3px solid var(--line-strong);
  color: #465b50;
}

.gpt-answer table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.8em 0;
  font-size: 0.86rem;
}

.gpt-answer th,
.gpt-answer td {
  border: 1px solid var(--line);
  padding: 7px 9px;
  text-align: left;
  vertical-align: top;
}

.gpt-answer th {
  background: #edf8f7;
  font-weight: 900;
}

.gpt-answer pre {
  overflow: auto;
  border-radius: 8px;
  background: var(--navy-dark);
  color: #f8fafc;
  padding: 10px;
}

.gpt-answer code {
  border-radius: 5px;
  background: #e8f4f4;
  padding: 0.1em 0.35em;
  font-family: "Cascadia Mono", Consolas, "Segoe UI Mono", monospace;
  font-size: 0.9em;
}

.gpt-answer pre code {
  background: transparent;
  padding: 0;
}

.gpt-answer a {
  color: var(--teal);
  font-weight: 850;
}

.chat-link {
  position: fixed;
  right: 16px;
  bottom: 16px;
  min-height: 40px;
  text-decoration: none;
  border-color: var(--line);
  background: #fff;
  color: var(--navy);
  box-shadow: var(--shadow);
}

.run-panel:has(.run-copy strong) {
  border-left: 4px solid var(--gold);
}

.run-panel .run-copy strong {
  color: var(--ink);
}

#runTitle {
  font-size: 1.02rem;
}

#runStatus {
  color: var(--muted);
}

.result-panel {
  position: relative;
  overflow: hidden;
}

#step1Panel .step-tag {
  color: var(--red);
}

#step2Panel .step-tag {
  color: var(--blue);
}

.help-dialog {
  width: min(760px, calc(100vw - 28px));
  max-height: min(720px, calc(100vh - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  box-shadow: var(--shadow);
  padding: 16px;
}

.help-dialog::backdrop {
  background: rgba(15, 35, 55, 0.46);
}

.help-content {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  color: #34483d;
  line-height: 1.55;
}

.help-content section,
.help-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--soft);
}

.help-content dl {
  margin: 10px 0 0;
  border-top: 1px solid var(--line);
}

.help-content dt {
  padding-top: 10px;
  font-weight: 900;
}

.help-content dd {
  margin: 4px 0 10px;
}

.hidden {
  display: none !important;
}

@media (max-width: 1180px) {
  .app-shell {
    width: min(100vw - 32px, 1080px);
  }

  .review-form {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  .run-panel {
    grid-column: auto;
  }
}

@media (max-width: 980px) {
  .app-shell {
    width: min(100vw - 24px, 760px);
    padding: 14px 0 22px;
  }

  .login-panel,
  .work-layout,
  .submission-grid,
  .results-grid {
    grid-template-columns: 1fr;
  }

  .workspace-panel {
    min-height: auto;
  }

  .result-panel {
    min-height: 240px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 18px, 480px);
    padding: 10px 0 18px;
    gap: 10px;
  }

  .topbar,
  .topbar-actions,
  .notice-panel,
  .workspace-head,
  .panel-head,
  .result-head,
  .run-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-title {
    align-items: center;
  }

  .brand-logo {
    width: 52px;
    height: 52px;
  }

  .notice-panel > div:last-child {
    grid-template-columns: 1fr;
  }

  .notice-warning {
    grid-column: auto;
    justify-self: start;
    max-width: none;
  }

  .login-panel {
    padding: 14px;
    gap: 12px;
  }

  .login-brand {
    min-height: 118px;
  }

  .login-brand img {
    width: 116px;
  }

  .run-actions,
  .topbar-actions {
    width: 100%;
  }

  .run-actions button,
  .topbar-actions button,
  .service-pill,
  .file-counter,
  .status-badge {
    width: 100%;
  }

  .upload-stack {
    grid-template-rows: 118px minmax(0, 1fr);
  }
}
