:root {
  color-scheme: light;
  --ink: #16243a;
  --muted: #627189;
  --line: #d8e1ed;
  --surface: #ffffff;
  --page: #f3f6fb;
  --primary: #3379f6;
  --primary-dark: #1f56bc;
  --platform-accent: #2771ef;
  --normal: #12a33a;
  --normal-soft: #e9f8ed;
  --abnormal: #f22935;
  --abnormal-soft: #fff0f0;
  --unknown: #8191aa;
  --unknown-soft: #f0f2f5;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 0;
  background: var(--page);
  color: var(--ink);
}

button, textarea { font: inherit; }

.page-shell {
  width: min(1440px, calc(100% - 24px));
  margin: 0 auto;
  padding: 12px 0 38px;
}

.tool-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 122px;
  padding: 22px 26px;
  border-radius: 18px;
  background: linear-gradient(118deg, #214e9e 0%, #346af1 58%, #159bd0 100%);
  color: #fff;
  box-shadow: 0 14px 34px rgba(32, 79, 166, 0.2);
}

.hero-copy { min-width: 0; }
.eyebrow {
  margin: 0 0 6px;
  color: #b8ffed;
  font-size: 12px;
  font-weight: 800;
}
.eyebrow span { margin-right: 5px; }
h1 { margin: 0; font-size: clamp(25px, 3vw, 34px); letter-spacing: -0.025em; }
.subtitle { margin: 7px 0 0; color: rgba(255, 255, 255, 0.92); font-size: 14px; }

