﻿:root {
  --bg: #090909;
  --surface: #151518;
  --surface-2: #1c1c20;
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.1);
  --text: #fafafa;
  --text-2: #c8c8d0;
  --text-3: #8a8a94;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.12);
  --accent-glow: rgba(59, 130, 246, 0.25);
  --sidebar: 220px;
  --radius: 14px;
  --radius-sm: 10px;
  --ease: 0.2s ease;
}

[data-theme="light"] {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --surface-2: #eaeaea;
  --border: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.14);
  --text: #09090b;
  --text-2: #5c6a7a;
  --text-3: #7e8a98;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --accent-glow: rgba(37, 99, 235, 0.2);
}

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

body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-size: 40px 40px;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  -webkit-mask-image: linear-gradient(to bottom, black 0%, transparent 60%);
  mask-image: linear-gradient(to bottom, black 0%, transparent 60%);
}

.app {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar {
  width: var(--sidebar);
  min-width: var(--sidebar);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(12px);
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
  padding: 0 0.5rem 1.5rem;
  margin-bottom: 0.5rem;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 1rem;
  display: grid;
  place-items: center;
}

.brand-text {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 1.25rem 0.75rem 0.5rem 1.5rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color var(--ease), background var(--ease);
  text-align: left;
}

.nav-link > :first-child {
  margin-left: 0.75rem;
}

.nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: transparent;
  flex-shrink: 0;
  transition: background var(--ease), box-shadow var(--ease);
}

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

.nav-link.active {
  color: var(--text);
  background: var(--surface);
}

.nav-link.active .nav-dot {
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

.sidebar-foot {
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  padding: 0.7rem 0.6rem;
  margin-bottom: 0.6rem;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  border-radius: var(--radius);
  transition: background var(--ease);
  text-align: left;
  font: inherit;
}
.user-chip:hover { background: var(--surface-2); }

.user-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border-hover);
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-2);
  overflow: hidden;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
}

.user-name {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  outline: none;
}

.user-name:focus {
  color: var(--accent);
}

.user-avatar-input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-3);
  font: inherit;
  font-size: 0.65rem;
  outline: none;
  margin-top: 2px;
}
.user-avatar-input:focus { color: var(--accent); }
.user-avatar-input::placeholder { color: var(--text-3); }

img {
  image-rendering: auto;
  -ms-interpolation-mode: bicubic;
}
.avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.user-role {
  font-size: 0.75rem;
  font-weight: 700;
  color: #a78bfa;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 1px;
}

.owner-badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.15rem 0.5rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #c4b5fd;
  background: rgba(139, 92, 246, 0.2);
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: 6px;
  vertical-align: middle;
}

.rgb-text {
  background: linear-gradient(90deg, #60a5fa, #a78bfa, #f472b6, #60a5fa);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: rgbShift 4s linear infinite;
}

@keyframes rgbShift {
  to { background-position: 200% center; }
}

.foot-actions {
  display: flex;
  gap: 0.75rem;
  padding: 0 0.5rem;
}

.link-btn {
  background: none;
  border: none;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
}

.link-btn-muted { color: var(--text-3); }
.link-btn:hover { opacity: 0.8; }

.main {
  flex: 1;
  margin-left: var(--sidebar);
  margin-right: 20vw;
  padding: 2rem 1.5rem 3rem 2.5rem;
  max-width: none;
  width: calc(100% - var(--sidebar) - 20vw);
  position: relative;
  z-index: 1;
}

.main > * {
  position: relative;
  z-index: 1;
}

.header-user-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: var(--text-2);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.header-user-pill strong {
  font-weight: 700;
  color: var(--text);
}

.header-user-pill #headerUserRole {
  font-size: 0.65rem;
  font-weight: 700;
  color: #a78bfa;
  letter-spacing: 0.05em;
}

.pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.header-text h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.2rem;
}

.header-text p {
  font-size: 0.9rem;
  color: var(--text-2);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-ghost {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-2);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  transition: border-color var(--ease), color var(--ease);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-hover);
}

.btn-primary {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: filter var(--ease), transform 0.15s ease;
}

.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: scale(0.98); }

.icon-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-2);
  cursor: pointer;
  transition: color var(--ease), border-color var(--ease);
}

