:root {
  --bg: #eef5ff;
  --bg-deep: #dfeeff;
  --card: #ffffff;
  --text: #172033;
  --muted: #6a7485;
  --line: #e2e8f0;
  --blue: #1677ff;
  --blue-deep: #0f5fd6;
  --green: #19b47b;
  --orange: #ff9f1a;
  --red: #ef4444;
  --shadow: 0 12px 30px rgba(35, 73, 125, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 0%, rgba(22, 119, 255, 0.14), transparent 34%),
    linear-gradient(180deg, var(--bg), #f8fbff 48%, #f4f7fb);
  font-family: "PingFang SC", "PingFang TC", "PingFang HK", sans-serif;
  font-size: 15px;
  line-height: 1.58;
}

body,
button,
input,
textarea,
select {
  font-family: "PingFang SC", "PingFang TC", "PingFang HK", sans-serif;
}

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

button,
input,
textarea {
  font: inherit;
}

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

.app-shell {
  width: min(100% - 24px, 520px);
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 0 max(18px, env(safe-area-inset-bottom));
}

.app-header {
  display: grid;
  gap: 12px;
  padding: 4px 0 12px;
  text-align: center;
}

.brand-line {
  width: fit-content;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  justify-self: center;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 24px rgba(22, 119, 255, 0.08);
  backdrop-filter: blur(10px);
}

.brand-line img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
}

.brand-line div {
  min-width: 0;
  text-align: left;
}

.brand-line p {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
}

.brand-line span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

h1 {
  margin: 2px 0 0;
  font-size: 32px;
  line-height: 1.15;
  font-weight: 900;
}

.header-desc {
  max-width: 330px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 14px;
}

.hero-image {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.hero-image img {
  width: 100%;
  height: auto;
  display: block;
}

main {
  display: grid;
  gap: 16px;
}

.parser-section,
.coupon-section {
  display: grid;
  gap: 10px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px;
  text-align: left;
}

.title-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.title-mark {
  width: 6px;
  height: 38px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffb43b, var(--orange));
  box-shadow: 0 6px 14px rgba(255, 159, 26, 0.28);
  flex: 0 0 auto;
}

.title-mark.blue {
  background: linear-gradient(180deg, #3b95ff, var(--blue));
  box-shadow: 0 6px 14px rgba(22, 119, 255, 0.24);
}

.section-title p {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.section-title h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.15;
  font-weight: 900;
}

.help-btn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  color: #0f5fd6;
  background: rgba(255, 255, 255, 0.58);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 18px rgba(35, 73, 125, 0.12);
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
}

.help-btn[aria-expanded="true"] {
  color: white;
  background: rgba(22, 119, 255, 0.88);
  border-color: var(--blue);
}

.help-panel {
  margin-top: -2px;
  padding: 11px 13px;
  border: 1px solid #dcecff;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #f7fbff, #eef6ff);
  color: #3b4a60;
  box-shadow: 0 8px 20px rgba(35, 73, 125, 0.07);
  font-size: 13px;
}

.help-panel ol {
  margin: 0;
  padding-left: 19px;
}

.help-panel li + li {
  margin-top: 4px;
}

