:root {
  color-scheme: light;
  --bg: #f7f7f5;
  --text: #171717;
  --muted: #737373;
  --line: #deded8;
  --panel: #ffffff;
  --accent: #111111;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

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

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

.auth-shell {
  width: min(520px, calc(100vw - 32px));
}

.admin-shell {
  width: min(1180px, calc(100vw - 32px));
}

.top {
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.page-links a {
  display: inline-grid;
  place-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent);
  padding: 0 12px;
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}

.notice-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 10px;
}

.notice-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(255 255 255 / 42%);
  padding: 16px 18px;
  margin-bottom: 22px;
}

.notice-panel h2,
.refund-panel h2 {
  margin: 0 0 10px;
  font-size: 20px;
  line-height: 1.25;
}

.notice-title-note {
  display: inline-block;
  margin-left: 8px;
  border-radius: 6px;
  background: #fff176;
  color: #d92d20;
  padding: 3px 7px;
  font-size: 17px;
  font-weight: 750;
  line-height: 1.45;
}

.notice-list {
  margin: 0;
  padding-left: 22px;
  color: #102a4c;
  line-height: 1.9;
}

.notice-list strong {
  font-weight: 750;
}

.notice-list .notice-warning {
  font-weight: 750;
}

.notice-inline-alert {
  display: inline;
  border-radius: 6px;
  background: #fff176;
  color: #d92d20;
  padding: 2px 6px;
  font-weight: 750;
}

.inline-link {
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #00796b;
  padding: 0;
  font-weight: 750;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.notice-contact-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding-top: 12px;
}

.notice-text {
  color: #d92d20;
  font-size: 17px;
  font-weight: 650;
  line-height: 1.5;
}

.contact-thumb {
  width: 58px;
  min-width: 58px;
  height: 58px;
  min-height: 58px;
  padding: 0;
  border-color: var(--line);
  background: var(--panel);
  overflow: hidden;
}

.contact-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.notice-token-gift {
  margin: 12px 0 0;
  border-radius: 8px;
  background: #fff176;
  color: #d92d20;
  padding: 10px 12px;
  font-size: 16px;
  font-weight: 750;
  line-height: 1.55;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 6vw, 56px);
  font-weight: 700;
  letter-spacing: 0;
}

.access-key-field {
  display: grid;
  gap: 8px;
  margin-top: 24px;
  color: var(--text);
  font-size: 18px;
  font-weight: 750;
}

.access-key-field label {
  color: var(--text);
  font-size: 18px;
  font-weight: 750;
}

.access-key-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.access-key-input-wrap {
  position: relative;
  min-width: 0;
}

.access-key-row input {
  min-height: 60px;
  padding: 0 58px 0 16px;
  font-size: 22px;
  font-weight: 650;
}

.access-key-row > button {
  min-width: 108px;
  min-height: 60px;
  font-size: 20px;
  font-weight: 750;
}

.key-visibility-button {
  position: absolute;
  right: 8px;
  top: 50%;
  display: grid;
  place-items: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #555;
  padding: 0;
  font-size: 22px;
  line-height: 1;
  transform: translateY(-50%);
}

.key-visibility-button:hover,
.key-visibility-button.active {
  background: rgb(0 0 0 / 6%);
  color: var(--text);
}

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

.panel,
.result {
  border-top: 1px solid var(--line);
  padding: 24px 0;
}

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

.align-end {
  align-items: end;
  grid-template-columns: minmax(0, 1fr) auto;
}

.grow {
  min-width: 0;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 0 12px;
  outline: none;
  font-size: 16px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
}

textarea {
  min-height: 118px;
  padding: 12px;
  resize: vertical;
  line-height: 1.5;
}

select:disabled {
  color: var(--text);
  opacity: 1;
}

button {
  min-height: 48px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: white;
  padding: 0 18px;
  cursor: pointer;
}

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

.secondary,
.ghost {
  background: transparent;
  color: var(--accent);
}

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

.step-flow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.step-item {
  min-height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: #0f2f55;
  font-weight: 750;
}

.step-item.active {
  border-color: #19836a;
  background: #19836a;
  color: white;
}

.step-item.danger {
  border-color: #f5b5ae;
  background: #fff4f2;
  color: #d92d20;
}

.retry-hint {
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
}

.auth-form {
  display: grid;
  gap: 16px;
}

.admin-actions {
  grid-template-columns: repeat(3, auto);
  justify-content: start;
}

.key-editor {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 20px;
}

.editor-hint {
  margin: 0;
}

.admin-filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 12px;
  margin-top: 18px;
}

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