.icon-btn:hover { color: var(--text); border-color: var(--border-hover); }
.icon-btn svg { width: 16px; height: 16px; }

.panel { display: none; animation: fade 0.25s ease; }
.panel.active { display: block; }

@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1.5rem 0 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.75rem;
}

.hero-greet {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin-bottom: 0.35rem;
}

.hero-greet strong { font-weight: 700; }

.hero-sub {
  font-size: 0.95rem;
  color: var(--text-2);
}

.hero-tags {
  display: flex;
  gap: 0.5rem;
}

.tag {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
}

.tag-accent {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: transparent;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}

.metric {
  padding: 1.1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--ease);
}

.metric:hover { border-color: var(--border-hover); }

.metric-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-3);
  margin-bottom: 0.35rem;
}

.metric-value {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.metric-value-sm { font-size: 1rem; font-weight: 600; }

.layout-split {
  display: grid;
  grid-template-columns: 1fr 240px;
  grid-template-rows: auto auto;
  gap: 0.75rem;
}

.surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.surface-wide { grid-column: 1; grid-row: 1; }
.surface:not(.surface-wide):not(.surface-feed) { grid-column: 2; grid-row: 1; }
.surface-feed {
  grid-column: 1 / -1;
  grid-row: 2;
}

.surface-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.surface-head h2 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-2);
}

.chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 120px;
}

.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}

.chart-bar {
  width: 100%;
  height: var(--h);
  min-height: 8px;
  max-height: 100%;
  background: linear-gradient(180deg, var(--accent) 0%, rgba(59, 130, 246, 0.25) 100%);
  border-radius: 6px 6px 2px 2px;
  opacity: 0.85;
  transition: height 0.4s ease;
}

.chart-bar:hover { opacity: 1; }

.chart-day {
  font-size: 0.65rem;
  color: var(--text-3);
  flex-shrink: 0;
}

.shortcuts {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.shortcut {
  width: 100%;
  text-align: left;
  padding: 0.6rem 0.75rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color var(--ease), border-color var(--ease), background var(--ease);
}

.shortcut:hover {
  color: var(--text);
  border-color: var(--border-hover);
  background: var(--bg);
}

.feed {
  list-style: none;
  display: flex;
  flex-direction: column;
  min-height: 48px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 0;
  overflow: hidden;
}

.feed-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0.75rem;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.feed-item:last-child {
  border-bottom: none;
}

.feed-item span:last-child {
  font-size: 0.75rem;
  color: var(--text-3);
}

.feed-empty {
  font-size: 0.85rem;
  color: var(--text-3);
  padding: 0.75rem;
}

.modules-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.5rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}

.modules-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.25rem;
}

.modules-desc {
  font-size: 0.9rem;
  color: var(--text-2);
}

.corner-mascot {
    position: fixed;
    bottom: -10px;
    right: -20px;
    width: 220px;
    z-index: 9999;
    pointer-events: none;
    user-select: none;
    opacity: 0.95;
}

.corner-mascot img {
    width: 100%;
    height: auto;
    display: block;
    image-rendering: auto;
}

.search {
  width: 100%;
  max-width: 280px;
  padding: 0.6rem 1rem;
  font: inherit;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--ease);
}

.search::placeholder { color: var(--text-3); }
.search:focus { border-color: var(--accent); }

.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 0.75rem;
}

.module-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--ease), transform 0.2s ease, box-shadow 0.2s ease;
}

.module-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.module-top {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
}

.module-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--text-2);
  flex-shrink: 0;
}

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

.module-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.module-cat {
  font-size: 0.7rem;
  color: var(--text-3);
  text-transform: capitalize;
}

.module-desc {
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--text-2);
  flex: 1;
}

.module-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-top: 0.25rem;
}

.module-open {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: filter var(--ease);
}

.module-open:hover { filter: brightness(1.1); }

.module-tab {
  font-size: 0.75rem;
  color: var(--text-3);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: color var(--ease);
}

.module-tab:hover { color: var(--accent); }
.module-tab svg { width: 12px; height: 12px; }

.module-card.hidden { display: none; }
.modules-empty { grid-column: 1 / -1; padding: 2rem 0; }

