:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --panel-soft: #f9fbfd;
  --text: #111827;
  --muted: #667085;
  --line: #e4e7ec;
  --primary: #1769e0;
  --primary-strong: #0f55bd;
  --danger: #c33b32;
  --shadow: 0 18px 48px rgba(15, 23, 42, .08);
  --radius: 8px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: radial-gradient(circle at 12% -10%, rgba(23,105,224,.12), transparent 28rem), linear-gradient(180deg, #f9fbff 0%, var(--bg) 42%, #f1f5f9 100%);
  color: var(--text);
  letter-spacing: 0;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .62; }
.app-shell { min-height: 100vh; }
.splash-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: 32px;
  text-align: center;
}
.brand-mark {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: #101828;
  color: #fff;
  font-weight: 800;
  box-shadow: var(--shadow);
}
.splash-screen h1 { margin: 0; font-size: 28px; }
.splash-screen p, .muted { margin: 0; color: var(--muted); }
.page { width: min(1120px, 100%); margin: 0 auto; padding: 20px 18px 96px; }
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 18px; }
.auth-panel {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.auth-head { display: grid; gap: 12px; margin-bottom: 24px; }
.auth-head h1, .section-title h1, .top-title h1 { margin: 0; font-size: 26px; line-height: 1.2; }
.field { display: grid; gap: 8px; margin-bottom: 16px; }
.field label { font-size: 14px; color: #344054; font-weight: 650; }
.input, .textarea, .select {
  width: 100%;
  border: 1px solid #d0d5dd;
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border .16s ease, box-shadow .16s ease;
}
.input, .select { min-height: 46px; padding: 0 13px; }
.textarea { min-height: 150px; resize: vertical; padding: 12px 13px; line-height: 1.7; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(23,105,224,.12); }
.btn {
  min-height: 44px;
  display: inline-grid;
  grid-auto-flow: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0 16px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}
.btn svg, .icon { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-strong); }
.btn-ghost { border-color: var(--line); }
.btn-danger { border-color: rgba(195,59,50,.2); color: var(--danger); }
.btn-full { width: 100%; }
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(16px);
  background: rgba(246,248,251,.86);
  border-bottom: 1px solid rgba(228,231,236,.86);
}
.top-inner {
  width: min(1120px, 100%);
  min-height: 66px;
  margin: 0 auto;
  padding: 0 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
}
.top-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mini-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #101828;
  color: #fff;
  font-weight: 800;
  flex: 0 0 auto;
}
.top-actions { display: flex; align-items: center; gap: 8px; }
.section-title { display: grid; gap: 8px; margin: 24px 0 18px; }
.tool-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.tool-card, .panel, .history-item, .stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.tool-card {
  min-height: 156px;
  padding: 18px;
  display: grid;
  align-content: start;
  gap: 12px;
  text-align: left;
  box-shadow: 0 8px 24px rgba(15,23,42,.04);
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.tool-card:hover { transform: translateY(-2px); border-color: rgba(23,105,224,.38); box-shadow: var(--shadow); }
.tool-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: #eef4ff; color: var(--primary); }
.tool-card h2 { margin: 0; font-size: 17px; }
.tool-card p { margin: 0; color: var(--muted); line-height: 1.55; font-size: 14px; }
.tool-layout { display: grid; grid-template-columns: minmax(0, 430px) minmax(0, 1fr); gap: 16px; align-items: start; }
.panel { padding: 18px; }
.panel h2 { margin: 0 0 14px; font-size: 18px; }
.option-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.result-box {
  min-height: 320px;
  padding: 16px;
  border-radius: var(--radius);
  background: #0f172a;
  color: #e5eefc;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.empty-state {
  min-height: 220px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius);
  background: var(--panel-soft);
  padding: 24px;
}
.loading-line { height: 4px; overflow: hidden; border-radius: 999px; background: #e7eefb; }
.loading-line::before { content: ""; display: block; width: 42%; height: 100%; border-radius: inherit; background: var(--primary); animation: loading 1s infinite ease-in-out; }
@keyframes loading { 0% { transform: translateX(-110%); } 100% { transform: translateX(250%); } }
.profile-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat-card { padding: 18px; }
.stat-card span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.stat-card strong { display: block; font-size: 24px; overflow-wrap: anywhere; }
.actions-row { display: flex; flex-wrap: wrap; gap: 10px; }
.history-list { display: grid; gap: 12px; }
.history-item { padding: 16px; display: grid; gap: 8px; }
.history-meta { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13px; }
.history-item h2 { margin: 0; font-size: 16px; }
.history-item p { margin: 0; color: #344054; line-height: 1.55; overflow-wrap: anywhere; }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  z-index: 50;
  max-width: min(420px, calc(100% - 32px));
  transform: translateX(-50%);
  padding: 11px 14px;
  border-radius: var(--radius);
  background: rgba(17,24,39,.94);
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 14px;
}
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: none;
  grid-template-columns: repeat(3, 1fr);
  padding: 7px 12px calc(7px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(16px);
}
.nav-item { min-height: 48px; display: grid; place-items: center; gap: 2px; border: 0; background: transparent; color: var(--muted); font-size: 12px; }
.nav-item.active { color: var(--primary); font-weight: 800; }
.nav-item svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 920px) {
  .tool-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tool-layout { grid-template-columns: 1fr; }
  .profile-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .page { padding: 16px 14px 92px; }
  .top-inner { min-height: 58px; padding: 0 14px; }
  .top-title h1 { font-size: 20px; }
  .top-actions { display: none; }
  .tool-grid { grid-template-columns: 1fr; }
  .tool-card { min-height: 132px; }
  .option-grid { grid-template-columns: 1fr; }
  .auth-panel { padding: 22px; }
  .bottom-nav { display: grid; }
}
.result-head {
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.result-head h2 {
  margin: 0;
}
.clear-panel {
  margin-top: 14px;
}
.category-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  margin: -2px 0 18px;
  padding: 2px 2px 8px;
  scroll-snap-type: x proximity;
}
.category-scroll::-webkit-scrollbar {
  display: none;
}
.category-tab {
  flex: 0 0 auto;
  min-height: 42px;
  display: inline-grid;
  grid-auto-flow: column;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  background: rgba(255, 255, 255, .86);
  color: #475467;
  font-weight: 700;
  white-space: nowrap;
  scroll-snap-align: start;
  transition: background .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease;
}
.category-tab svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.category-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 10px 24px rgba(23, 105, 224, .22);
}
.tool-category {
  width: fit-content;
  border-radius: 999px;
  padding: 3px 8px;
  background: #f2f4f7;
  color: #475467;
  font-size: 12px;
  font-weight: 700;
}
.tool-grid > .empty-state {
  grid-column: 1 / -1;
}
@media (max-width: 640px) {
  .category-scroll {
    margin-left: -14px;
    margin-right: -14px;
    padding-left: 14px;
    padding-right: 14px;
  }
  .category-tab {
    min-height: 40px;
    padding: 0 13px;
  }
}
.tool-card {
  position: relative;
  overflow: hidden;
}
.tool-main {
  width: 100%;
  min-height: 100%;
  display: grid;
  align-content: start;
  gap: 12px;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}
