﻿:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-muted: #f1f3f8;
  --surface-hover: #f6f7fc;
  --text: #1a1d29;
  --text-soft: #596174;
  --text-faint: #8c94a6;
  --border: #e4e7ef;
  --border-strong: #d5dae5;
  --accent: #5b5bd6;
  --accent-strong: #4747bc;
  --accent-soft: #eeeeff;
  --success: #21845b;
  --shadow-sm: 0 1px 2px rgba(28, 35, 55, .04), 0 5px 18px rgba(28, 35, 55, .035);
  --shadow-lg: 0 20px 50px rgba(28, 35, 55, .09);
  --radius: 12px;
  --sidebar-width: 274px;
  --transition: 180ms ease;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151721;
  --surface: #1c1f2b;
  --surface-muted: #222635;
  --surface-hover: #262a3a;
  --text: #f2f3f8;
  --text-soft: #a9afc1;
  --text-faint: #747c91;
  --border: #2e3343;
  --border-strong: #3b4254;
  --accent: #9291ff;
  --accent-strong: #aaa9ff;
  --accent-soft: #2d2d54;
  --success: #63c997;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .16), 0 5px 18px rgba(0, 0, 0, .12);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .24);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); transition: background var(--transition), color var(--transition); }
button, a { font: inherit; }
a { color: inherit; text-decoration: none; }
button { border: 0; cursor: pointer; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 20; display: flex; flex-direction: column;
  width: var(--sidebar-width); padding: 22px 16px 16px; background: var(--surface);
  border-right: 1px solid var(--border); transition: transform var(--transition), width var(--transition), padding var(--transition);
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 8px 26px; }
.brand, .mobile-brand { display: inline-flex; align-items: center; gap: 11px; }
.brand-mark { display: grid; width: 33px; height: 33px; place-items: center; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface-muted); color: var(--accent); font-size: 21px; font-weight: 700; }
.brand-copy { display: flex; flex-direction: column; gap: 1px; }
.brand-copy strong { font-size: 15px; letter-spacing: -.02em; }
.brand-copy small { color: var(--text-faint); font-size: 11px; }
.icon-button { display: inline-grid; width: 34px; height: 34px; place-items: center; padding: 0; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--text-soft); transition: background var(--transition), color var(--transition), border-color var(--transition); }
.icon-button:hover { border-color: var(--border); background: var(--surface-muted); color: var(--text); }
.icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 0 0 12px; }
.nav-group { margin: 0 0 22px; }
.nav-group-title { margin: 0 10px 8px; color: var(--text-faint); font-size: 11px; font-weight: 700; letter-spacing: .08em; line-height: 1.4; }
.nav-link { position: relative; display: flex; align-items: center; gap: 10px; min-height: 42px; margin: 2px 0; padding: 9px 10px 9px 13px; border-radius: 9px; color: var(--text-soft); font-size: 13px; transition: background var(--transition), color var(--transition), transform var(--transition); }
.nav-link:hover { background: var(--surface-hover); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.nav-link.active::before { position: absolute; left: 0; width: 3px; height: 18px; border-radius: 0 3px 3px 0; background: var(--accent); content: ""; }
.nav-icon { width: 22px; text-align: center; font-size: 16px; line-height: 1; }
.nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer { display: flex; align-items: center; gap: 8px; padding: 14px 10px 2px; border-top: 1px solid var(--border); color: var(--text-faint); font-size: 11px; }
.sidebar-status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 13%, transparent); }