.privacy-note {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 520px;
  padding: 13px 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  background: rgba(8, 63, 136, 0.38);
  color: rgba(255, 255, 255, 0.95);
  font-size: 12px;
  line-height: 1.5;
}
.privacy-note strong { color: #b8ffed; }
.privacy-icon { color: #68f3cf; }

.platform-tabs {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 16px 0 24px;
  padding: 8px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(43, 65, 100, 0.06);
  scrollbar-width: thin;
}

.platform-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 9px 13px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #4d5d72;
  white-space: nowrap;
  cursor: pointer;
}
.platform-tab small {
  padding: 2px 5px;
  border-radius: 99px;
  background: #eef2f7;
  color: #8a96a7;
  font-size: 10px;
}
.platform-tab:disabled { cursor: not-allowed; opacity: 0.72; }
.platform-tab:hover:not(:disabled):not(.is-active) { background: #f4f7fb; color: #253b5a; }
.platform-tab.is-active {
  background: var(--platform-accent);
  color: #fff;
  box-shadow: 0 5px 13px rgba(45, 119, 245, 0.3);
}

.platform-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 7px;
  background: #eef2f7;
  color: #26364c;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
}
.is-active .platform-icon { background: rgba(255, 255, 255, 0.2); color: #fff; }
.icon-facebook { color: #1877f2; }
.icon-instagram { color: #d6249f; }
.icon-threads { color: #111; }
.icon-tiktok { color: #0f172a; }

.workspace-card {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 14px 38px rgba(45, 62, 88, 0.07);
}

.section-heading,
.platform-heading,
.result-title,
.toolbar,
.split-actions {
  display: flex;
  align-items: center;
}

.section-heading { justify-content: space-between; gap: 20px; margin-bottom: 13px; }
.platform-heading { gap: 9px; }
.platform-heading .platform-icon { background: var(--platform-accent); color: #fff; }
.section-heading h2, .result-title h2 { margin: 0; font-size: 17px; }
.section-heading p { max-width: 900px; margin: 7px 0 0; color: var(--muted); font-size: 14px; line-height: 1.55; }

.line-counter {
  display: flex;
  align-items: baseline;
  gap: 4px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #edf3fc;
  color: #45607f;
}
.line-counter strong { color: #1d57bd; font-size: 18px; }
.line-counter.over-limit, .line-counter.over-limit strong { color: #c51e2b; background: #ffeded; }

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  line-height: 1.55;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
textarea:focus { border-color: #5d8ee5; box-shadow: 0 0 0 3px rgba(65, 124, 226, 0.13); }
.account-input { min-height: 170px; padding: 13px 15px; }
.input-help { margin: 7px 0 0; color: #53657d; font-size: 13px; }

.toolbar { gap: 10px; margin-top: 16px; }
.button {
  min-height: 40px;
  padding: 8px 17px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-weight: 700;
  transition: transform 100ms ease, opacity 100ms ease, background 100ms ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: 0.48; }
.button-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 14px rgba(51, 121, 246, 0.2); }
.button-primary:hover:not(:disabled) { background: var(--primary-dark); }
.button-secondary { border-color: #cbd5e1; color: #526174; }

.progress-wrap {
  display: grid;
  grid-template-columns: minmax(120px, 260px) auto;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
}
.progress-track { height: 7px; overflow: hidden; border-radius: 99px; background: #e6ebf2; }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #2e74e8, #59a2fa); transition: width 180ms ease; }
.notice { min-height: 22px; margin: 10px 0 -4px; color: #46617e; font-size: 13px; }
.notice.error { color: #c51e2b; }
.notice.success { color: #087c28; }

.service-error-dialog {
  width: min(430px, calc(100% - 28px));
  padding: 26px;
  border: 0;
  border-radius: 18px;
  color: var(--ink);
  text-align: center;
  box-shadow: 0 28px 80px rgba(13, 31, 61, 0.3);
}
.service-error-dialog::backdrop { background: rgba(20, 32, 52, 0.52); backdrop-filter: blur(2px); }
.service-error-symbol {
  display: grid;
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  place-items: center;
  border-radius: 50%;
  background: #fff0f1;
  color: #d52332;
  font-size: 30px;
  font-weight: 900;
}
.service-error-dialog h2 { margin: 0; font-size: 21px; }
.service-error-dialog p { margin: 12px 0 20px; color: #5f6f84; line-height: 1.65; }
.service-error-dialog button {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  background: #d52332;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  margin-top: 18px;
}

.result-card { padding: 18px; border: 1px solid transparent; border-radius: 16px; }
.result-normal { background: var(--normal-soft); border-color: #d4efdb; }
.result-abnormal { background: var(--abnormal-soft); border-color: #f8d9dc; }
.result-unknown { background: var(--unknown-soft); border-color: #e2e6eb; }
.result-title { gap: 7px; margin-bottom: 9px; }
.result-normal .result-title { color: var(--normal); }
.result-abnormal .result-title { color: var(--abnormal); }
.result-unknown .result-title { color: var(--unknown); }
.count-badge {
  min-width: 23px;
  padding: 2px 7px;
  border-radius: 99px;
  background: currentColor;
  color: #fff;
  font-size: 12px;
  line-height: 19px;
  text-align: center;
}
.result-normal .count-badge { background: var(--normal); }
.result-abnormal .count-badge { background: var(--abnormal); }
.result-unknown .count-badge { background: var(--unknown); }
.result-card textarea { min-height: 190px; padding: 11px; background: #fff; }
.button-copy { width: 100%; min-height: 36px; margin-top: 9px; padding: 6px 12px; border-color: currentColor; font-weight: 600; }
.result-normal .button-copy { color: var(--normal); }
.result-abnormal .button-copy { color: var(--abnormal); }
.result-unknown .button-copy { color: var(--unknown); }
.split-actions { gap: 0; }
.split-actions .button { flex: 1; }
.button-retry { min-height: 36px; margin-top: 9px; padding: 6px 12px; border-color: #3577ff; color: #2468ef; }

.rules-card {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  padding: 13px 16px;
  border-radius: 11px;
  background: #f7f9fc;
  color: #65748a;
  font-size: 13px;
  line-height: 1.5;
}
.rules-card strong { flex: 0 0 auto; color: #2f4057; }

.copy-dialog {
  width: min(460px, calc(100% - 28px));
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 17px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 28px 80px rgba(13, 31, 61, 0.3);
}
.copy-dialog::backdrop { background: rgba(20, 32, 52, 0.48); backdrop-filter: blur(2px); }
.copy-dialog form { padding: 22px; }
.copy-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.copy-dialog h2 { margin: 2px 0 0; font-size: 20px; }
.dialog-eyebrow { margin: 0; color: #3978e8; font-size: 12px; font-weight: 800; }
.dialog-close {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: #f0f3f7;
  color: #526174;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}
.copy-dialog-description { margin: 13px 0 15px; color: var(--muted); font-size: 13px; }
.copy-choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.copy-choice {
  min-height: 98px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f9fbfe;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.copy-choice:hover { border-color: #73a0f2; background: #f1f6ff; }
.copy-choice strong, .copy-choice span { display: block; }
.copy-choice strong { margin-bottom: 7px; font-size: 14px; }
.copy-choice span { color: var(--muted); font-size: 12px; line-height: 1.45; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 980px) {
  .tool-hero { align-items: flex-start; }
  .privacy-note { max-width: 420px; }
  .results-grid { gap: 14px; }
}

@media (max-width: 760px) {
  .page-shell { width: min(100% - 16px, 1440px); padding: 8px 0 26px; }
  .tool-hero { display: block; min-height: 0; padding: 16px 17px; border-radius: 15px; }
  h1 { font-size: 25px; }
  .subtitle, .privacy-note { display: none; }
  .platform-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    margin: 10px 0 14px;
    padding: 7px;
    overflow: visible;
    border-radius: 12px;
    scrollbar-width: auto;
  }
  .platform-tab { width: 100%; min-width: 0; min-height: 40px; gap: 5px; padding: 8px; font-size: 13px; }
  .platform-tab .platform-icon { width: 20px; height: 20px; flex-basis: 20px; font-size: 12px; }
  .platform-tab:last-child { grid-column: 1 / -1; justify-content: center; }
  .platform-tab small { display: none; }
  .workspace-card { padding: 16px; border-radius: 14px; }
  .section-heading { align-items: flex-start; gap: 10px; }
  .section-heading p { font-size: 13px; }
  .line-counter { padding: 6px 9px; }
  .account-input { min-height: 155px; }
  .toolbar { flex-wrap: wrap; }
  .progress-wrap { grid-template-columns: 1fr auto; width: 100%; min-width: 0; margin: 4px 0 0; }
  .button-primary, .button-secondary { flex: 1; }
  .results-grid { grid-template-columns: 1fr; gap: 13px; }
  .result-card textarea { min-height: 140px; }
  .rules-card { flex-direction: column; gap: 5px; }
}

@media (max-width: 420px) {
  .tool-hero { padding: 14px 15px; }
  .workspace-card { padding: 13px; }
  .section-heading { display: grid; grid-template-columns: 1fr auto; }
  .section-heading p { grid-column: 1 / -1; }
  .result-card { padding: 14px; }
  .copy-dialog form { padding: 18px; }
  .copy-choice-grid { grid-template-columns: 1fr; }
  .copy-choice { min-height: 78px; }
}

@media (hover: none) and (pointer: coarse) and (min-width: 761px) and (max-width: 1180px) {
  .subtitle, .privacy-note { display: none; }
  .tool-hero { min-height: 0; padding: 17px 20px; }
  .platform-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
    scrollbar-width: auto;
  }
  .platform-tab { width: 100%; min-width: 0; justify-content: flex-start; }
  .platform-tab:last-child { grid-column: 1 / -1; justify-content: center; }
}