.mod-vip-badge {
  display:inline-block; font-size:0.55rem; font-weight:700; padding:1px 5px;
  border-radius:4px; background:rgba(139,92,246,0.2); color:#a78bfa;
  border:1px solid rgba(139,92,246,0.3); vertical-align:middle; margin-left:4px;
}

.module-manage {
  margin-top: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  animation: fade 0.2s ease;
}
.module-manage-head { margin-bottom: 1rem; display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:0.5rem; }
.module-manage-head h3 { font-size: 0.95rem; font-weight: 600; }
.module-manage-head .text-muted { display:block; width:100%; }
.mm-head-actions { flex-shrink:0; }
.module-manage-list { display: flex; flex-direction: column; gap: 6px; }
.module-manage-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.65rem 0.75rem; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  transition: border-color var(--ease);
}
.module-manage-item:hover { border-color: var(--border-hover); }
.module-manage-item.mm-off { opacity: 0.5; }
.mm-info { display: flex; align-items: center; gap: 0.65rem; }
.mm-icon { width: 32px; height: 32px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); display: grid; place-items: center; color: var(--text-2); flex-shrink: 0; }
.mm-icon svg { width: 16px; height: 16px; }
.mm-info strong { font-size: 0.85rem; font-weight: 600; display: block; }
.mm-cat { font-size: 0.65rem; color: var(--text-3); }
.mm-actions { display:flex; align-items:center; gap:6px; }
.mm-btn {
  width:28px; height:28px; border-radius:6px; border:1px solid var(--border);
  background:var(--surface); color:var(--text-2); cursor:pointer;
  display:grid; place-items:center; font-size:0.8rem;
  transition:color var(--ease), border-color var(--ease);
}
.mm-btn:hover { color:var(--text); border-color:var(--border-hover); }
.mm-btn-del { color:#f87171; border-color:transparent; background:rgba(239,68,68,0.12); }
.mm-btn-del:hover { background:rgba(239,68,68,0.2); color:#ef4444; }
.mm-toggle { position: relative; display: inline-block; width: 38px; height: 22px; cursor: pointer; }
.mm-toggle input { display: none; }
.mm-slider {
  position: absolute; inset: 0; background: var(--border); border-radius: 22px; transition: 0.2s;
}
.mm-slider::before {
  content: ''; position: absolute; width: 18px; height: 18px; left: 2px; bottom: 2px;
  background: var(--text); border-radius: 50%; transition: 0.2s;
}
.mm-toggle input:checked + .mm-slider { background: var(--accent); }
.mm-toggle input:checked + .mm-slider::before { transform: translateX(16px); }
.mm-toggle input:disabled + .mm-slider { opacity:0.4; cursor:not-allowed; }

.modal-overlay {
  position:fixed; inset:0; z-index:300;
  background:rgba(0,0,0,0.7); display:flex;
  align-items:center; justify-content:center;
  padding:1rem; animation:fade 0.15s ease;
}
.modal-box {
  background:var(--surface); border:1px solid var(--border-hover);
  border-radius:var(--radius); width:100%; max-width:520px;
  max-height:90vh; overflow-y:auto; box-shadow:0 20px 60px rgba(0,0,0,0.4);
}
.modal-head {
  display:flex; justify-content:space-between; align-items:center;
  padding:1rem 1.25rem; border-bottom:1px solid var(--border);
}
.modal-head h3 { font-size:1rem; font-weight:600; }
.modal-close { background:none; border:none; color:var(--text-2); font-size:1.5rem; cursor:pointer; padding:0; line-height:1; }
.modal-close:hover { color:var(--text); }
.modal-body { padding:1.25rem; display:flex; flex-direction:column; gap:0.75rem; }
.modal-foot { display:flex; gap:0.5rem; justify-content:flex-end; padding:1rem 1.25rem; border-top:1px solid var(--border); }
.mf-field { display:flex; flex-direction:column; gap:0.25rem; flex:1; }
.mf-field label { font-size:0.75rem; color:var(--text-2); font-weight:500; }
.mf-row { display:flex; gap:0.75rem; }

.cat-manage summary { padding:0.25rem 0; }
.cat-item {
  display:flex; align-items:center; justify-content:space-between;
  padding:0.4rem 0.6rem; border-radius:6px; margin-bottom:4px;
  background:var(--surface-2); border:1px solid var(--border);
  font-size:0.8rem;
}
.cat-item code { font-size:0.7rem; color:var(--text-3); }

.gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: rgba(9, 9, 11, 0.92);
  backdrop-filter: blur(8px);
}

.gate.hidden { display: none; }
body:has(.gate:not(.hidden)) .app,
body:has(.gate:not(.hidden)) .corner-mascot {
  display: none;
}

.gate-card {
  width: 100%;
  max-width: 360px;
  padding: 2.5rem 2rem;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  position: relative;
  overflow: hidden;
}

.gate-card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(from 0deg at 50% 50%, transparent, rgba(59,130,246,0.08), transparent, rgba(139,92,246,0.08), transparent);
  animation: gateSpin 6s linear infinite;
  pointer-events: none;
}