.parser-card,
.category-card,
.loading-card,
.empty-card,
.error-card {
  border: 1px solid rgba(226, 232, 240, 0.96);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.parser-card {
  padding: 14px;
}

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

textarea,
input[type="search"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdff;
  color: var(--text);
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

textarea {
  min-height: 88px;
  padding: 11px 12px;
  resize: vertical;
}

input[type="search"] {
  height: 46px;
  padding: 0 12px;
}

textarea:focus,
input[type="search"]:focus {
  border-color: rgba(22, 119, 255, 0.58);
  background: white;
  box-shadow: 0 0 0 4px rgba(22, 119, 255, 0.1);
}

.status-line {
  min-height: 23px;
  margin: 8px 0 11px;
  color: var(--muted);
  font-size: 13px;
}

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

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

.button-row {
  display: grid;
  grid-template-columns: 0.82fr 1.28fr 0.82fr;
  gap: 9px;
}

.button {
  min-height: 45px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--radius);
  padding: 10px 12px;
  font-weight: 800;
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.16s ease, filter 0.16s ease, opacity 0.16s ease;
}

.button:active {
  transform: scale(0.985);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.button-primary {
  color: white;
  background: linear-gradient(135deg, var(--blue), var(--blue-deep));
  box-shadow: 0 9px 18px rgba(22, 119, 255, 0.22);
}

.button-soft {
  color: #0f5fd6;
  background: #eaf3ff;
}

.button-secondary {
  color: white;
  background: linear-gradient(135deg, var(--green), #0f9f6e);
  box-shadow: 0 9px 18px rgba(25, 180, 123, 0.18);
}

.button-ghost {
  color: #42526a;
  background: #f4f7fb;
}

.button-home {
  width: 100%;
  margin-top: 10px;
  color: white;
  background: linear-gradient(135deg, var(--green), #0f9f6e);
  box-shadow: 0 9px 18px rgba(25, 180, 123, 0.2);
}

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

.category-card {
  overflow: hidden;
}

.category-toggle {
  width: 100%;
  min-height: 56px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20px;
  align-items: center;
  gap: 8px;
  border: 0;
  background: white;
  color: var(--text);
  padding: 13px 13px;
  text-align: left;
  cursor: pointer;
}

.category-toggle:active {
  background: #f8fbff;
}

.category-title {
  min-width: 0;
  display: grid;
  grid-template-columns: 6px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
}

.category-mark {
  width: 6px;
  height: 27px;
  border-radius: 999px;
  background: var(--orange);
}

.category-name {
  min-width: 0;
  font-size: 16px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.category-count {
  padding: 2px 7px;
  border-radius: 999px;
  background: #eef5ff;
  color: #43627f;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.chevron {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #f2f7fd;
  transition: transform 0.18s ease;
}

.chevron::before {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.8px solid #7f8ea3;
  border-bottom: 1.8px solid #7f8ea3;
  transform: translateY(-2px) rotate(45deg);
}

.category-card.is-open .chevron {
  transform: rotate(180deg);
}

.coupon-items {
  display: none;
  gap: 9px;
  padding: 10px 11px 11px;
  border-top: 1px solid var(--line);
}

.category-card.is-open .coupon-items {
  display: grid;
}

.coupon-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 12px;
  border: 1px solid #e5edf6;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fbfdff, #f6faff);
}

.coupon-title {
  grid-column: 1;
  margin: 0;
  color: #213047;
  font-size: 15px;
  line-height: 1.4;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.coupon-note {
  grid-column: 1;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.coupon-actions {
  grid-column: 2;
  grid-row: 1 / span 2;
  justify-self: end;
  align-self: center;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.coupon-actions .button {
  min-height: 34px;
  width: auto;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: none;
  white-space: nowrap;
}

.coupon-actions .button-primary {
  background: #1677ff;
}

.coupon-actions .button-secondary {
  background: #19b47b;
}

.coupon-actions .button:only-child {
  min-width: 86px;
}

.loading-card,
.empty-card,
.error-card {
  padding: 22px 14px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.site-footer {
  display: flex;
  justify-content: center;
  gap: 8px 14px;
  flex-wrap: wrap;
  padding: 22px 0 8px;
  color: #8a95a6;
  font-size: 12px;
}

.site-footer a {
  color: #6c7a8e;
}

.toast {
  position: fixed;
  right: 12px;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 12px;
  z-index: 50;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: rgba(18, 25, 38, 0.94);
  color: white;
  box-shadow: 0 12px 30px rgba(18, 25, 38, 0.22);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (min-width: 780px) {
  .app-shell {
    width: min(100% - 56px, 760px);
    padding-top: 24px;
  }

  .app-header {
    gap: 14px;
  }

  h1 {
    font-size: 42px;
  }

  .header-desc {
    max-width: 520px;
    font-size: 16px;
  }

  .parser-card {
    padding: 18px;
  }

  .button:hover {
    filter: brightness(0.98);
  }

  .toast {
    right: auto;
    bottom: auto;
    top: 18px;
    left: 50%;
    width: min(520px, calc(100% - 32px));
    transform: translate(-50%, -10px);
  }

  .toast.is-visible {
    transform: translate(-50%, 0);
  }
}
