:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --ink: #1c2430;
  --muted: #667085;
  --line: #d9dee7;
  --panel: #ffffff;
  --green: #147d64;
  --green-strong: #0f6b55;
  --red: #b42318;
  --red-soft: #fff1f0;
  --amber: #a15c07;
  --blue-soft: #e8f0ff;
  --shadow: 0 18px 60px rgba(27, 36, 48, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, #eef3f8 0, transparent 260px),
    radial-gradient(circle at 10% 0%, rgba(20, 125, 100, 0.08), transparent 32rem),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.layout {
  width: min(1220px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  align-items: start;
  gap: 18px;
}

.workspace {
  min-width: 0;
}

.mast {
  display: flex;
  align-items: end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 18px;
}

.mast-title {
  min-width: max-content;
}

h1 {
  margin: 0;
  font-size: clamp(32px, 6vw, 54px);
  line-height: 1;
  letter-spacing: 0;
}

.product-selectors {
  width: min(496px, 100%);
  flex: 0 1 496px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 4px;
}

.product-select {
  min-width: 0;
  position: relative;
  cursor: pointer;
  user-select: none;
}

.select-shell {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 12px;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 10px;
  padding: 9px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #c8cfda;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(27, 36, 48, 0.06);
  cursor: pointer;
  text-align: left;
  user-select: none;
}

.select-icon {
  grid-row: 1 / span 2;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  overflow: hidden;
}

.openai-icon {
  color: #0f6b55;
  background: #e7f6f1;
}

.claude-icon {
  color: #b65f2b;
  background: #fbefe6;
}

.openai-icon i,
.claude-icon i {
  display: block;
  font-family: "bootstrap-icons";
  font-size: 21px;
  font-style: normal;
  font-weight: 400;
  line-height: 1;
}

.empty-icon {
  background: #edf1f5;
  border: 1px solid #d0d5dd;
}

.empty-icon::before {
  width: 12px;
  height: 12px;
  content: "";
  border: 2px solid #98a2b3;
  border-radius: 50%;
}

.flag-icon {
  width: 30px;
  height: 22px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 3px;
  overflow: hidden;
  background-color: #eef2f6;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

.select-shell .flag-icon {
  grid-row: 1 / span 2;
}

.select-option .flag-icon {
  flex: 0 0 auto;
  width: 24px;
  height: 18px;
  margin-right: 8px;
}

.flag-generic {
  border: 1px solid rgba(0, 0, 0, 0.12);
  background:
    linear-gradient(
      180deg,
      #98a2b3 0 33%,
      #ffffff 33% 66%,
      #147d64 66% 100%
    );
}

.flag-empty {
  background:
    linear-gradient(
      135deg,
      #edf1f5 0 45%,
      #c8cfda 45% 52%,
      #edf1f5 52% 100%
    );
}

.select-caption {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.1;
}

.select-value {
  min-width: 0;
  grid-column: 2;
  grid-row: 2;
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select-shell:hover {
  border-color: #98a2b3;
  background: #f9fafb;
}

.select-shell:focus-visible,
.product-select.open .select-shell {
  border-color: var(--green);
  box-shadow:
    0 10px 30px rgba(27, 36, 48, 0.06),
    0 0 0 3px rgba(20, 125, 100, 0.16);
}

.select-arrow {
  grid-column: 3;
  grid-row: 1 / span 2;
  width: 9px;
  height: 9px;
  border-right: 2px solid #667085;
  border-bottom: 2px solid #667085;
  transform: rotate(45deg) translateY(-2px);
}

.product-select.open .select-arrow {
  transform: rotate(225deg) translate(-2px, -1px);
}

.select-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: grid;
  gap: 4px;
  padding: 6px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  cursor: pointer;
  user-select: none;
}

.select-menu[hidden] {
  display: none;
}

.select-option {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  color: var(--ink);
  background: transparent;
  font-size: 15px;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
  user-select: none;
}

.select-option:hover,
.select-option:focus-visible {
  color: #0f513f;
  background: #e7f6f1;
  outline: none;
}

.select-option[aria-selected="true"] {
  color: #0f513f;
  background: #eef8f4;
}

.pass-rate {
  width: 100%;
  display: grid;
  justify-items: start;
  gap: 5px;
  padding: 12px 14px;
  color: #0f513f;
  background: #ffffff;
  border: 1px solid #b8e6d4;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.pass-rate strong {
  font-size: 28px;
  line-height: 1;
  letter-spacing: 0;
}

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

.field {
  display: grid;
  gap: 8px;
}

.field span,
.field > label,
.tile span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.card-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px;
  align-items: stretch;
  gap: 8px;
}

.card-input-row input {
  min-width: 0;
}

.paste-button {
  min-height: 52px;
  padding: 0 14px;
  white-space: nowrap;
}

input {
  width: 100%;
  min-height: 52px;
  padding: 0 14px;
  border: 1px solid #c8cfda;
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(20, 125, 100, 0.16);
}

.actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

button {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid #c8cfda;
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  font-weight: 700;
}

button:hover:not(:disabled) {
  border-color: #98a2b3;
  background: #f9fafb;
}

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

button.primary {
  color: #fff;
  border-color: var(--green-strong);
  background: var(--green);
}

button.primary:hover:not(:disabled) {
  border-color: #0a5845;
  background: var(--green-strong);
}

button.danger {
  color: var(--red);
  border-color: #ffc9c2;
  background: var(--red-soft);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.tile {
  min-height: 126px;
  display: grid;
  align-content: space-between;
  gap: 18px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tile strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 22px;
  line-height: 1.18;
  letter-spacing: 0;
}

.code-tile {
  background: var(--blue-soft);
  border-color: #c7d7fe;
}

.code-tile strong {
  font-size: 34px;
}

.notes {
  margin: 12px 0;
  padding: 16px 18px;
  color: var(--ink);
  background: #f9fbfb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.notes h2 {
  margin: 0 0 10px;
}

.notes ol,
.notes ul {
  margin: 0;
  padding-left: 22px;
}

.notes ul {
  list-style: disc outside;
}

.notes p {
  margin: 6px 0;
  color: #344054;
  line-height: 1.55;
}

.notes .notice-load-error {
  margin: 0;
  color: var(--red);
  font-weight: 700;
}

.notes li {
  padding: 3px 0;
  color: #344054;
  line-height: 1.55;
}

.notes strong {
  font-weight: 800;
}

.notes .notice-red,
.notes .notice-red a {
  color: var(--red);
}

.notes .notice-divider {
  height: 0;
  margin: 12px 0;
  border: 0;
  border-top: 1px solid #d8e2dc;
}

.notes a {
  color: var(--green-strong);
  font-weight: 800;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.notice {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  color: #513b12;
  background: #fff7e6;
  border: 1px solid #f2d088;
  overflow-wrap: anywhere;
}

.notice.error {
  color: var(--red);
  background: var(--red-soft);
  border-color: #ffc9c2;
}

.sidebar {
  position: sticky;
  top: 32px;
  display: grid;
  gap: 12px;
  margin-top: 0;
}

.help-button {
  width: 100%;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  color: var(--green-strong);
  background: #ffffff;
  border: 1px solid #b8e6d4;
  border-radius: 6px;
  box-shadow: var(--shadow);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.35;
  text-decoration: none;
}

.help-button:hover {
  border-color: var(--green);
  background: #f6fbf9;
}

.refund-button {
  color: var(--red);
  background: var(--red-soft);
  border-color: #ffc9c2;
}

.refund-button:hover {
  border-color: var(--red);
  background: #ffe5e2;
}

.frequency-panel {
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.sidebar-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.pass-rate span,
.notes h2,
.sidebar-head span,
.sidebar-head strong {
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
}

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

.frequency-row {
  display: grid;
  gap: 6px;
}

.frequency-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-weight: 800;
}

.frequency-line span {
  color: #344054;
  font-size: 14px;
}

.frequency-line strong {
  font-size: 16px;
}

.frequency-track {
  height: 8px;
  overflow: hidden;
  background: #edf1f5;
  border-radius: 999px;
}

.frequency-fill {
  height: 100%;
  background: var(--green);
  border-radius: inherit;
}

.frequency-empty {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

@media (max-width: 720px) {
  .shell {
    align-items: start;
    padding-top: 22px;
  }

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

  .mast {
    align-items: start;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 8px;
  }

  .mast-title {
    min-width: 0;
  }

  .product-selectors {
    width: 100%;
    flex: 0 0 auto;
    gap: 10px;
    margin-bottom: 0;
  }

  .workspace > .mast + .notes {
    margin-top: 0;
  }

  .pass-rate {
    width: 100%;
    justify-items: start;
  }

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

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

  .sidebar {
    position: static;
    margin-top: 0;
  }
}

@media (min-width: 721px) and (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

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

  .product-selectors {
    width: min(520px, 100%);
  }

  .sidebar {
    position: static;
    margin-top: 0;
  }
}
