/* ===== Shared Base Styles ===== */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400..600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

/* ===== CSS Variables ===== */
:root {
  /* Typography */
  --sans: 'Inter', 'Helvetica Neue', -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;

  /* Grays (refined scale) */
  --black:       #0a0a0a;
  --white:       #ffffff;
  --gray-50:     #fafaf9;
  --gray-100:    #f5f5f4;
  --gray-200:    #e7e5e4;
  --gray-300:    #d6d3d1;
  --gray-400:    #a8a29e;
  --gray-500:    #8c8a87;
  --gray-600:    #6b6663;
  --gray-700:    #57534e;
  --gray-900:    #1c1917;
  --gray-950:    #0c0a09;

  /* Semantic */
  --red:         #dc2626;
  --green:       #16a34a;
  --blue:        #2563eb;
  --blue-light:  #eff6ff;

  /* Spacing scale */
  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  12px;
  --space-lg:  16px;
  --space-xl:  24px;
  --space-2xl: 32px;
  --space-3xl: 48px;

  /* Radius scale */
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;
  --radius-xl:   20px;
  --radius-full: 9999px;

  /* Shadows (black w/ subtle transparency) */
  --shadow-xs:  0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:  0 12px 24px rgba(0,0,0,0.07), 0 4px 8px rgba(0,0,0,0.04);
  --shadow-xl:  0 24px 48px rgba(0,0,0,0.08), 0 8px 16px rgba(0,0,0,0.04);

  /* Transitions */
  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-in-out:  cubic-bezier(0.65, 0, 0.35, 1);
  --duration-fast:   120ms;
  --duration-normal: 200ms;
  --duration-slow:   350ms;

  /* Glass effect */
  --glass-bg:     rgba(255,255,255,0.72);
  --glass-border: rgba(0,0,0,0.06);
  --glass-blur:   12px;
  --glass-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 8px 32px rgba(0,0,0,0.06);
}

/* ===== Dark Theme ===== */
:root[data-theme="dark"] {
  --black:       #f5f5f4;   /* 强调色 → 暗色下变亮（按钮/聚焦/进度条） */
  --white:       #1c1917;   /* 卡片底 → 深石色 */
  --gray-50:     #131110;   /* 页面底 */
  --gray-100:    #292524;   /* 表面 */
  --gray-200:    #3a3633;   /* 边框 */
  --gray-300:    #57534e;
  --gray-400:    #8c8a87;
  --gray-500:    #a8a29e;   /* 次要文字 → 提亮 */
  --gray-600:    #c4c0bc;
  --gray-700:    #d6d3d1;
  --gray-900:    #f5f5f4;   /* 正文 → 亮色 */
  --gray-950:    #000000;

  --blue-light:  #1e293b;   /* 浅蓝底 → 深蓝灰 */

  --glass-bg:     rgba(28,25,23,0.72);
  --glass-border: rgba(255,255,255,0.08);

  --shadow-xs:  0 1px 2px rgba(0,0,0,0.3);
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.45), 0 2px 4px rgba(0,0,0,0.3);
  --shadow-lg:  0 12px 24px rgba(0,0,0,0.5), 0 4px 8px rgba(0,0,0,0.3);
  --shadow-xl:  0 24px 48px rgba(0,0,0,0.55), 0 8px 16px rgba(0,0,0,0.3);
}
:root[data-theme="dark"] ::selection { background: rgba(255,255,255,0.18); color: var(--white); }
:root[data-theme="dark"] input:focus,
:root[data-theme="dark"] textarea:focus,
:root[data-theme="dark"] select:focus { box-shadow: 0 0 0 3px rgba(255,255,255,0.12); }
:root[data-theme="dark"] .warning-msg { background: #422006; border-color: #854d0e; color: #fde68a; }
:root[data-theme="dark"] .error-msg   { background: #450a0a; border-color: #991b1b; color: #fecaca; }
:root[data-theme="dark"] .success-msg { background: #052e16; border-color: #166534; color: #bbf7d0; }

/* ===== Animations ===== */
@keyframes fadeUp   { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn   { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp  { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn  { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: scale(1); } }
@keyframes shimmer  { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.3); }
  50%      { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}

/* ===== Utility Classes ===== */
.hidden { display: none !important; }

/* ===== Base Card ===== */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration-normal) var(--ease-out),
              border-color var(--duration-normal) var(--ease-out),
              transform var(--duration-normal) var(--ease-out);
}
.card:hover {
  border-color: var(--gray-300);
  box-shadow: var(--shadow-md);
}

/* ===== Message Styles ===== */
.warning-msg {
  background: #fffbeb; border: 1px solid #fcd34d;
  padding: 10px 14px; font-size: 12px; color: #92400e;
  border-radius: var(--radius-sm); margin-top: 12px;
}
.error-msg {
  background: #fef2f2; border: 1px solid #fecaca;
  padding: 10px 14px; font-size: 12px; color: #991b1b;
  border-radius: var(--radius-sm); margin-top: 12px;
}
.success-msg {
  background: #f0fdf4; border: 1px solid #bbf7d0;
  padding: 10px 14px; font-size: 12px; color: #166534;
  border-radius: var(--radius-sm); margin-top: 12px;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }

/* ===== Selection ===== */
::selection { background: rgba(0,0,0,0.12); color: var(--black); }

/* ===== Lucide Icon Helpers ===== */
i.lucide {
  display: inline-flex; align-items: center; justify-content: center;
  vertical-align: -0.125em;
  flex-shrink: 0;
  margin-right: 0.3em;
}
i.lucide:last-child { margin-right: 0; }
i.lucide svg { display: block; }
i.lucide.icon-xs svg { width: 12px; height: 12px; }
i.lucide.icon-sm svg { width: 14px; height: 14px; }
i.lucide.icon-md svg { width: 16px; height: 16px; }
i.lucide.icon-lg svg { width: 20px; height: 20px; }
i.lucide.icon-xl svg { width: 24px; height: 24px; }
i.lucide.icon-2xl svg { width: 36px; height: 36px; }
/* standalone / no-text icons */
i.lucide.icon-only { margin-right: 0; }

/* ===== Focus ===== */
:focus-visible { outline: 2px solid var(--black); outline-offset: 2px; border-radius: 2px; }

/* ===== Button Base ===== */
button {
  cursor: pointer; font-family: inherit; color: inherit;
  transition: all var(--duration-fast) var(--ease-out);
}
button:active { transform: scale(0.97); }

/* ===== Input Base ===== */
input, textarea, select {
  font-family: inherit;
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--black);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.08);
}

/* ===== Skeleton Loading ===== */
.skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-50) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

/* ===== slot-text Required Styles ===== */
.slot-text {
  display: inline-flex;
  white-space: pre;
}
button.slot-text {
  justify-content: center;
  align-items: center;
  display: inline-flex;
}
.char-slot {
  position: relative;
  display: inline-flex;
  flex: none;
  justify-content: center;
  overflow: hidden;
  overflow-x: visible;
  overflow-y: clip;
  line-height: 1.3;
  vertical-align: bottom;
}
.char-slot.is-resizing { overflow-x: clip; }
.char-sizer {
  visibility: hidden;
  white-space: pre;
}
.char-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: pre;
  will-change: transform;
}