@keyframes gateSpin { to { transform: rotate(360deg); } }

.gate-card-inner {
  position: relative;
  z-index: 1;
}

.gate-mark {
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 1.35rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 0 24px var(--accent-glow);
}

.gate-card h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.35rem;
}

.gate-card p {
  font-size: 0.9rem;
  color: var(--text-2);
  margin-bottom: 1.75rem;
}

.gate-card input {
  width: 100%;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--ease);
}

.gate-card input:focus { border-color: var(--accent); }

.text-muted { color: var(--text-2); font-size: 0.85rem; }
.hidden { display: none !important; }

.api-docs {
  margin-top: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: border-color var(--ease);
}
.api-docs:hover { border-color: var(--border-hover); }
.api-docs summary {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--accent);
  cursor: pointer;
  user-select: none;
}
.api-docs[open] { border-color: var(--border-hover); }
.api-docs-body {
  margin-top: 1rem;
  font-size: 0.85rem;
  line-height: 1.65;
  color: var(--text-2);
}
.api-docs-body p { margin: 0.75rem 0 0.35rem; }
.api-docs-body p:first-child { margin-top: 0; }
.api-docs-body pre {
  background: var(--bg);
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  line-height: 1.5;
  overflow-x: auto;
  border: 1px solid var(--border);
  color: var(--text-2);
  font-family: ui-monospace, monospace;
}
.api-docs-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}
.api-docs-body code {
  color: var(--accent);
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
}
.btn-dismiss {
  margin-top: 0.75rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.4rem 1rem;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: color var(--ease), border-color var(--ease);
}
.btn-dismiss:hover { color: var(--text); border-color: var(--border-hover); }

html { scroll-behavior: smooth; }
::selection { background: rgba(59, 130, 246, 0.3); color: #fff; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

.profile-head {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 2rem 0 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.profile-avatar-wrap {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 2px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-2);
  overflow: hidden;
  flex-shrink: 0;
  transition: border-color var(--ease);
  position: relative;
  background-size: cover;
  background-position: center;
}
.profile-avatar-wrap:hover { border-color: var(--accent); }
.profile-avatar-wrap .avatar-hint {
  position: absolute;
  bottom: -4px;
  right: -4px;
  background: var(--accent);
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  opacity: 0;
  transition: opacity var(--ease);
  pointer-events: none;
}
.profile-avatar-wrap:hover .avatar-hint { opacity: 1; }

.profile-info h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 0.2rem; }

.profile-body { max-width: 520px; }

.profile-section {
  margin-bottom: 1.5rem;
}
.profile-section h3 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: 0.75rem;
}

.profile-field { margin-bottom: 1rem; }
.profile-field label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-2);
  margin-bottom: 0.3rem;
}
.profile-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--ease);
}
.profile-input:focus { border-color: var(--accent); }
.profile-hint { font-size: 0.7rem; color: var(--text-3); margin-top: 0.3rem; }

.profile-theme-toggle {
  display: flex;
  gap: 4px;
  background: var(--surface);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border);
  width: fit-content;
}
.profile-theme-btn {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.4rem 1rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
}
.profile-theme-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.profile-theme-btn:hover:not(.active) { color: var(--text); }

