/* =========================================================
   Manus‑Like UI Kit for Bulma (Optimized)
   - Modern / Minimal / Rounded / Gray-scale / Low-noise
   - Prefers borders + spacing over shadows
   - Skeleton-first loading states
   ========================================================= */

:root {
  /* Backgrounds */
  --ui-bg: #f7f7f8;              /* app 背景 */
  --ui-surface: #ffffff;         /* 面板/卡片 */
  --ui-surface-2: #fbfbfc;       /* 次级面板 */

  /* Text (gray scale) */
  --ui-text: #111214;
  --ui-text-2: #5b6068;
  --ui-text-3: #8b9098;

  /* Border */
  --ui-border: #e6e7eb;
  --ui-border-2: #eff0f3;

  /* Shadows (keep subtle; many surfaces should be shadowless) */
  --ui-shadow-sm: 0 1px 4px rgba(16, 24, 40, 0.06);
  --ui-shadow: 0 4px 14px rgba(16, 24, 40, 0.08);

  /* Radius (consistent, not too soft) */
  --ui-radius: 14px;
  --ui-radius-sm: 12px;
  --ui-radius-xs: 10px;

  /* Spacing */
  --ui-gap: 16px;

  /* Accent (still grayscale) */
  --ui-accent: #2a2d33;          /* primary button */
  --ui-accent-hover: #1f2228;

  /* Input */
  --ui-input-bg: #ffffff;
  --ui-input-border: #d9dbe1;
  --ui-input-focus-ring: rgba(42, 45, 51, 0.18);

  /* Skeleton */
  --ui-skeleton: #eceef1;

  /* Status */
  --ui-danger: #c0392b;
  
  /* 字体大小系统 - 按优先级 */
  --font-size-xs: 11px;
  --font-size-sm: 12px;
  --font-size-base: 14px;
  --font-size-md: 16px;
  --font-size-lg: 18px;
  --font-size-xl: 20px;
  --font-size-xxl: 24px;
  --font-size-huge: 28px;
}

/* Dark mode (opt-in): <html data-theme="dark"> */
html[data-theme="dark"] {
  --ui-bg: #0f1115;
  --ui-surface: #141722;
  --ui-surface-2: #10131b;

  --ui-text: #eceef2;
  --ui-text-2: #b3b8c2;
  --ui-text-3: #8b9098;

  --ui-border: #232735;
  --ui-border-2: #1b1f2c;

  --ui-shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.35);
  --ui-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);

  --ui-accent: #eceef2;
  --ui-accent-hover: #ffffff;

  --ui-input-bg: #10131b;
  --ui-input-border: #2a2f40;
  --ui-input-focus-ring: rgba(236, 238, 242, 0.16);

  --ui-skeleton: #1e2230;
}

/* Base */
html, body {
  background: var(--ui-bg);
  color: var(--ui-text);
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Typography (Bulma tweaks) */
.title, .subtitle, .label { color: var(--ui-text); }
.help, .has-text-grey { color: var(--ui-text-2) !important; }

/* Global rounded system */
.button,
.input,
.textarea,
.select select,
.box,
.card,
.notification,
.dropdown-content,
.menu-list a,
.modal-card,
.tag {
  border-radius: var(--ui-radius-xs);
}

hr {
  background: transparent;
  border: 0;
  border-top: 1px solid var(--ui-border);
}

/* Reduce Bulma defaults */
.button { box-shadow: none !important; }
.card { box-shadow: none; }

/* =========================================================
   Layout Shell (Legacy - kept for backward compatibility)
   ========================================================= */

.ui-shell {
  display: grid;
  grid-template-columns: 276px 1fr;
  min-height: 100vh;
}

.ui-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--ui-surface);
  border-right: 1px solid var(--ui-border);
  padding: 16px 12px;
  overflow-y: auto;
}

.ui-main { min-width: 0; }

.ui-content {
  padding: 18px;
  max-width: 1120px; /* 让内容更"工具感/可读" */
}

@media (max-width: 980px) {
  .ui-shell { grid-template-columns: 1fr; }
  .ui-sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--ui-border);
  }
}

/* =========================================================
   Release 3.5 Layout Structure
   ========================================================= */

/* Header */
.header {
  background: var(--ui-surface);
  border-bottom: 1px solid var(--ui-border);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 1000;
  flex-shrink: 0;
}

