:root {
  color-scheme: light;
  --bg: #eef3f7;
  --panel: #ffffff;
  --panel-soft: #f7fafc;
  --text: #18212f;
  --muted: #6b7788;
  --border: #dce5ee;
  --accent: #1677ff;
  --accent-dark: #0d5ed7;
  --danger: #e5484d;
  --danger-dark: #c9343a;
  --success: #0f9f6e;
  --shadow: 0 22px 70px rgb(39 67 96 / 0.14);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 18% 8%, rgb(22 119 255 / 0.12), transparent 30%),
    linear-gradient(180deg, #f7fbff 0%, var(--bg) 52%, #e9f0f6 100%);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

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

a {
  color: var(--accent);
  text-decoration: none;
}

.is-hidden {
  display: none !important;
}

.shell {
  width: min(100%, 960px);
  margin: 0 auto;
  padding: 34px 18px 56px;
}

.workspace {
  display: grid;
  gap: 18px;
}

.workspace.compact {
  max-width: 780px;
  margin: 0 auto;
}

.mast {
  text-align: center;
}

.mast h1 {
  margin: 0;
  font-size: clamp(34px, 7vw, 58px);
  letter-spacing: 0;
  line-height: 1;
  font-weight: 800;
}

.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 14px;
}

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

.product-select {
  position: relative;
}

.select-shell {
  width: 100%;
  min-height: 78px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgb(255 255 255 / 0.92);
  color: var(--text);
  box-shadow: 0 10px 28px rgb(42 73 102 / 0.08);
  text-align: left;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.select-shell:hover {
  border-color: rgb(22 119 255 / 0.45);
  box-shadow: 0 12px 32px rgb(42 73 102 / 0.12);
}

.select-shell::after {
  content: "";
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  margin-left: auto;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.18s ease;
}

.product-select.open .select-shell::after {
  transform: rotate(225deg) translateY(-2px);
}

.select-shell small {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 13px;
}

.select-shell strong {
  display: block;
  font-size: 17px;
  word-break: break-word;
}

.select-shell > span:not(.select-icon) {
  min-width: 0;
}

.select-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--panel-soft);
  color: var(--accent);
  font-weight: 800;
}

.openai-icon::before {
  content: "AI";
}

.claude-icon::before {
  content: "C";
}

.flag-icon::before {
  content: attr(data-flag);
}

.flag-empty::before {
  content: "";
}

.select-menu {
  position: absolute;
  z-index: 10;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: 300px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.select-option {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  text-align: left;
}

.select-option:hover,
.select-option[aria-selected="true"] {
  background: #edf5ff;
}

.notes,
.panel,
.metrics,
.records-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgb(255 255 255 / 0.95);
  box-shadow: var(--shadow);
}

.notes {
  padding: 18px 20px;
}

.notes h2,
.frequency h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.notes ol {
  margin: 0;
  padding-left: 22px;
  color: #344155;
  line-height: 1.75;
}

.notes li::marker {
  color: var(--accent);
  font-weight: 700;
}

.panel {
  padding: 18px;
}

.field label {
  display: block;
  margin-bottom: 9px;
  color: #344155;
  font-weight: 700;
}

.card-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 14px;
  color: var(--text);
  background: var(--panel-soft);
  outline: none;
}

select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 12px;
  color: var(--text);
  background: var(--panel-soft);
  outline: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgb(22 119 255 / 0.12);
}

.paste-button,
.actions button,
.help-button,
.records-head button {
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 16px;
  background: var(--panel);
  color: var(--text);
  font-weight: 700;
}

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

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

.actions .primary {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.actions .primary:hover {
  background: var(--accent-dark);
}

.actions .danger,
.refund-button,
#destroyBtn {
  border-color: var(--danger);
  background: var(--danger);
  color: white;
}

.actions button:active,
.paste-button:active,
.help-button:active,
.records-head button:active {
  transform: translateY(1px);
}

.notice {
  border-radius: 12px;
  padding: 13px 15px;
  background: #eaf7f2;
  color: #096545;
  border: 1px solid rgb(15 159 110 / 0.22);
  font-weight: 700;
}

.notice.error {
  background: #fff0f0;
  color: #a9282d;
  border-color: rgb(229 72 77 / 0.28);
}

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

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

.tile {
  min-height: 104px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgb(255 255 255 / 0.95);
  box-shadow: 0 12px 32px rgb(42 73 102 / 0.08);
}

.tile span {
  color: var(--muted);
  font-size: 14px;
}

.tile strong {
  font-size: 20px;
  word-break: break-word;
}

.code-tile strong {
  color: var(--success);
  font-size: 26px;
}

.result-tile {
  grid-column: span 1;
}

.link-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.help-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.metrics {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

.pass-rate {
  min-height: 128px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  border-radius: 14px;
  background: var(--panel-soft);
}

.pass-rate span {
  color: var(--muted);
}

.pass-rate strong {
  font-size: 34px;
  color: var(--success);
}

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

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

.frequency-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #344155;
  font-size: 14px;
}

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

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

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

.records-workspace {
  max-width: 980px;
  margin: 0 auto;
}

.records-panel {
  overflow: hidden;
}

.records-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 800;
}

.records-list {
  display: grid;
  gap: 0;
}

.records-filter {
  display: grid;
  grid-template-columns: 170px 140px minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-soft);
}

.records-filter label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.records-filter button,
.pagination button {
  min-height: 44px;
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 0 18px;
  background: var(--accent);
  color: white;
  font-weight: 800;
}

.records-summary {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 18px;
  border-top: 1px solid var(--border);
}

.pagination button:disabled {
  background: #d8e1eb;
  border-color: #d8e1eb;
  color: #6b7788;
}

.guide-page {
  max-width: 820px;
}

.guide-card {
  box-shadow: 0 12px 32px rgb(42 73 102 / 0.08);
}

.record-item {
  display: grid;
  grid-template-columns: 150px 120px 1fr;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  color: #344155;
  font-size: 14px;
}

.record-item:last-child {
  border-bottom: 0;
}

.record-action {
  font-weight: 800;
  color: var(--text);
}

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

@media (max-width: 760px) {
  .shell {
    padding: 24px 12px 40px;
  }

  .product-grid,
  .metrics,
  .actions,
  .actions.two,
  .status-grid,
  .destroy-grid {
    grid-template-columns: 1fr;
  }

  .card-input-row {
    grid-template-columns: 1fr;
  }

  .tile {
    min-height: 88px;
  }

  .record-item {
    grid-template-columns: 1fr;
  }

  .records-filter {
    grid-template-columns: 1fr;
  }

  .pagination {
    flex-wrap: wrap;
  }
}