.favorite-btn {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(208, 213, 221, .9);
  border-radius: 999px;
  background: rgba(255, 255, 255, .92);
  color: #98a2b3;
  transition: transform .16s ease, color .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.tool-card > .favorite-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
}
.favorite-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: transparent;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: fill .16s ease, transform .16s ease;
}
.favorite-btn:hover {
  transform: scale(1.06);
  border-color: rgba(245, 158, 11, .48);
  color: #d97706;
}
.favorite-btn.active {
  color: #f59e0b;
  border-color: rgba(245, 158, 11, .34);
  background: #fffbeb;
  box-shadow: 0 8px 22px rgba(245, 158, 11, .18);
}
.favorite-btn.active svg {
  fill: currentColor;
  animation: favorite-pop .22s ease;
}
.favorite-page-btn {
  width: auto;
  min-height: 44px;
  grid-auto-flow: column;
  gap: 8px;
  padding: 0 14px;
  font-weight: 700;
}
@keyframes favorite-pop {
  0% { transform: scale(.78); }
  70% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
.favorites-section {
  margin: 24px 0 22px;
  padding: 16px;
  border: 1px solid rgba(245, 158, 11, .24);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fffdf7 0%, #fff 100%);
  box-shadow: 0 10px 28px rgba(15, 23, 42, .04);
}
.favorites-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.favorites-title h2 {
  margin: 0;
  font-size: 18px;
}
.favorites-title span {
  color: #b45309;
  font-size: 13px;
  font-weight: 700;
}
.favorite-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.tool-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
@media (max-width: 920px) {
  .favorite-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .favorites-section {
    margin-top: 18px;
    padding: 14px;
  }
  .favorite-grid { grid-template-columns: 1fr; }
  .tool-title-row {
    align-items: stretch;
  }
  .favorite-page-btn {
    min-height: 42px;
  }
}
.search-panel {
  position: sticky;
  top: 66px;
  z-index: 18;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin: 10px 0 18px;
  padding: 10px 0;
  background: rgba(246, 248, 251, .9);
  backdrop-filter: blur(14px);
}
.search-box {
  min-height: 46px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 1px solid #d0d5dd;
  border-radius: var(--radius);
  background: #fff;
  padding: 0 12px;
  transition: border .16s ease, box-shadow .16s ease;
}
.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(23, 105, 224, .12);
}
.search-box > svg {
  width: 18px;
  height: 18px;
  color: #98a2b3;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.search-input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}
.search-input::-webkit-search-cancel-button {
  appearance: none;
}
.search-clear {
  width: 28px;
  height: 28px;
  display: none;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: #f2f4f7;
  color: #667085;
}
.search-clear.visible {
  display: grid;
}
.search-clear svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.search-cancel {
  min-height: 42px;
  display: none;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 800;
  padding: 0 4px;
}
.search-cancel.visible {
  display: inline-grid;
  align-items: center;
}
.search-hit {
  border-radius: 4px;
  background: #fef3c7;
  color: #92400e;
  padding: 0 2px;
}
.search-empty {
  min-height: 180px;
}
@media (max-width: 640px) {
  .search-panel {
    top: 58px;
    margin-top: 4px;
  }
}
.feedback-panel {
  width: min(680px, 100%);
  margin: 0 auto;
}
.feedback-textarea {
  min-height: 210px;
}
.char-count {
  display: flex;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 13px;
  margin-top: -6px;
}
.feedback-submit {
  display: flex;
  justify-content: center;
  padding-top: 4px;
}
.feedback-submit .btn {
  min-width: 168px;
}
@media (max-width: 640px) {
  .feedback-panel {
    margin: 0;
  }
  .feedback-submit .btn {
    width: 100%;
  }
}
/* H5 mobile adaptation */
@media (max-width: 520px) {
  html {
    -webkit-text-size-adjust: 100%;
  }

  body {
    background: linear-gradient(180deg, #f8fbff 0%, #f3f6fa 100%);
    overflow-x: hidden;
  }

  .app-topbar {
    position: sticky;
    top: 0;
    background: rgba(248, 251, 255, .96);
  }

  .top-inner {
    min-height: 54px;
    padding: 0 12px;
  }

  .mini-mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 13px;
  }

  .top-title {
    gap: 9px;
  }

  .top-title h1 {
    max-width: calc(100vw - 92px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 18px;
  }

  .page {
    width: 100%;
    padding: 10px 12px calc(82px + var(--safe-bottom));
  }

  .section-title {
    margin: 16px 0 12px;
    gap: 5px;
  }

  .section-title h1,
  .auth-head h1 {
    font-size: 22px;
  }

  .section-title .muted,
  .tool-card p,
  .history-item p {
    font-size: 13px;
  }

  .search-panel {
    top: 54px;
    z-index: 19;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    margin: 0 -12px 12px;
    padding: 8px 12px 10px;
    background: rgba(248, 251, 255, .96);
    border-bottom: 1px solid rgba(228, 231, 236, .72);
  }

  .search-box {
    min-height: 42px;
    border-radius: 10px;
  }

  .search-input {
    font-size: 15px;
  }

  .search-cancel {
    min-height: 40px;
    padding: 0 2px;
    font-size: 14px;
  }

  .category-scroll {
    gap: 8px;
    margin: -2px -12px 12px;
    padding: 2px 12px 8px;
  }

  .category-tab {
    min-height: 38px;
    gap: 6px;
    padding: 0 12px;
    font-size: 13px;
  }

  .category-tab svg {
    width: 16px;
    height: 16px;
  }

  .favorites-section {
    margin: 12px 0 16px;
    padding: 12px;
    border-radius: 10px;
  }

  .favorites-title {
    margin-bottom: 10px;
  }

  .favorites-title h2 {
    font-size: 16px;
  }

  .favorites-title span {
    font-size: 12px;
  }

  .tool-grid,
  .favorite-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .tool-card {
    min-height: auto;
    padding: 14px;
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, .035);
  }

  .tool-main {
    min-height: 104px;
    gap: 9px;
    padding-right: 36px;
  }

  .tool-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }

  .tool-card h2 {
    font-size: 16px;
    line-height: 1.28;
  }

  .tool-category {
    padding: 2px 7px;
    font-size: 11px;
  }

  .tool-card > .favorite-btn {
    top: 10px;
    right: 10px;
  }

  .favorite-btn {
    width: 32px;
    height: 32px;
  }

  .tool-layout {
    gap: 12px;
  }

  .panel,
  .stat-card,
  .history-item {
    padding: 14px;
    border-radius: 10px;
  }

  .panel h2 {
    font-size: 16px;
    margin-bottom: 12px;
  }

  .field {
    margin-bottom: 13px;
  }

  .input,
  .select {
    min-height: 44px;
    border-radius: 10px;
    font-size: 15px;
  }

  .textarea {
    min-height: 132px;
    border-radius: 10px;
    font-size: 15px;
  }

  .feedback-textarea {
    min-height: 190px;
  }

  .btn {
    min-height: 42px;
    border-radius: 10px;
    padding: 0 13px;
    font-size: 14px;
  }

  .btn svg,
  .icon {
    width: 17px;
    height: 17px;
  }

  .actions-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .actions-row .btn {
    width: 100%;
  }

  .profile-grid {
    gap: 10px;
    margin-bottom: 12px;
  }

  .stat-card span {
    margin-bottom: 5px;
  }

  .stat-card strong {
    font-size: 20px;
  }

  .tool-title-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    margin-bottom: 12px;
  }

  .tool-title-row .btn:first-child {
    justify-self: start;
  }

  .favorite-page-btn {
    min-height: 40px;
    padding: 0 12px;
  }

  .result-head {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
  }

  .result-head .btn {
    width: auto;
  }

  .result-box {
    min-height: 240px;
    padding: 14px;
    border-radius: 10px;
    font-size: 14px;
  }

  .empty-state {
    min-height: 150px;
    padding: 18px;
    border-radius: 10px;
    font-size: 14px;
  }

  .history-list {
    gap: 10px;
  }

  .history-meta {
    display: grid;
    gap: 4px;
    font-size: 12px;
  }

  .history-item h2 {
    font-size: 15px;
    line-height: 1.35;
  }

  .auth-page {
    align-items: start;
    padding: 18px 12px;
  }

  .auth-panel {
    margin-top: 10vh;
    padding: 20px;
    border-radius: 12px;
  }

  .brand-mark {
    width: 56px;
    height: 56px;
    border-radius: 14px;
  }

  .bottom-nav {
    display: grid;
    padding: 6px 8px calc(6px + var(--safe-bottom));
  }

  .nav-item {
    min-height: 46px;
    font-size: 11px;
  }

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

  .toast {
    bottom: calc(76px + var(--safe-bottom));
    width: max-content;
    max-width: calc(100% - 28px);
    font-size: 13px;
  }
}

@media (max-width: 360px) {
  .page {
    padding-left: 10px;
    padding-right: 10px;
  }

  .search-panel,
  .category-scroll {
    margin-left: -10px;
    margin-right: -10px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .tool-title-row {
    grid-template-columns: 1fr;
  }

  .favorite-page-btn {
    width: 100%;
  }
}