.header-content {
  max-width: 100%;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin: 0;
  color: var(--ui-text);
  background: linear-gradient(135deg, var(--ui-accent) 0%, var(--ui-accent-hover) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.feedback-btn,
.developer-btn,
.changelog-btn,
.redeem-code-btn {
  color: var(--ui-text-2);
  text-decoration: none;
  padding: 8px 16px;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  transition: all 0.2s;
  font-size: var(--font-size-base);
  background: transparent;
  cursor: pointer;
  font-family: inherit;
}

.feedback-btn:hover,
.developer-btn:hover,
.changelog-btn:hover,
.redeem-code-btn:hover {
  background: var(--ui-surface-2);
  border-color: var(--ui-border);
  color: var(--ui-text);
}

html[data-theme="dark"] .feedback-btn:hover,
html[data-theme="dark"] .developer-btn:hover,
html[data-theme="dark"] .changelog-btn:hover,
html[data-theme="dark"] .redeem-code-btn:hover {
  background: rgba(255,255,255,0.05);
}

.logout-btn {
  color: var(--ui-text-2);
  text-decoration: none;
  padding: 8px 16px;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  transition: all 0.2s;
  font-size: var(--font-size-base);
  background: transparent;
  display: inline-block;
}

.logout-btn:hover {
  background: var(--ui-surface-2);
  border-color: var(--ui-border);
  color: var(--ui-text);
}

html[data-theme="dark"] .logout-btn:hover {
  background: rgba(255,255,255,0.05);
}

/* Main Layout */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 240px;
  min-width: 180px;
  max-width: 400px;
  background: var(--ui-surface);
  border-right: 1px solid var(--ui-border);
  overflow-y: auto;
  overflow-x: hidden;
  height: calc(100vh - 60px);
  position: sticky;
  top: 60px;
  resize: horizontal;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  will-change: auto;
  transform: translateZ(0);
}

.sidebar-resizer {
  width: 4px;
  background: var(--ui-border);
  cursor: col-resize;
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 10;
  transition: background 0.2s;
}

.sidebar-resizer:hover {
  background: var(--ui-accent);
}

.sidebar-nav {
  padding: 16px 0;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 0;
  box-sizing: border-box;
  scroll-behavior: auto;
}

.sidebar-nav .menu-label {
  display: block;
  padding: 12px 20px;
  color: var(--ui-text-3);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0;
}

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

.sidebar-item {
  margin-bottom: 4px;
  display: block;
  visibility: visible;
  opacity: 1;
  height: auto;
  min-height: auto;
}

.sidebar-link {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  color: var(--ui-text-2);
  text-decoration: none;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.sidebar-link:hover {
  background: rgba(0,0,0,0.03);
  color: var(--ui-text);
}

html[data-theme="dark"] .sidebar-link:hover {
  background: rgba(255,255,255,0.05);
}

.sidebar-item.active .sidebar-link {
  background: rgba(0,0,0,0.035);
  color: var(--ui-text);
  border-left-color: var(--ui-accent);
  font-weight: 600;
  box-sizing: border-box;
}

html[data-theme="dark"] .sidebar-item.active .sidebar-link {
  background: rgba(255,255,255,0.06);
}

.sidebar-icon {
  font-size: var(--font-size-lg);
  margin-right: 12px;
  width: 24px;
  text-align: center;
}

.sidebar-text {
  flex: 1;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--ui-border-2);
  margin-top: auto;
}

/* Sidebar Group (Collapsible) */
.sidebar-group {
  margin-bottom: 4px;
  display: block;
  visibility: visible;
  position: relative;
  width: 100%;
  box-sizing: border-box;
}

.sidebar-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  color: var(--ui-text-2);
  cursor: pointer;
  transition: all 0.2s;
  border-left: 3px solid transparent;
  user-select: none;
}

.sidebar-group-header:hover {
  background: rgba(0,0,0,0.03);
  color: var(--ui-text);
}

html[data-theme="dark"] .sidebar-group-header:hover {
  background: rgba(255,255,255,0.05);
}

.sidebar-group.active .sidebar-group-header {
  background: rgba(0,0,0,0.035);
  color: var(--ui-text);
  border-left-color: var(--ui-accent);
}

html[data-theme="dark"] .sidebar-group.active .sidebar-group-header {
  background: rgba(255,255,255,0.06);
}

.sidebar-group-arrow {
  font-size: var(--font-size-xs);
  transition: transform 0.2s;
  color: var(--ui-text-3);
}

.sidebar-group.active .sidebar-group-arrow {
  transform: rotate(90deg);
  color: var(--ui-accent);
}

