:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-muted: #eef3f8;
  --line: #dce4ed;
  --line-strong: #c6d2df;
  --text: #17202a;
  --muted: #637184;
  --blue: #216fc2;
  --blue-strong: #15599f;
  --green: #18845f;
  --orange: #bd6a10;
  --red: #c2413a;
  --shadow: 0 18px 40px rgba(28, 49, 74, 0.09);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

a {
  color: inherit;
  text-decoration: none;
}

svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100vh;
  padding: 28px 22px;
  background: #fbfcfe;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 34px;
  color: var(--blue);
  font-size: 26px;
  font-weight: 760;
  letter-spacing: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: var(--blue);
  color: #fff;
  font-size: 22px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: var(--radius);
  color: #33506d;
  font-weight: 650;
}

.nav-item svg {
  width: 20px;
  height: 20px;
}

.nav-item.active {
  background: var(--blue);
  color: #fff;
}

.nav-item:not(.active):hover {
  background: var(--surface-muted);
  color: var(--blue-strong);
}

.sidebar-support {
  display: grid;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.sidebar-title {
  margin: 0;
  color: #2d4257;
  font-size: 15px;
  font-weight: 800;
}

.sidebar-qr {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.sidebar-qr.dark {
  background: #202327;
  border-color: #32373e;
  color: #fff;
}

.sidebar-qr img {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
}

.sidebar-qr.dark img {
  background: #202327;
}

.sidebar-qr span {
  color: inherit;
  font-size: 14px;
  font-weight: 760;
  text-align: center;
}

.content {
  width: min(1180px, 100%);
  padding: 44px clamp(18px, 4vw, 58px) 56px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1.08;
}

h2 {
  font-size: 20px;
}

.trust-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid #b9dccf;
  border-radius: 999px;
  background: #eefaf5;
  color: var(--green);
  font-weight: 720;
  white-space: nowrap;
}

.trust-pill svg {
  width: 18px;
  height: 18px;
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(330px, 0.82fr);
  gap: 22px;
  align-items: stretch;
}

.input-panel,
.result-panel,
.ad-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.input-panel,
.result-panel,
.ad-panel {
  padding: 22px;
}

.field-group {
  display: grid;
  gap: 9px;
}

label {
  font-size: 16px;
  font-weight: 760;
}

textarea,
input[type="text"] {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  outline: none;
  color: var(--text);
  background: #fff;
}

textarea {
  min-height: 190px;
  resize: vertical;
  padding: 16px;
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, ui-monospace, monospace;
  font-size: 17px;
  line-height: 1.55;
}

input[type="text"] {
  min-height: 44px;
  padding: 10px 12px;
}

textarea:focus,
input[type="text"]:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(33, 111, 194, 0.14);
}

textarea.invalid {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(194, 65, 58, 0.12);
}

.field-help,
.status-line,
.ad-card p {
  color: var(--muted);
}

.field-help {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
}

.actions,
.result-actions {
  display: flex;
  gap: 10px;
}

.actions,
.result-actions {
  flex-wrap: wrap;
  margin-top: 18px;
}

.primary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 15px;
  border-radius: var(--radius);
  font-weight: 720;
  white-space: nowrap;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.primary-button {
  border: 1px solid var(--blue);
  background: var(--blue);
  color: #fff;
}

.primary-button:hover:not(:disabled) {
  background: var(--blue-strong);
  border-color: var(--blue-strong);
}

.ghost-button {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: #2d4257;
}

.ghost-button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.ghost-button.danger:hover {
  border-color: var(--red);
  color: var(--red);
}

.primary-button:active:not(:disabled),
.ghost-button:active:not(:disabled) {
  transform: translateY(1px);
}

.primary-button svg,
.ghost-button svg {
  width: 18px;
  height: 18px;
}

.icon-button {
  flex: 0 0 46px;
  width: 46px;
  padding: 0;
}

.wide {
  width: 100%;
}

.status-line {
  min-height: 24px;
  margin-top: 16px;
  font-size: 14px;
  line-height: 1.6;
}

.status-line.success {
  color: var(--green);
}

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

.result-panel {
  display: flex;
  flex-direction: column;
}

.result-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.timer-ring {
  position: relative;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  color: var(--blue);
  font-weight: 800;
}

.timer-ring svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-bg,
.timer-fg {
  stroke-width: 4;
}

.timer-bg {
  stroke: var(--surface-muted);
}

.timer-fg {
  stroke: currentColor;
  stroke-dasharray: 113;
  stroke-dashoffset: 113;
  transition:
    stroke-dashoffset 220ms linear,
    stroke 160ms ease;
}

.timer-ring.warning {
  color: var(--orange);
}

.timer-ring.danger {
  color: var(--red);
}

.direct-notice {
  display: none;
  margin-top: 18px;
  padding: 10px 12px;
  border: 1px solid #b9dccf;
  border-radius: var(--radius);
  background: #eefaf5;
  color: var(--green);
  font-size: 14px;
  font-weight: 700;
}

.code-display {
  display: grid;
  place-items: center;
  min-height: 150px;
  margin: 26px 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fbfdff 0%, #f2f6fa 100%);
  color: #111827;
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, ui-monospace, monospace;
  font-size: clamp(42px, 7vw, 64px);
  font-weight: 850;
  letter-spacing: 0;
  line-height: 1;
  text-align: center;
}

.code-display.ready {
  color: var(--blue-strong);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 18px;
}

.meta-row span {
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: #40586f;
  font-size: 13px;
  font-weight: 700;
}

.ad-panel {
  margin-top: 22px;
}

.section-head {
  margin-bottom: 16px;
}

.ad-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.ad-card {
  position: relative;
  display: flex;
  min-height: 170px;
  flex-direction: column;
  align-items: flex-start;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.ad-card:hover {
  border-color: var(--blue);
  box-shadow: 0 16px 32px rgba(28, 49, 74, 0.1);
  transform: translateY(-1px);
}

.ad-tag {
  display: inline-flex;
  margin-bottom: 14px;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: #40586f;
  font-size: 12px;
  font-weight: 780;
}

.ad-card strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 18px;
}

.ad-card p {
  margin: 0;
  line-height: 1.6;
}

.ad-action {
  display: inline-flex;
  margin-top: auto;
  padding-top: 16px;
  color: var(--blue);
  font-weight: 800;
}

.direct-mode .input-panel {
  display: none;
}

.direct-mode .tool-grid {
  grid-template-columns: minmax(300px, 560px);
  justify-content: center;
}

.direct-mode .direct-notice {
  display: block;
}

.direct-mode .result-panel {
  min-height: 390px;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    min-height: auto;
    padding: 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    margin-bottom: 16px;
  }

  .nav-list {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .content {
    padding-top: 28px;
  }

  .sidebar-support {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
    align-items: start;
  }

  .sidebar-title {
    grid-column: 1 / -1;
  }

  .sidebar-qr img {
    max-height: 220px;
  }

  .tool-grid,
  .ad-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar {
    display: grid;
  }

  .trust-pill {
    width: max-content;
  }

  .input-panel,
  .result-panel,
  .ad-panel {
    padding: 16px;
  }

  .result-head {
    align-items: center;
  }

  .icon-button {
    width: 100%;
  }

  .code-display {
    min-height: 120px;
  }

  .sidebar-support {
    grid-template-columns: 1fr;
  }
}