.profile-stats {
  display: flex;
  gap: 1.5rem;
}
.profile-stat {
  text-align: center;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex: 1;
}
.profile-stat-val {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
}
.profile-stat-label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-3);
  margin-top: 0.2rem;
}

.profile-actions {
  display: flex;
  gap: 0.75rem;
  padding-top: 0.5rem;
}
.profile-actions .btn-primary { width: auto; padding: 0.6rem 1.5rem; }

.mascot-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.mascot-item {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.mascot-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: pointer;
  image-rendering: auto;
}

.mascot-del {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: #ef4444;
  color: #fff;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

.mascot-item:hover .mascot-del {
  opacity: 1;
}

.mascot-add-row {
  display: flex;
  gap: 0.5rem;
}

.mascot-add-row .profile-input {
  flex: 1;
}

.mascot-add-row .btn-primary {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
}

.mascot-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-2);
  cursor: pointer;
}

.mascot-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.km-head { margin-bottom: 1rem; }
.km-head h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 0.2rem; }

.km-toolbar { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 1.25rem; flex-wrap: wrap; }
.km-toolbar .btn-primary { margin-left: 0; }

.km-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.km-table th, .km-table td { padding: 0.65rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.km-table th { background: var(--surface-2); color: var(--text-3); font-weight: 600; text-transform: uppercase; font-size: 0.65rem; letter-spacing: 0.06em; }
.km-table tr:last-child td { border-bottom: none; }
.km-table tr:hover td { background: var(--surface-2); }
.km-table .km-key { font-family: ui-monospace, monospace; font-size: 0.75rem; color: var(--accent); }
.km-table .km-badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.65rem; font-weight: 600; }
.km-table .km-badge-vip { background: rgba(139,92,246,0.15); color: #a78bfa; border: 1px solid rgba(139,92,246,0.3); }
.km-table .km-badge-basic { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.km-table .km-badge-active { background: rgba(34,197,94,0.15); color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }
.km-table .km-badge-inactive { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.km-table .km-btn { padding: 0.25rem 0.6rem; font-size: 0.7rem; border-radius: 6px; font-weight: 500; cursor: pointer; font: inherit; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); transition: color var(--ease), border-color var(--ease); }
.km-table .km-btn:hover { color: var(--text); border-color: var(--border-hover); }
.km-table .km-btn-danger { background: rgba(239,68,68,0.15); color: #f87171; border-color: transparent; }
.km-table .km-btn-danger:hover { background: rgba(239,68,68,0.25); }

.km-info-wrap { position: relative; display: inline-block; }
.km-info-btn { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-3); font-size: 11px; font-weight: 700; cursor: pointer; transition: color var(--ease), border-color var(--ease); }
.km-info-btn:hover { color: var(--accent); border-color: var(--accent); }
.km-tooltip { position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); background: var(--surface); border: 1px solid var(--border-hover); border-radius: var(--radius-sm); padding: 0.75rem; font-size: 0.75rem; color: var(--text-2); white-space: nowrap; box-shadow: 0 8px 24px rgba(0,0,0,0.3); z-index: 50; display: none; pointer-events: none; }
.km-tooltip::after { content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 6px solid transparent; border-top-color: var(--border-hover); }
.km-info-wrap:hover .km-tooltip { display: block; }
.km-tooltip dt { font-weight: 600; color: var(--text); margin-top: 0.4rem; }
.km-tooltip dt:first-child { margin-top: 0; }
.km-tooltip dd { margin-left: 0; color: var(--text-3); font-family: ui-monospace, monospace; font-size: 0.65rem; }

@media (max-width: 768px) {
  .km-table { font-size: 0.75rem; }
  .km-table th, .km-table td { padding: 0.4rem 0.5rem; }
  .km-table .km-key { font-size: 0.65rem; }
  .km-toolbar { flex-direction: column; align-items: stretch; }
  .km-toolbar .search { max-width: 100%; }
  #kmGenerateForm > div:first-child { grid-template-columns: 1fr; }
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  z-index: 10000;
  padding: 0.75rem 1.1rem;
  font-size: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: toastIn 0.3s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 49;
}

.sidebar-toggle {
  display: none;
  width: 36px;
  height: 36px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-2);
  cursor: pointer;
  flex-shrink: 0;
  transition: color var(--ease), border-color var(--ease);
}
.sidebar-toggle:hover { color: var(--text); border-color: var(--border-hover); }
.sidebar-toggle svg { width: 100%; height: 100%; }