.sidebar-submenu {
  list-style: none;
  display: none;
  padding: 0;
  margin: 0;
  height: 0;
  overflow: hidden;
  opacity: 0;
  position: relative;
  width: 100%;
  box-sizing: border-box;
}

.sidebar-group.active .sidebar-submenu {
  display: block;
  height: auto;
  opacity: 1;
  margin: 0;
  padding: 0;
  position: relative;
  width: 100%;
  box-sizing: border-box;
}

.sidebar-subitem {
  margin-bottom: 2px;
  display: block;
  visibility: visible;
  opacity: 1;
  height: auto;
  min-height: auto;
  position: relative;
  width: 100%;
  box-sizing: border-box;
}

.sidebar-subitem .sidebar-link {
  padding: 10px 20px 10px 40px;
  font-size: var(--font-size-base);
}

.sidebar-subitem.active .sidebar-link {
  background: rgba(0,0,0,0.035);
  color: var(--ui-text);
  border-left-color: var(--ui-accent);
}

html[data-theme="dark"] .sidebar-subitem.active .sidebar-link {
  background: rgba(255,255,255,0.06);
}

/* Main Content */
.main-content {
  flex: 1;
  overflow-y: auto;
  background: var(--ui-bg);
  min-height: calc(100vh - 60px);
}

/* Responsive */
@media (max-width: 980px) {
  .main-layout {
    flex-direction: column;
  }
  
  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
    top: 0;
    border-right: 0;
    border-bottom: 1px solid var(--ui-border);
    resize: none;
  }
  
  .main-content {
    min-height: auto;
  }
}

/* =========================================================
   Sidebar
   ========================================================= */

.ui-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 10px;
}

.ui-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--ui-accent);
  color: var(--ui-surface);
  font-weight: 800;
}

html[data-theme="dark"] .ui-logo {
  background: var(--ui-accent);
  color: #0f1115;
}

.ui-brand-title { font-weight: 800; line-height: 1.1; }
.ui-brand-sub { font-size: var(--font-size-sm); color: var(--ui-text-2); }

.menu-label {
  color: var(--ui-text-3);
  letter-spacing: 0.02em;
}

.menu-list a {
  padding: 10px 12px;
  color: var(--ui-text-2);
  border: 1px solid transparent;
}

.menu-list a:hover {
  background: rgba(0,0,0,0.03);
  color: var(--ui-text);
}

html[data-theme="dark"] .menu-list a:hover {
  background: rgba(255,255,255,0.05);
}

.menu-list a.is-active {
  background: rgba(0,0,0,0.035);
  color: var(--ui-text);
  border-color: var(--ui-border);
  font-weight: 700;
}

html[data-theme="dark"] .menu-list a.is-active {
  background: rgba(255,255,255,0.06);
}

.ui-sidebar-footer {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
}

@media (max-width: 980px) {
  .ui-sidebar-footer { position: static; margin-top: 12px; }
}

/* =========================================================
   Topbar
   ========================================================= */

.ui-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-gap);
  padding: 16px 18px;
  background: var(--ui-surface);
  border-bottom: 1px solid var(--ui-border);
}

.ui-search .input {
  border: 1px solid var(--ui-input-border);
  background: var(--ui-input-bg);
}

.ui-topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ui-avatar {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--ui-bg);
  border: 1px solid var(--ui-border);
  font-weight: 800;
}

/* =========================================================
   Buttons
   ========================================================= */

.ui-btn {
  border: 1px solid transparent;
  font-weight: 700;
}

.ui-btn-primary {
  background: var(--ui-accent);
  color: var(--ui-surface);
}

.ui-btn-primary:hover {
  background: var(--ui-accent-hover);
  color: var(--ui-surface);
}

.ui-btn-secondary {
  background: var(--ui-surface);
  color: var(--ui-text);
  border-color: var(--ui-border);
}

.ui-btn-secondary:hover {
  background: var(--ui-surface-2);
}

.ui-btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ui-text);
}

.ui-btn-ghost:hover {
  background: rgba(0,0,0,0.03);
}

html[data-theme="dark"] .ui-btn-ghost:hover {
  background: rgba(255,255,255,0.06);
}

.ui-btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
}

.ui-btn[disabled],
.ui-btn.is-disabled {
  opacity: 0.55;
  pointer-events: none;
}

/* =========================================================
   Cards
   ========================================================= */

.ui-card {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  box-shadow: none; /* 关键：默认无阴影 */
}

