:root {
  --bg: #f5f7fa;
  --bg-elevated: #ffffff;
  --text: #212529;
  --text-muted: #6c757d;
  --primary: #4f7cff;
  --primary-hover: #3a66e0;
  --primary-soft: #eaf0ff;
  --success: #18b58b;
  --danger: #e35b5b;
  --warning: #f4a261;
  --border: #e6e8ec;
  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .06);
  --shadow: 0 4px 16px rgba(15, 23, 42, .06);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .1);
  --gradient-hero: linear-gradient(135deg, #4f7cff 0%, #6e8bff 50%, #8b5cf6 100%);
  --gradient-card-top: linear-gradient(180deg, rgba(79, 124, 255, .08) 0%, transparent 100%);
  --transition: .2s cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
::-webkit-scrollbar-track { background: transparent; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: var(--radius-sm); }

.app-navbar {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
}

.app-brand {
  font-weight: 600;
  font-size: 1.15rem;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
}

.app-nav-link {
  color: rgba(255, 255, 255, .75) !important;
  padding: .5rem .85rem !important;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  text-decoration: none;
}
.app-nav-link:hover { color: #fff !important; background: rgba(255, 255, 255, .08); }
.app-nav-link.active { color: #fff !important; background: rgba(79, 124, 255, .25); }

.skill-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: transform var(--transition), box-shadow var(--transition);
  overflow: hidden;
  position: relative;
}
.skill-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: var(--gradient-card-top);
}
.skill-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(79, 124, 255, .3);
}

.skill-card .card-body { padding: 1.1rem 1.25rem; }
.skill-card .card-footer {
  background: #fafbfc;
  border-top: 1px solid var(--border);
  padding: .75rem 1rem;
}

.skill-card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  transition: color var(--transition);
}
.skill-card-title:hover { color: var(--primary-hover); text-decoration: underline; }

.skill-version-badge {
  background: var(--primary-soft);
  color: var(--primary);
  font-size: .72rem;
  font-weight: 600;
  padding: .2rem .55rem;
  border-radius: 999px;
}

.skill-meta { color: var(--text-muted); font-size: .82rem; }
.skill-meta-icon { margin-right: .15rem; opacity: .7; }

.tag-badge {
  display: inline-block;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: .72rem;
  font-weight: 500;
  padding: .2rem .55rem;
  border-radius: 999px;
  margin: 0 .2rem .2rem 0;
}

.action-btn {
  border-radius: var(--radius-sm) !important;
  padding: .35rem .6rem !important;
  font-size: .85rem;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}
.action-btn .btn-text { display: none; }
@media (min-width: 576px) {
  .action-btn .btn-text { display: inline; }
}

.empty-state {
  padding: 4rem 1rem;
  text-align: center;
  color: var(--text-muted);
}
.empty-state svg { width: 80px; height: 80px; opacity: .35; margin-bottom: 1rem; }
.empty-state h5 { color: var(--text); margin-bottom: .5rem; }

#api-key-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #f8fafc;
  padding: .85rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  white-space: pre-wrap;
  word-break: break-all;
  font-size: .9rem;
}

.cursor-pointer { cursor: pointer; }

.skeleton {
  background: linear-gradient(90deg, #eef2f7 0%, #f7f9fc 50%, #eef2f7 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-card {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 1.25rem;
  border: 1px solid var(--border);
}
.skeleton-line { height: 12px; margin-bottom: .6rem; }

.login-hero {
  min-height: 100vh;
  background: var(--gradient-hero);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  position: relative;
  overflow: hidden;
}
.login-hero::before, .login-hero::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, .1);
  pointer-events: none;
}
.login-hero::before { width: 320px; height: 320px; top: -100px; right: -100px; }
.login-hero::after { width: 240px; height: 240px; bottom: -80px; left: -80px; }

.login-card {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  padding: 2.25rem 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}
.login-card h3 { font-weight: 700; }
.login-card .form-control {
  border-radius: var(--radius-sm);
  padding: .65rem .85rem;
  border: 1px solid var(--border);
  transition: all var(--transition);
}
.login-card .form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 124, 255, .15); }

.password-wrap { position: relative; }
.password-toggle {
  position: absolute;
  right: .6rem; top: 50%;
  transform: translateY(-50%);
  background: none; border: 0;
  color: var(--text-muted);
  padding: .25rem .4rem;
  cursor: pointer;
}
.password-toggle:hover { color: var(--primary); }

.btn-primary {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--primary-hover) !important;
  border-color: var(--primary-hover) !important;
}

.spinner-inline {
  display: inline-block;
  width: 1rem; height: 1rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spinner .6s linear infinite;
  vertical-align: -.15em;
  margin-right: .35rem;
}
@keyframes spinner { to { transform: rotate(360deg); } }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.page-header h4 { margin: 0; font-weight: 600; }
.page-header .actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  pointer-events: none;
}
.app-toast {
  pointer-events: auto;
  min-width: 260px;
  max-width: 360px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: .75rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  animation: toast-in .25s ease-out;
}
.app-toast.removing { animation: toast-out .25s ease-in forwards; }
.app-toast .toast-icon { font-size: 1.1rem; line-height: 1; }
.app-toast.success .toast-icon { color: var(--success); }
.app-toast.danger .toast-icon { color: var(--danger); }
.app-toast.info .toast-icon { color: var(--primary); }
.app-toast .toast-body { flex: 1; font-size: .9rem; }
.app-toast .toast-close { background: none; border: 0; color: var(--text-muted); cursor: pointer; padding: 0 .25rem; }
@keyframes toast-in { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toast-out { to { transform: translateX(20px); opacity: 0; } }

@media (max-width: 575.98px) {
  .toast-container { left: 1rem; right: 1rem; }
  .app-toast { min-width: 0; max-width: 100%; }
}

.log-row-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .85rem 1rem;
  margin-bottom: .5rem;
}
.log-row-card .log-action { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 600; background: var(--primary-soft); color: var(--primary); }
.log-row-card .log-time { font-size: .78rem; color: var(--text-muted); }
.log-row-card .log-meta { font-size: .82rem; color: var(--text-muted); margin-top: .35rem; }
.log-row-card .log-detail { font-size: .82rem; margin-top: .25rem; word-break: break-all; }

.file-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  text-align: center;
  background: #fafbfc;
  transition: all var(--transition);
  cursor: pointer;
}
.file-drop:hover, .file-drop.drag-over {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.file-drop input[type=file] { display: none; }
.file-drop svg { width: 40px; height: 40px; color: var(--primary); opacity: .65; margin-bottom: .5rem; }
.file-drop .file-name { font-weight: 600; color: var(--text); margin-top: .5rem; }

.muted-link { color: var(--text-muted); text-decoration: none; }
.muted-link:hover { color: var(--primary); }

@media (max-width: 767.98px) {
  .page-header h4 { font-size: 1.15rem; }
  .login-card { padding: 1.75rem 1.4rem; }
}