:root {
  color-scheme: light;
  --bg: #f5f3f7;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-solid: #ffffff;
  --sidebar: #eee9f2;
  --border: #ddd5e3;
  --text: #2f2933;
  --muted: #756d79;
  --accent: #8a6a98;
  --accent-soft: #eadff0;
  --hover: #f2ecf5;
  --shadow: 0 14px 34px rgba(69, 51, 76, 0.10);
  font-family: Inter, ui-sans-serif, system-ui, -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 top right, #eee4f2 0, transparent 34rem),
    var(--bg);
  color: var(--text);
}
button, input, textarea, select { font: inherit; }
button { color: inherit; }

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 18px 14px;
  background: color-mix(in srgb, var(--sidebar) 92%, transparent);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(16px);
}

.brand {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.brand:hover { background: rgba(255,255,255,.55); }
.brand-icon { font-size: 30px; }
.brand strong, .brand small { display: block; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }

.sidebar-tree { margin-top: 22px; }
.sidebar-group { margin-bottom: 14px; }
.sidebar-group-title {
  padding: 0 10px 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.sidebar-link {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.sidebar-link:hover { background: rgba(255,255,255,.65); }
.sidebar-link.active {
  background: var(--panel-solid);
  box-shadow: 0 4px 18px rgba(70, 50, 78, .07);
}
.sidebar-link-icon { width: 24px; text-align: center; }
.sidebar-link-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.workspace { min-width: 0; }
.topbar {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  border-bottom: 1px solid rgba(221, 213, 227, .8);
  background: rgba(245, 243, 247, .72);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.breadcrumbs {
  min-width: 0;
  color: var(--muted);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.breadcrumbs strong { color: var(--text); }
.view-actions { display: flex; gap: 8px; }
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255,255,255,.72);
  cursor: pointer;
}
.icon-button:hover, .icon-button.active {
  border-color: #cbbbd3;
  background: var(--accent-soft);
}

.main { padding: 28px; outline: none; }
.page-title { margin: 0; font-size: clamp(24px, 3vw, 38px); }
.page-subtitle { margin: 8px 0 24px; color: var(--muted); }

.group-section { margin: 30px 0; }
.group-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.group-heading h2 { margin: 0; font-size: 16px; }
.group-heading span { color: var(--muted); font-size: 12px; }

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}
.tool-card {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
  transition: transform .16s ease, border-color .16s ease;
}
.tool-card:hover { transform: translateY(-2px); border-color: #c9b8d2; }
.tool-card-icon { display: block; margin-bottom: 14px; font-size: 30px; }
.tool-card-name { display: block; font-weight: 750; }
.tool-card-desc {
  display: -webkit-box;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.tool-list {
  display: grid;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  overflow: hidden;
}
.tool-row {
  display: grid;
  grid-template-columns: 42px minmax(160px, 1fr) minmax(220px, 2fr) 150px;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.tool-row:last-child { border-bottom: 0; }
.tool-row:hover { background: var(--hover); }
.tool-row-desc, .tool-row-path { color: var(--muted); font-size: 12px; }
.tool-row-path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty-state, .error-state {
  padding: 40px;
  border: 1px dashed var(--border);
  border-radius: 16px;
  background: rgba(255,255,255,.55);
  color: var(--muted);
  text-align: center;
}
.error-state { color: #8d3b48; text-align: left; }
.error-state pre { overflow: auto; color: var(--text); }

.tool-stage {
  min-height: calc(100vh - 124px);
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel-solid);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.tool-root { min-height: inherit; }

/* 提供给小工具复用的基础控件 */
.tool-page { padding: clamp(20px, 4vw, 42px); }
.tool-page h1 { margin-top: 0; }
.tool-form { display: grid; gap: 14px; }
.tool-label { display: grid; gap: 7px; font-weight: 650; }
.tool-input, .tool-textarea, .tool-select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #fff;
  color: var(--text);
  outline: none;
}
.tool-textarea { min-height: 220px; resize: vertical; font-family: ui-monospace, monospace; }
.tool-input:focus, .tool-textarea:focus, .tool-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.tool-buttons { display: flex; flex-wrap: wrap; gap: 9px; }
.tool-button {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}
.tool-button.primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.tool-output {
  padding: 14px;
  border-radius: 11px;
  background: #f6f3f7;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 780px) {
  .app-shell { grid-template-columns: 78px minmax(0, 1fr); }
  .sidebar { padding-inline: 9px; }
  .brand { justify-content: center; }
  .brand > span:last-child,
  .sidebar-group-title,
  .sidebar-link-name { display: none; }
  .sidebar-link { justify-content: center; }
  .main { padding: 16px; }
  .topbar { padding-inline: 16px; }
  .tool-row { grid-template-columns: 36px minmax(0, 1fr); }
  .tool-row-desc, .tool-row-path { display: none; }
}