/* 只有需要"浮层感"的卡片才加 */
.ui-card.is-elevated {
  box-shadow: var(--ui-shadow-sm);
}

.ui-card-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--ui-border-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ui-card-title { font-weight: 800; }

.ui-card-body { padding: 16px; }

.ui-card-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--ui-border-2);
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
}

.ui-empty {
  padding: 28px;
  text-align: center;
  color: var(--ui-text-2);
}

/* =========================================================
   Forms
   ========================================================= */

.input,
.textarea,
.select select {
  background: var(--ui-input-bg);
  border: 1px solid var(--ui-input-border);
  color: var(--ui-text);
}

.input:focus,
.textarea:focus,
.select select:focus {
  border-color: var(--ui-accent);
  box-shadow: 0 0 0 4px var(--ui-input-focus-ring);
}

.label { font-weight: 800; }

.ui-field { margin-bottom: 14px; }

.ui-help {
  margin-top: 6px;
  font-size: var(--font-size-sm);
  color: var(--ui-text-2);
}

.ui-error {
  color: var(--ui-danger);
  font-size: var(--font-size-sm);
  margin-top: 6px;
}

/* =========================================================
   Skeleton
   ========================================================= */

@keyframes uiPulse {
  0% { opacity: .55; }
  50% { opacity: 1; }
  100% { opacity: .55; }
}

.ui-skeleton {
  background: var(--ui-skeleton);
  border-radius: 10px;
  animation: uiPulse 1.35s ease-in-out infinite;
}

/* 常用尺寸组合 */
.ui-skeleton.line { height: 12px; }
.ui-skeleton.line.sm { height: 10px; }
.ui-skeleton.line.lg { height: 14px; }

.ui-skeleton.block { height: 48px; }
.ui-skeleton.card { height: 120px; }

.ui-skeleton.w-30 { width: 30%; }
.ui-skeleton.w-50 { width: 50%; }
.ui-skeleton.w-70 { width: 70%; }
.ui-skeleton.w-100 { width: 100%; }

/* =========================================================
   Modal
   ========================================================= */

.modal-background {
  background: rgba(0, 0, 0, 0.55);
}

.ui-modal-card {
  border-radius: var(--ui-radius);
  overflow: hidden;
  border: 1px solid var(--ui-border);
  box-shadow: var(--ui-shadow);
}

.ui-modal-head,
.ui-modal-foot {
  background: var(--ui-surface);
  border-color: var(--ui-border-2);
}

.ui-modal-body {
  background: var(--ui-surface);
}

/* =========================================================
   Dropdown
   ========================================================= */

.dropdown-content {
  border: 1px solid var(--ui-border);
  box-shadow: var(--ui-shadow-sm);
  background: var(--ui-surface);
}

.dropdown-item {
  padding: 10px 12px;
  color: var(--ui-text);
}

.dropdown-item:hover {
  background: rgba(0,0,0,0.03);
}

html[data-theme="dark"] .dropdown-item:hover {
  background: rgba(255,255,255,0.06);
}

/* =========================================================
   Tables
   ========================================================= */

.table {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  overflow: hidden;
}

.table thead th {
  color: var(--ui-text-2);
  font-weight: 800;
  border-bottom: 1px solid var(--ui-border-2);
  background: var(--ui-surface-2);
}

.table tbody tr:hover {
  background: rgba(0,0,0,0.02);
}

html[data-theme="dark"] .table tbody tr:hover {
  background: rgba(255,255,255,0.04);
}

/* =========================================================
   Workspace Layouts
   ========================================================= */

/* Lyrics Workspace - Left/Right Layout */
.lyrics-workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  height: calc(100vh - 60px);
  background: var(--ui-border);
}

.input-panel,
.result-panel {
  background: var(--ui-surface);
  overflow-y: auto;
  padding: 24px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--ui-border);
}

.panel-header h2 {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--ui-text);
  margin: 0;
}

.panel-subtitle {
  font-size: var(--font-size-sm);
  color: var(--ui-text-3);
  margin-top: 4px;
}

/* Analyze Workspace */
.analyze-workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  height: calc(100vh - 60px);
  background: var(--ui-border);
}

/* Music Workspace */
.music-workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  height: calc(100vh - 60px);
  background: var(--ui-border);
}

@media (max-width: 1024px) {
  .lyrics-workspace,
  .analyze-workspace,
  .music-workspace {
    grid-template-columns: 1fr;
    height: auto;
  }
  
  .input-panel,
  .result-panel {
    min-height: 400px;
  }
}
