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

:root {
  --accent-purple: #a855f7;
  --accent-cyan: #06b6d4;
  --accent-pink: #ec4899;
  --accent-orange: #f97316;
  --accent-green: #22c55e;
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --transition: 0.25s cubic-bezier(0.4,0,0.2,1);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.18);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.22);
  --shadow-lg: 0 8px 48px rgba(0,0,0,0.28);
}

/* Dark theme (default) */
:root, [data-theme="dark"] {
  --bg-base: #0a0a0f;
  --bg-surface: #111118;
  --bg-card: rgba(255,255,255,0.04);
  --bg-card-hover: rgba(255,255,255,0.07);
  --bg-input: rgba(255,255,255,0.06);
  --border: rgba(255,255,255,0.08);
  --border-focus: rgba(168,85,247,0.6);
  --text-primary: #f1f1f5;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --glass-bg: rgba(17,17,24,0.7);
  --glass-border: rgba(255,255,255,0.1);
  --nav-bg: rgba(10,10,15,0.85);
  --scrollbar-thumb: rgba(255,255,255,0.12);
}

/* Light theme */
[data-theme="light"] {
  --bg-base: #f0f2f8;
  --bg-surface: #e8eaf2;
  --bg-card: rgba(255,255,255,0.65);
  --bg-card-hover: rgba(255,255,255,0.85);
  --bg-input: rgba(255,255,255,0.8);
  --border: rgba(0,0,0,0.08);
  --border-focus: rgba(168,85,247,0.5);
  --text-primary: #1a1a2e;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  --glass-bg: rgba(240,242,248,0.75);
  --glass-border: rgba(255,255,255,0.6);
  --nav-bg: rgba(240,242,248,0.9);
  --scrollbar-thumb: rgba(0,0,0,0.15);
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  transition: background var(--transition), color var(--transition);
}

/* Uyghur / Kazakh fonts (from local assets) */
@font-face {
  font-family: 'UKIJ Esliye';
  src: url('/assets/fonts/ukij-esliya.ttf') format('truetype');
  font-weight: normal; font-style: normal;
  /* 维吾尔文、哈萨克文、阿拉伯文 Unicode 范围 */
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: 'UKIJ Esliye Chiwar';
  src: url('/assets/fonts/ukij-esliya-chiwar.ttf') format('truetype');
  font-weight: normal; font-style: normal;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: 'UKIJ Tor';
  src: url('/assets/fonts/ukij-tor.ttf') format('truetype');
  font-weight: normal; font-style: normal;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: 'UKIJ Ku';
  src: url('/assets/fonts/ukij-ku.ttf') format('truetype');
  font-weight: normal; font-style: normal;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: 'Uzluq Berg';
  src: url('/assets/fonts/uzluq-berg.otf') format('opentype');
  font-weight: normal; font-style: normal;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}

/* Minority language font assignments */
.lang-ug, .lang-kk, [lang="ug"], [lang="kk"] {
  font-family: 'UKIJ Esliye', 'UKIJ Tor', 'Scheherazade New', serif;
}
.lang-mn, [lang="mn"] {
  font-family: 'Mongolian Baiti', serif;
  writing-mode: vertical-lr;
}
.lang-bo, [lang="bo"] {
  font-family: 'Jomolhari', 'Tibetan Machine Uni', serif;
  line-height: 2;
}

/*
 * 多语言混合输入支持：
 * 无论界面语言是什么，输入框和文本域都叠加 UKIJ 字体，
 * 这样用户在中文模式下输入维吾尔文/哈萨克文时也能正确渲染。
 * 
 * 注意：UKIJ 字体通过 unicode-range 声明只处理阿拉伯/维吾尔文字符，
 * 所以必须放在字体栈最前面才能生效。
 */
textarea,
input[type="text"],
input[type="tel"],
input[type="password"],
input[type="search"],
.form-input,
.form-textarea {
  font-family: 'UKIJ Esliye', 'UKIJ Tor', 'Scheherazade New',
               'Inter', 'PingFang SC', 'Microsoft YaHei',
               'Jomolhari', 'Mongolian Baiti',
               'Helvetica Neue', sans-serif;
}

/* RTL 检测：当 textarea/input 内容触发 bidi 算法时保证排列正确 */
textarea { unicode-bidi: plaintext; }

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

/* Selection */
::selection { background: rgba(168,85,247,0.3); color: var(--text-primary); }

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

a { color: var(--accent-purple); text-decoration: none; transition: opacity var(--transition); }
a:hover { opacity: 0.8; }

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

h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); font-weight: 700; line-height: 1.2; }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 600; line-height: 1.3; }
h3 { font-size: clamp(1.1rem, 2vw, 1.4rem); font-weight: 600; }
h4 { font-size: 1rem; font-weight: 600; }

p { color: var(--text-secondary); }

.text-gradient {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.text-muted { color: var(--text-muted); font-size: 0.875rem; }

/* Utility */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.w-full { width: 100%; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.p-4 { padding: 1rem; }
.rounded { border-radius: var(--radius-md); }