.summary-grid div {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.summary-grid strong {
  font-size: 28px;
}

.admin-table-wrap {
  overflow-x: auto;
  border-top: 1px solid var(--line);
  margin-top: 20px;
}

.admin-table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid var(--line);
  padding: 13px 10px;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.admin-table th {
  color: var(--muted);
  font-weight: 500;
}

.api-shell {
  width: min(1180px, calc(100vw - 32px));
}

.api-intro {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.api-actions {
  grid-template-columns: repeat(2, auto);
  justify-content: start;
  margin-top: 0;
}

.api-note {
  margin: 14px 0 0;
  color: #102a4c;
  line-height: 1.65;
}

.api-category {
  margin-top: 26px;
  border-top: 1px solid var(--line);
  padding-top: 22px;
}

.api-category h2 {
  margin: 0 0 14px;
  font-size: 22px;
}

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

.api-card {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

.api-card-header {
  display: grid;
  gap: 8px;
}

.api-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.api-card h3 {
  margin: 0;
  font-size: 18px;
}

.api-endpoint {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.api-description {
  margin: 0;
  color: #315071;
  line-height: 1.55;
}

.danger-badge {
  border-radius: 999px;
  background: #fff4f2;
  color: var(--danger);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.api-form {
  display: grid;
  gap: 12px;
}

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

.api-form textarea {
  min-height: 92px;
}

.api-card button {
  justify-self: start;
}

.api-result {
  display: block;
  min-height: 86px;
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111111;
  color: #f8f8f2;
  padding: 12px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.table-checkbox {
  width: 16px;
  min-height: 16px;
  margin: 0;
  padding: 0;
}

.danger-button {
  border-color: #f1b4ad;
  background: transparent;
  color: var(--danger);
}

.danger-text {
  color: var(--danger);
}

.refund-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(255 255 255 / 46%);
  padding: 16px 18px;
  margin-top: 18px;
}

.refund-panel[hidden] {
  display: none;
}

.refund-note {
  margin: 0 0 16px;
  color: #102a4c;
  line-height: 1.6;
}

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

.refund-message {
  min-height: 24px;
  margin: 12px 0 0;
  border: 1px solid #f5c45f;
  border-radius: 8px;
  background: #fff7e6;
  color: #7a4b00;
  padding: 10px 12px;
}

.refund-message.error {
  border-color: #f1b4ad;
  background: #fff4f2;
  color: var(--danger);
}

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

.refund-result-grid[hidden] {
  display: none;
}

.refund-result-grid div {
  min-height: 104px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

.refund-result-grid span {
  display: block;
  color: #315071;
  font-size: 13px;
  margin-bottom: 20px;
}

.refund-result-grid strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 24px;
  line-height: 1.12;
}

.result {
  display: grid;
  gap: 22px;
}

.label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
}

.copy-line,
.code-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.copy-line strong,
.code-line strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 28px;
  font-weight: 650;
}

.code-line strong {
  font-size: 44px;
  letter-spacing: 0.06em;
}

.text-button {
  min-height: 34px;
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0;
}

.status {
  min-height: 24px;
  margin: 0;
}

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

.image-modal[hidden] {
  display: none;
}

.message-modal[hidden] {
  display: none;
}

.message-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
}

.message-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(0 0 0 / 48%);
}

.message-modal-panel {
  position: relative;
  z-index: 1;
  width: min(92vw, 480px);
  border-radius: 8px;
  background: var(--panel);
  padding: 22px;
  box-shadow: 0 18px 50px rgb(0 0 0 / 18%);
}

.message-modal-panel h2 {
  margin: 0 0 12px;
  font-size: 22px;
}

.message-modal-panel p {
  margin: 0;
  color: #102a4c;
  font-size: 18px;
  font-weight: 650;
  line-height: 1.7;
  white-space: pre-line;
}

.message-modal-action {
  width: 100%;
  margin-top: 18px;
}

.message-modal-close {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 999px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
}

.image-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(0 0 0 / 58%);
}

.image-modal-panel {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
  width: min(92vw, 420px);
  max-height: 90vh;
}

.image-modal-panel img {
  display: block;
  width: 100%;
  max-height: 78vh;
  object-fit: contain;
  border-radius: 10px;
  background: white;
}

.image-modal-close {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 999px;
}

.image-modal-download {
  display: grid;
  place-items: center;
  min-height: 44px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  text-decoration: none;
}

.modal-open {
  overflow: hidden;
}

@media (max-width: 640px) {
  .shell {
    width: min(100vw - 24px, 760px);
    padding: 26px 0 calc(28px + env(safe-area-inset-bottom));
  }

  .auth-shell {
    width: min(100vw - 24px, 520px);
  }

  .admin-shell {
    width: min(100vw - 24px, 1180px);
  }

  .top {
    margin-bottom: 22px;
  }

  h1 {
    font-size: 40px;
    line-height: 1.05;
  }

  .notice-row,
  .notice-contact-row {
    align-items: flex-start;
  }

  .notice-text {
    flex: 1 1 220px;
    font-size: 17px;
  }

  .contact-thumb {
    width: 64px;
    min-width: 64px;
    height: 64px;
    min-height: 64px;
  }

  .row,
  .align-end,
  .access-key-row {
    grid-template-columns: 1fr;
  }

  .notice-panel,
  .refund-panel {
    padding: 14px;
  }

  .notice-list {
    padding-left: 20px;
    line-height: 1.75;
  }

  .panel,
  .result {
    padding: 20px 0;
  }

  .actions,
  .step-flow,
  .refund-actions,
  .refund-result-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .admin-actions,
  .admin-filter-row,
  .api-intro,
  .api-actions,
  .api-grid,
  .api-param-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .actions button,
  input,
  select,
  textarea {
    width: 100%;
    min-height: 52px;
  }

  .table-checkbox {
    width: 16px;
    min-height: 16px;
  }

  .copy-line,
  .code-line {
    align-items: flex-start;
  }

  .copy-line strong {
    font-size: 24px;
  }

  .code-line strong {
    font-size: 36px;
    line-height: 1.15;
  }
}