.main-content { min-height: 100vh; margin-left: var(--sidebar-width); transition: margin-left var(--transition); }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 72px; padding: 18px 44px 10px; }
.breadcrumb { color: var(--text-faint); font-size: 12px; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb-separator { display: inline-block; margin: 0 8px; color: var(--border-strong); }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.theme-icon-moon { display: none; }
:root[data-theme="dark"] .theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-icon-moon { display: block; }
.page-view { max-width: 1220px; min-height: calc(100vh - 72px); margin: 0 auto; padding: 38px 44px 64px; }
.mobile-header, .mobile-scrim { display: none; }

.hero { max-width: 810px; padding: 28px 0 48px; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 16px; color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: .08em; }
.eyebrow::before { width: 22px; height: 1px; background: currentColor; content: ""; }
.hero h1 { max-width: 720px; margin: 0; font-size: clamp(35px, 5vw, 60px); font-weight: 750; letter-spacing: -.055em; line-height: 1.08; }
.hero h1 span { color: var(--accent); }
.hero-copy { max-width: 640px; margin: 22px 0 0; color: var(--text-soft); font-size: 16px; line-height: 1.85; }
.hero-copy p { margin: 0 0 8px; }
.hero-copy p:last-child { margin-bottom: 0; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 0 0 18px; }
.section-heading h2 { margin: 0; font-size: 20px; letter-spacing: -.025em; }
.section-heading p { margin: 4px 0 0; color: var(--text-faint); font-size: 12px; }
.overview-grid { display: grid; grid-template-columns: 170px minmax(0, 1fr) 220px; gap: 14px; }
.stat-card, .panel-card, .tool-page-card, .empty-state, .not-found { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.stat-card { padding: 21px; }
.stat-label { color: var(--text-faint); font-size: 12px; }
.stat-value { margin-top: 12px; font-size: 34px; font-weight: 750; letter-spacing: -.055em; }
.stat-note { margin-top: 4px; color: var(--text-soft); font-size: 12px; }
.panel-card { padding: 21px; }
.panel-card h3 { margin: 0 0 14px; font-size: 14px; }
.category-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.category-chip { display: inline-flex; align-items: center; gap: 7px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-muted); color: var(--text-soft); font-size: 12px; transition: border-color var(--transition), color var(--transition), background var(--transition); }
.category-chip:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.category-chip b { color: var(--text); font-size: 11px; }
.recent-hint { display: flex; gap: 12px; align-items: flex-start; color: var(--text-soft); font-size: 12px; line-height: 1.65; }
.recent-hint-icon { display: grid; flex: 0 0 auto; width: 28px; height: 28px; place-items: center; border-radius: 8px; background: var(--accent-soft); color: var(--accent); }
.recent-hint p { margin: 0; }
.tool-list-section { margin-top: 52px; }
.tool-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.tool-group-card { padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.tool-group-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; }
.tool-group-heading h3 { margin: 0; font-size: 14px; }
.tool-group-heading span { color: var(--text-faint); font-size: 11px; }
.tool-card-link { display: flex; align-items: center; gap: 12px; padding: 11px 10px; border-top: 1px solid var(--border); transition: background var(--transition), transform var(--transition); }
.tool-card-link:first-of-type { border-top: 0; }
.tool-card-link:hover { margin: 0 -5px; padding-right: 15px; padding-left: 15px; border-radius: 8px; background: var(--surface-hover); transform: translateX(2px); }
.tool-card-icon { display: grid; flex: 0 0 auto; width: 34px; height: 34px; place-items: center; border-radius: 9px; background: var(--surface-muted); font-size: 17px; }
.tool-card-content { min-width: 0; flex: 1; }
.tool-card-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 650; }
.tool-card-desc { overflow: hidden; margin-top: 3px; color: var(--text-faint); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.tool-card-arrow { color: var(--text-faint); font-size: 17px; transition: color var(--transition), transform var(--transition); }
.tool-card-link:hover .tool-card-arrow { color: var(--accent); transform: translateX(3px); }
.empty-state, .not-found { padding: 55px 30px; text-align: center; }
.empty-state-icon { font-size: 34px; }
.empty-state h2, .not-found h2 { margin: 14px 0 8px; font-size: 20px; }
.empty-state p, .not-found p { max-width: 460px; margin: 0 auto; color: var(--text-soft); font-size: 13px; line-height: 1.7; }

.tool-page { display: flex; flex-direction: column; height: calc(100vh - 135px); min-height: 520px; }
.tool-page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding: 0 0 22px; }
.tool-page-title-wrap { display: flex; align-items: flex-start; gap: 14px; }
.tool-page-icon { display: grid; flex: 0 0 auto; width: 48px; height: 48px; place-items: center; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); box-shadow: var(--shadow-sm); font-size: 23px; }
.tool-page h1 { margin: 0; font-size: 25px; letter-spacing: -.04em; }
.tool-page-description { max-width: 700px; margin: 7px 0 0; color: var(--text-soft); font-size: 13px; line-height: 1.6; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); color: var(--text); font-size: 12px; font-weight: 650; white-space: nowrap; transition: border-color var(--transition), background var(--transition), color var(--transition), transform var(--transition); }
.button:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); transform: translateY(-1px); }
.button-primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.button-primary:hover { border-color: var(--accent-strong); background: var(--accent-strong); color: #fff; }
.button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.tool-frame-wrap { position: relative; flex: 1; min-height: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-lg); }
.tool-frame { display: block; width: 100%; height: 100%; border: 0; background: var(--surface); }
.frame-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--surface); color: var(--text-soft); font-size: 13px; transition: opacity var(--transition); }
.frame-loading.is-hidden { pointer-events: none; opacity: 0; }
.spinner { width: 17px; height: 17px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.external-tool-card { display: flex; min-height: 410px; align-items: center; justify-content: center; padding: 35px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-lg); text-align: center; }
.external-tool-inner { max-width: 510px; }
.external-tool-icon { display: grid; width: 64px; height: 64px; margin: 0 auto 20px; place-items: center; border-radius: 17px; background: var(--accent-soft); color: var(--accent); font-size: 30px; }
.external-tool-inner h2 { margin: 0 0 9px; font-size: 21px; }
.external-tool-inner p { margin: 0 auto 22px; color: var(--text-soft); font-size: 13px; line-height: 1.7; }
.external-url { overflow: hidden; max-width: 100%; margin: 0 auto 22px; color: var(--text-faint); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-collapsed .sidebar { width: 0; padding-right: 0; padding-left: 0; overflow: visible; transform: translateX(-100%); }
.sidebar-collapsed .main-content { margin-left: 0; }
.sidebar-collapsed .sidebar-collapse { position: fixed; top: 20px; left: 16px; z-index: 30; display: inline-grid; width: 36px; height: 36px; border-color: var(--border); background: var(--surface); box-shadow: var(--shadow-sm); }
.sidebar-collapsed .sidebar-collapse svg { transform: rotate(180deg); }

@media (max-width: 980px) {
  .overview-grid { grid-template-columns: 150px minmax(0, 1fr); }
  .recent-panel { grid-column: 1 / -1; }
  .tool-groups { grid-template-columns: 1fr; }
}
@media (max-width: 767px) {
  .sidebar { width: min(84vw, 300px); transform: translateX(-102%); box-shadow: var(--shadow-lg); }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-collapse { display: none; }
  .main-content { margin-left: 0; }
  .mobile-header { display: flex; align-items: center; gap: 12px; height: 60px; padding: 12px 17px 4px; }
  .mobile-brand { font-size: 14px; font-weight: 700; }
  .mobile-header-spacer { flex: 1; }
  .mobile-scrim { position: fixed; inset: 0; z-index: 19; display: block; background: rgba(10, 13, 22, .38); }
  .topbar { min-height: 48px; padding: 5px 17px 8px; }
  .breadcrumb { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .page-view { min-height: calc(100vh - 108px); padding: 24px 17px 45px; }
  .hero { padding: 12px 0 36px; }
  .hero h1 { font-size: 38px; }
  .hero-copy { font-size: 14px; line-height: 1.8; }
  .overview-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card, .panel-card { padding: 16px; }
  .category-panel, .recent-panel { grid-column: 1 / -1; }
  .tool-list-section { margin-top: 38px; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 4px; }
  .tool-page { height: calc(100vh - 123px); min-height: 470px; }
  .tool-page-header { flex-direction: column; gap: 15px; padding-bottom: 17px; }
  .tool-page-header .button { width: 100%; }
  .tool-page h1 { font-size: 22px; }
  .tool-page-icon { width: 42px; height: 42px; font-size: 20px; }
  .external-tool-card { min-height: 350px; padding: 24px; }
}
