:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e6e8ee;
  --text: #14161a;
  --muted: #6b7280;
  --accent: #3b5bdb;
  --accent-soft: rgba(59, 91, 219, 0.1);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.04);
  --radius: 16px;
  --radius-sm: 12px;
  --nav-w: 232px;
  --topbar-h: 72px;
  --bottom-h: 64px;
  --space: 8px;
  --content-max: 960px;
  --font: "SF Pro Text", "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1d212b;
    --border: #2a3140;
    --text: #f3f4f6;
    --muted: #9aa3b2;
    --accent: #6b8cff;
    --accent-soft: rgba(107, 140, 255, 0.14);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 12px 28px rgba(0, 0, 0, 0.28);
  }
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1d212b;
  --border: #2a3140;
  --text: #f3f4f6;
  --muted: #9aa3b2;
  --accent: #6b8cff;
  --accent-soft: rgba(107, 140, 255, 0.14);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 12px 28px rgba(0, 0, 0, 0.28);
}

:root[data-theme="light"] {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e6e8ee;
  --text: #14161a;
  --muted: #6b7280;
  --accent: #3b5bdb;
  --accent-soft: rgba(59, 91, 219, 0.1);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.04);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

img,
svg {
  display: block;
  max-width: 100%;
}

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

button {
  font: inherit;
  cursor: pointer;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  z-index: 100;
  padding: 8px 12px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
}

.skip-link:focus {
  left: 8px;
}

.app {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
}

.sidebar {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: calc(var(--space) * 1.5);
  padding: calc(var(--space) * 3) calc(var(--space) * 2.5) calc(var(--space) * 2);
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-text strong {
  font-size: 15px;
  letter-spacing: 0.01em;
}

.brand-text span {
  font-size: 12px;
  color: var(--muted);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 calc(var(--space) * 1.5);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}

.nav-icon svg {
  width: 22px;
  height: 22px;
}

.sidebar-foot {
  margin: auto calc(var(--space) * 2.5) calc(var(--space) * 2.5);
  font-size: 12px;
  color: var(--muted);
}

.shell {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom, 0px));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: var(--topbar-h);
  padding: calc(var(--space) * 2.5) calc(var(--space) * 2.5) calc(var(--space) * 2);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.topbar.is-stuck {
  border-bottom-color: var(--border);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
}

.topbar-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  max-width: var(--content-max);
}

.topbar-title h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.topbar-title p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
}

.btn.ghost {
  background: transparent;
}

.btn[aria-pressed="true"] {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  background: var(--accent-soft);
  font-weight: 600;
}

.main {
  padding: 0 calc(var(--space) * 2.5) calc(var(--space) * 3);
  display: flex;
  flex-direction: column;
  gap: calc(var(--space) * 2);
  outline: none;
  max-width: var(--content-max);
}

.view[hidden] {
  display: none !important;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: calc(var(--space) * 2.5);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: calc(var(--space) * 2);
}

.card-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.chip {
  font-size: 11px;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}

.chip.soft {
  background: transparent;
  border-style: dashed;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.01em;
  color: var(--accent);
  font-weight: 600;
}

.welcome-title {
  margin: 0 0 6px;
  font-size: 20px;
  letter-spacing: -0.02em;
  font-weight: 650;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: calc(var(--space) * 2);
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  min-height: 140px;
  padding: calc(var(--space) * 2);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px dashed var(--border);
}

.empty.tall {
  min-height: 200px;
}

.empty p {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
}

.empty-icon {
  width: 36px;
  height: 36px;
  margin-bottom: 4px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--border) 70%, transparent);
}

.profile {
  display: flex;
  align-items: center;
  gap: calc(var(--space) * 2);
}

.avatar {
  width: 72px;
  height: 72px;
  flex: 0 0 auto;
  border-radius: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  position: relative;
}
.avatar::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 28%;
  width: 22px;
  height: 22px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: color-mix(in srgb, var(--muted) 40%, transparent);
}
.avatar::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 14px;
  width: 36px;
  height: 18px;
  transform: translateX(-50%);
  border-radius: 18px 18px 8px 8px;
  background: color-mix(in srgb, var(--muted) 35%, transparent);
}

.name-slot {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.settings {
  list-style: none;
  margin: 0;
  padding: 0;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 4px;
  border-top: 1px solid var(--border);
}

.settings-row:first-child {
  border-top: 0;
  padding-top: 4px;
}

.settings-row.is-pending strong {
  color: var(--text);
}

.settings-row.is-pending .muted,
.settings-row.is-pending .row-trail {
  color: var(--muted);
}

.settings-row strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}

.row-trail {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  border: 1px dashed var(--border);
  border-radius: 999px;
  padding: 4px 8px;
}

.tools-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: calc(var(--space) * 2);
}

.tool {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 148px;
}

.tool.is-pending {
  border-style: dashed;
  box-shadow: none;
  background: var(--surface-2);
  cursor: default;
}

.tool-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tool h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.tool p {
  margin: 0;
}

.tool-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border));
  margin-bottom: 4px;
}

.tool-icon svg {
  width: 20px;
  height: 20px;
}

.tool-icon.tone-a {
  color: #3b5bdb;
  background: rgba(59, 91, 219, 0.12);
  border-color: rgba(59, 91, 219, 0.22);
}

.tool-icon.tone-b {
  color: #0d9488;
  background: rgba(13, 148, 136, 0.12);
  border-color: rgba(13, 148, 136, 0.22);
}

.tool-icon.tone-c {
  color: #c2410c;
  background: rgba(194, 65, 12, 0.12);
  border-color: rgba(194, 65, 12, 0.22);
}

:root[data-theme="dark"] .tool-icon.tone-a,
:root:not([data-theme="light"]) .tool-icon.tone-a {
  color: #8da4ff;
}

@media (prefers-color-scheme: light) {
  :root[data-theme="system"] .tool-icon.tone-a {
    color: #3b5bdb;
  }
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  min-height: var(--bottom-h);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}

.bottom-nav .nav-item {
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-height: 52px;
  padding: 6px 4px;
  font-size: 12px;
  border-radius: 12px;
}

.bottom-nav .nav-icon {
  width: 20px;
  height: 20px;
}

.bottom-nav .nav-icon svg {
  width: 20px;
  height: 20px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (min-width: 880px) {
  .app {
    grid-template-columns: var(--nav-w) 1fr;
  }

  .sidebar {
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100dvh;
    border-right: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 70%, var(--bg));
  }

  .bottom-nav {
    display: none;
  }

  .shell {
    padding-bottom: 0;
  }

  .main,
  .topbar {
    padding-left: calc(var(--space) * 4);
    padding-right: calc(var(--space) * 4);
  }

  .main {
    padding-bottom: calc(var(--space) * 4);
  }

  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }

  .tools-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .welcome-title {
    font-size: 22px;
  }
}

@media (min-width: 1200px) {
  :root {
    --content-max: 1080px;
  }
}

.theme-seg {
  display: none;
  flex-wrap: wrap;
  gap: 6px;
}

.theme-cycle {
  display: inline-flex;
}

.theme-seg.compact {
  display: flex;
}

.theme-seg.compact .btn {
  padding: 6px 10px;
  font-size: 12px;
}

.settings-row-theme {
  align-items: flex-start;
}

@media (min-width: 880px) {
  .theme-cycle {
    display: none;
  }
  .theme-seg {
    display: flex;
  }
}