@media (max-width: 768px) {
  .sidebar-toggle { display: grid; place-items: center; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay.active { display: block; }

  .main { margin-left: 0; margin-right: 0; width: 100%; padding: 1rem; }
  .header { flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1.25rem; }
  .header-text h1 { font-size: 1.2rem; }
  .header-text p { font-size: 0.8rem; }

  .hero { padding: 1rem 0 1.25rem; margin-bottom: 1.25rem; }
  .hero-greet { font-size: 1.35rem; }
  .hero-sub { font-size: 0.85rem; }
  .hero-tags { width: 100%; justify-content: flex-start; }

  .metrics { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; margin-bottom: 1.25rem; }
  .metric { padding: 0.85rem 1rem; }
  .metric-value { font-size: 1.2rem; }
  .metric-label { font-size: 0.7rem; }

  .layout-split { grid-template-columns: 1fr; }
  .surface:not(.surface-wide) { grid-column: 1; }

  .chart { height: 100px; gap: 4px; }

  .search { max-width: 100%; }
  .modules-grid { grid-template-columns: 1fr; }
  .module-card:hover { transform: none; box-shadow: none; }

  .gate-card { max-width: 320px; padding: 2rem 1.25rem; }
  .gate-mark { width: 44px; height: 44px; font-size: 1.1rem; }
  .gate-card h2 { font-size: 1.2rem; }
  .gate-card input { font-size: 0.9rem; padding: 0.65rem 0.85rem; }

  .corner-mascot { width: 140px; bottom: -6px; right: -12px; }

  .profile-head { flex-direction: column; text-align: center; gap: 1rem; }
  .profile-avatar-wrap { width: 72px; height: 72px; font-size: 1.5rem; }
  .profile-info h2 { font-size: 1.1rem; }
  .profile-stats { gap: 0.5rem; }
  .profile-stat { padding: 0.75rem; }

  .mascot-item { width: 48px; height: 48px; }

  .surface { padding: 1rem; }
  .surface-head { margin-bottom: 0.75rem; }
  .surface-head h2 { font-size: 0.8rem; }
}

@media (max-width: 480px) {
  .main { padding: 0.75rem; }
  .header { margin-bottom: 1rem; }
  .header-text h1 { font-size: 1rem; }
  .header-text p { font-size: 0.75rem; }

  .hero-greet { font-size: 1.1rem; }
  .hero-sub { font-size: 0.8rem; }

  .metrics { grid-template-columns: repeat(2, 1fr); gap: 0.4rem; }
  .metric { padding: 0.7rem 0.75rem; }
  .metric-value { font-size: 1rem; }

  .chart { height: 80px; gap: 3px; }
  .chart-day { font-size: 0.55rem; }

  .modules-grid { gap: 0.5rem; }
  .module-card { padding: 0.85rem; gap: 0.5rem; }
  .module-card h3 { font-size: 0.85rem; }
  .module-desc { font-size: 0.78rem; }
  .module-open { font-size: 0.75rem; padding: 0.4rem 0.75rem; }

  .gate-card { max-width: 280px; padding: 1.5rem 1rem; }
  .gate-card h2 { font-size: 1rem; }
  .gate-card p { font-size: 0.8rem; margin-bottom: 1.25rem; }

  .corner-mascot { width: 100px; bottom: -4px; right: -8px; }

  .profile-head { padding: 1rem 0; }
  .profile-avatar-wrap { width: 60px; height: 60px; font-size: 1.25rem; }
  .profile-stats { flex-direction: column; gap: 0.4rem; }
  .profile-stat { padding: 0.6rem; display: flex; justify-content: space-between; align-items: center; }
  .profile-stat-val { font-size: 1rem; display: inline; }
  .profile-stat-label { display: inline; margin-top: 0; margin-left: 0.5rem; }

  .profile-actions { flex-direction: column; }
  .profile-actions .btn-primary { width: 100%; text-align: center; }

  .mascot-item { width: 40px; height: 40px; }
}
