@import url('/typography.css');

/* ========================================================
   APPLE HUMAN INTERFACE GUIDELINES - MINIMALIST DARK THEME
   Thiết kế tối giản phong cách Apple · Tấn Công AI · Chuyên cung cấp API AI và Source giá rẻ
   ======================================================== */

:root, [data-theme="obsidian"] {
  color-scheme: dark;
  --bg: #000000;
  --bg-gradient: radial-gradient(1000px circle at 50% 0%, #151518 0%, #000000 100%) fixed;
  --sidebar-bg: rgba(18, 18, 20, 0.85);
  --surface: rgba(255, 255, 255, 0.04);
  --surface-card: rgba(28, 28, 30, 0.65);
  --surface-hover: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.08);
  --line-focus: #f5a623;
  --muted: #86868b;
  --text: #e5e5ea;
  --text-title: #f5f5f7;

  /* Apple Luxury Gold */
  --accent: #f5a623;
  --accent-light: #ffd60a;
  --accent-dark: #d48806;
  --accent-gradient: linear-gradient(135deg, #ffd60a 0%, #f5a623 100%);
  --accent-glow: rgba(245, 166, 35, 0.25);
  --accent-bg: rgba(245, 166, 35, 0.12);
  --accent-border: rgba(245, 166, 35, 0.3);

  --green: #34c759;
  --cyan: #32ade6;
  --rose: #ff375f;
  --apple-font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="emerald"] {
  --bg: #030806;
  --bg-gradient: radial-gradient(1000px circle at 50% 0%, #081a13 0%, #030806 100%) fixed;
  --sidebar-bg: rgba(7, 20, 15, 0.85);
  --surface: rgba(255, 255, 255, 0.04);
  --surface-card: rgba(14, 34, 26, 0.65);
  --surface-hover: rgba(255, 255, 255, 0.08);
  --line: rgba(52, 199, 89, 0.15);
  --accent: #30d158;
  --accent-light: #34c759;
  --accent-gradient: linear-gradient(135deg, #34c759 0%, #248a3d 100%);
  --accent-glow: rgba(48, 209, 88, 0.25);
  --accent-bg: rgba(48, 209, 88, 0.12);
  --accent-border: rgba(48, 209, 88, 0.3);
}

[data-theme="lotus"] {
  --bg: #090306;
  --bg-gradient: radial-gradient(1000px circle at 50% 0%, #1c0a13 0%, #090306 100%) fixed;
  --sidebar-bg: rgba(22, 9, 16, 0.85);
  --surface: rgba(255, 255, 255, 0.04);
  --surface-card: rgba(35, 15, 26, 0.65);
  --surface-hover: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 55, 95, 0.15);
  --accent: #ff375f;
  --accent-light: #ff6482;
  --accent-gradient: linear-gradient(135deg, #ff6482 0%, #ff375f 100%);
  --accent-glow: rgba(255, 55, 95, 0.25);
  --accent-bg: rgba(255, 55, 95, 0.12);
  --accent-border: rgba(255, 55, 95, 0.3);
}

[data-theme="imperial"] {
  --bg: #080501;
  --bg-gradient: radial-gradient(1000px circle at 50% 0%, #1a1205 0%, #080501 100%) fixed;
  --sidebar-bg: rgba(22, 16, 6, 0.85);
  --surface: rgba(255, 255, 255, 0.04);
  --surface-card: rgba(36, 26, 10, 0.65);
  --surface-hover: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 214, 10, 0.15);
  --accent: #ffd60a;
  --accent-light: #ffdf33;
  --accent-gradient: linear-gradient(135deg, #ffdf33 0%, #ffd60a 100%);
  --accent-glow: rgba(255, 214, 10, 0.25);
  --accent-bg: rgba(255, 214, 10, 0.12);
  --accent-border: rgba(255, 214, 10, 0.3);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

/* Apple-style minimalist scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.18); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.3); }

body {
  margin: 0;
  background: var(--bg-gradient);
  color: var(--text);
  font: 14px/1.6 var(--apple-font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

button, input, select, textarea { font-family: var(--apple-font); }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; outline: none; }
button:disabled { opacity: .35; cursor: not-allowed; }
[hidden] { display: none !important; }

/* ========================================================
   APPLE SIDEBAR (macOS / iPadOS Frosted Glass)
   ======================================================== */
.sidebar {
  width: 260px;
  position: fixed;
  inset: 0 auto 0 0;
  background: var(--sidebar-bg);
  backdrop-filter: blur(35px) saturate(180%);
  -webkit-backdrop-filter: blur(35px) saturate(180%);
  border-right: 1px solid var(--line);
  padding: 24px 16px 20px;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--text-title);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  padding: 6px 10px;
  margin-bottom: 8px;
}
.brand-mark {
  font-size: 26px;
  line-height: 1;
  color: var(--accent);
}
.brand small {
  display: block;
  font-size: 9px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.05em;
  margin-top: 2px;
}
.badge-pro {
  font-size: 9px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.12);
  color: var(--accent-light);
  border: 1px solid var(--accent-border);
  padding: 2px 6px;
  border-radius: 6px;
  letter-spacing: 0.05em;
  margin-left: 6px;
}

.nav-caption {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 16px 12px 6px;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 9px 12px;
  border-radius: 10px;
  color: #a1a1a6;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
}
.nav > span {
  font-size: 15px;
  width: 18px;
  text-align: center;
  opacity: 0.7;
}
.nav:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #f5f5f7;
}
.nav:hover > span { opacity: 1; color: var(--accent-light); }

.nav.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-weight: 600;
}
.nav.active > span {
  opacity: 1;
  color: var(--accent);
}

.nav-divider {
  height: 1px;
  background: var(--line);
  margin: 12px 8px;
}

/* Owner Card (Apple Profile Capsule) */
.owner-mini {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(20px);
  border-radius: 14px;
  transition: border-color 0.2s;
}
.owner-mini:hover {
  border-color: rgba(255, 255, 255, 0.16);
}
.owner-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-gradient);
  color: #000;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.owner-mini small {
  display: block;
  font-size: 8px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.05em;
}
.owner-mini strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-title);
  margin: 1px 0;
}
.owner-mini a {
  font-size: 11px;
  font-weight: 500;
  color: var(--accent-light);
}
.dev-tag {
  display: inline-block;
  font-size: 9px;
  font-weight: 600;
  color: var(--accent-light);
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-radius: 6px;
  padding: 1px 6px;
  margin-top: 3px;
}

.sidebar-foot {
  font-size: 10px;
  color: var(--muted);
  padding: 10px 4px 0;
  display: flex;
  align-items: center;
}
.local-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
  margin-right: 6px;
  box-shadow: 0 0 6px var(--green);
}

/* ========================================================
   TOPBAR (macOS Glass Header)
   ======================================================== */
main {
  margin-left: 260px;
  padding: 22px 36px 36px;
  max-width: 1720px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-left span { font-weight: 500; }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.slash {
  color: var(--muted);
  opacity: 0.4;
  margin: 0 2px;
}

.live-clock-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-title);
  font-variant-numeric: tabular-nums;
}

/* Apple Segmented Control for Themes */
.theme-selector {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 2px;
  gap: 1px;
}
.theme-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 16px;
  transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
}
.theme-btn:hover { color: #fff; }
.theme-btn.active {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* Apple Pill Button for Gõ Mõ */
.mokugyo-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  color: var(--accent-light);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 600;
  transition: all 0.2s;
}
.mokugyo-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  transform: scale(1.02);
}
.mokugyo-btn:active { transform: scale(0.97); }

.floating-merit {
  position: fixed;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-light);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  animation: floatUp 1.1s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  z-index: 1000;
}
@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0) scale(0.95); }
  50% { opacity: 0.95; transform: translateY(-28px) scale(1.08); }
  100% { opacity: 0; transform: translateY(-56px) scale(0.9); }
}

.service-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-title);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 4px 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px;
  border-radius: 20px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.status-pill:before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--muted);
  border-radius: 50%;
}
.status-pill.connected {
  background: rgba(52, 199, 89, 0.12);
  border-color: rgba(52, 199, 89, 0.3);
  color: #34c759;
}
.status-pill.connected:before {
  background: #34c759;
  box-shadow: 0 0 8px #34c759;
  animation: pulseDot 2s infinite;
}
@keyframes pulseDot {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}
.status-pill.error, .status-pill.needs_action {
  color: #ff453a;
  border-color: rgba(255, 69, 58, 0.3);
  background: rgba(255, 69, 58, 0.1);
}
.status-pill.retry, .status-pill.connecting, .status-pill.waiting {
  color: #ffd60a;
  border-color: rgba(255, 214, 10, 0.3);
  background: rgba(255, 214, 10, 0.1);
}

/* ========================================================
   PAGE HEADER (Apple Clean Title)
   ======================================================== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 0 22px;
}
.eyebrow, .section-kicker {
  font-size: 10px;
  letter-spacing: 0.08em;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent);
}
.eyebrow { margin-bottom: 4px; }
h1 {
  font-size: 26px;
  letter-spacing: -0.025em;
  line-height: 1.3;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text-title);
}
.page-header p {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}
.header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* Apple Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-title);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
}
.button:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}
.button.gold {
  background: #f5a623;
  border: 1px solid #ffd60a;
  color: #000000;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(245, 166, 35, 0.25);
}
.button.gold:hover {
  background: #ffb833;
  box-shadow: 0 4px 16px rgba(245, 166, 35, 0.4);
}
.button.secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  color: var(--text);
}
.button.danger {
  border-color: rgba(255, 69, 58, 0.4);
  color: #ff6961;
  background: rgba(255, 69, 58, 0.1);
}
.button.danger:hover {
  background: rgba(255, 69, 58, 0.2);
  color: #fff;
}

/* ========================================================
   CARDS & STATS (Apple Frosted Glass Cards)
   ======================================================== */
.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(280px, 340px);
  gap: 24px;
  align-items: start;
}
.pages { min-width: 0; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.stat {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 18px;
  background: var(--surface-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
}
.stat:hover {
  border-color: rgba(255, 255, 255, 0.16);
  transform: translateY(-2px);
}
.stat > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}
.stat strong {
  display: block;
  font-size: 27px;
  line-height: 1.3;
  font-weight: 700;
  margin: 4px 0 2px;
  color: var(--text-title);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat strong small {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}
.stat p {
  font-size: 10px;
  color: var(--muted);
  margin: 0;
}

.card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-card);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  padding: 22px;
  margin-bottom: 16px;
  transition: border-color 0.2s;
}
.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.section-kicker {
  display: block;
  margin-bottom: 3px;
  font-size: 9px;
}
h2 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  margin: 0;
  color: var(--text-title);
  letter-spacing: -0.015em;
}
h3 {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--text-title);
}
.muted {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
  margin: 6px 0;
}
.subtle, .save-state {
  font-size: 11px;
  color: var(--muted);
}
.save-state {
  white-space: nowrap;
  background: rgba(52, 199, 89, 0.1);
  color: #34c759;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 600;
}

/* Provider card */
.provider {
  display: flex;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.02);
}
.provider-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--accent-light);
  font-size: 20px;
  background: rgba(255, 255, 255, 0.05);
}
.provider strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-title);
}
.provider p {
  font-size: 11px;
  color: var(--muted);
  margin: 2px 0 0;
}
.provider-tag {
  margin-left: auto;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--cyan);
  background: rgba(50, 173, 230, 0.1);
  border: 1px solid rgba(50, 173, 230, 0.25);
  border-radius: 6px;
  padding: 3px 7px;
}

.connection-actions {
  display: flex;
  gap: 8px;
  margin: 16px 0;
}
.connection-actions .gold { min-width: 170px; }

.connection-notice {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 10px 0;
}
.notice-dot {
  width: 6px;
  height: 6px;
  background: var(--cyan);
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 7px;
}
.connection-notice p {
  margin: 0;
  font-size: 11px;
  color: var(--text);
  line-height: 1.6;
}

.inline-link {
  display: inline-block;
  color: var(--accent-light);
  font-size: 11px;
  font-weight: 500;
  margin-top: 6px;
}
.inline-link:hover { text-decoration: underline; }

.quiet-badge {
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  padding: 3px 8px;
}

.feature-list { display: grid; gap: 14px; }
.feature-list > div { display: flex; gap: 12px; }
.feature-list > div > span {
  font-size: 20px;
  width: 28px;
  flex-shrink: 0;
}
.feature-list strong {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-title);
}
.feature-list p {
  font-size: 11px;
  line-height: 1.6;
  color: var(--muted);
  margin: 2px 0 0;
}

/* Quick Action Box */
.action-box {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin: 12px 0;
}
.action-box-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent-light);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.quick-prayers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 7px;
}
.quick-prayer-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 500;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: all 0.15s;
}
.quick-prayer-btn:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.18);
}

.custom-sim-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr auto;
  gap: 8px;
  align-items: center;
}
@media (max-width: 900px) {
  .custom-sim-grid { grid-template-columns: 1fr 1fr; }
}

/* Demo Grid */
.demo-section > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-title);
}
.demo-section > summary::-webkit-details-marker { display: none; }
.summary-plus {
  color: var(--accent);
  font-size: 16px;
  transition: transform 0.2s ease;
}
.demo-section[open] .summary-plus { transform: rotate(45deg); }
.demo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}
.demo-grid button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 8px;
  transition: all 0.15s;
}
.demo-grid button:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
}
.demo-grid strong { font-size: 11px; font-weight: 500; }
.demo-grid span { font-size: 15px; }

/* Log */
#log {
  max-height: 220px;
  overflow: auto;
}
#log .log-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}
#log .log-row:last-child { border: 0; }
#log time {
  font-size: 10px;
  color: var(--muted);
  flex-shrink: 0;
}
#log .event-tag {
  font-size: 9px;
  font-weight: 600;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
}
#log .gift {
  border-color: var(--accent-border);
  color: var(--accent-light);
  background: var(--accent-bg);
}
.empty-log {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
  padding: 6px 0;
}

/* Session Bar */
.session-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 2px;
}
.session-bar strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-title);
}
.session-bar p {
  font-size: 11px;
  color: var(--muted);
  max-width: 400px;
  margin: 2px 0 0;
}

/* ========================================================
   APPLE FORM CONTROLS & INPUTS
   ======================================================== */
label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-title);
  margin: 16px 0 6px;
}
input:not([type=checkbox]), textarea, select {
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  color: var(--text-title);
  border-radius: 8px;
  padding: 9px 12px;
  outline: none;
  font-size: 13px;
  line-height: 1.5;
  transition: all 0.15s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-bg);
}
textarea { resize: vertical; min-height: 75px; }
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.field-hint {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
  margin: 6px 0;
}
.field-hint code {
  color: var(--accent-light);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 5px;
  border-radius: 4px;
}
.number-input { position: relative; }
.number-input input { padding-right: 60px; }
.number-input > span {
  position: absolute;
  right: 12px;
  top: 10px;
  font-size: 11px;
  color: var(--muted);
}

/* Apple iOS Toggle Switch */
.toggle-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  margin: 2px 0 6px;
  cursor: pointer;
}
.toggle-row strong {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-title);
}
.toggle-row small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.toggle-row input {
  appearance: none;
  width: 44px;
  height: 26px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.12);
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.25, 1, 0.5, 1);
}
.toggle-row input:before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
  transition: transform 0.25s cubic-bezier(0.25, 1, 0.5, 1);
}
.toggle-row input:checked {
  background: #34c759;
  border-color: #34c759;
}
.toggle-row input:checked:before {
  transform: translateX(18px);
}

.soft-note {
  border-left: 2px solid var(--accent);
  padding: 10px 14px;
  background: var(--accent-bg);
  color: var(--text);
  font-size: 11px;
  line-height: 1.7;
  margin-top: 20px;
  border-radius: 0 8px 8px 0;
}

/* Track Card */
.track-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}
.track-icon {
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.06);
  color: var(--accent-light);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  font-size: 20px;
}
.track-card strong {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-title);
}
.track-card p {
  font-size: 11px;
  color: var(--muted);
  margin: 2px 0 0;
}

.range-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
}
.range-label label { margin: 0 0 4px; }
.range-label output {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-title);
  font-variant-numeric: tabular-nums;
}
input[type=range] {
  accent-color: var(--accent);
  height: 18px;
  padding: 0;
  margin: 4px 0 8px;
  cursor: pointer;
  box-shadow: none;
}
.voice-row { display: flex; gap: 8px; }
.voice-row select { flex: 1; min-width: 0; }
.voice-row button { flex-shrink: 0; }

.preset-wishes-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.preset-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  transition: all 0.15s;
}
.preset-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* Rules */
.rule-head, .rule {
  display: grid;
  grid-template-columns: 1fr 1.5fr 32px;
  gap: 8px;
}
.rule-head {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 20px 0 8px;
}
.rule { margin: 8px 0; }
.rule input { font-size: 12px; }
.rule button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border-radius: 6px;
  font-size: 16px;
  transition: all 0.15s;
}
.rule button:hover {
  background: #ff453a;
  color: #fff;
}
.received-gifts {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.received-gifts > strong {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-title);
}
.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.chips button {
  font-size: 11px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--accent-light);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 4px 10px;
  transition: all 0.15s;
}
.chips button:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* ========================================================
   APPLE iPHONE PREVIEW BEZEL (9:16 LIVE Frame)
   ======================================================== */
.preview-column {
  position: sticky;
  top: 20px;
  min-width: 0;
}
.preview-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 10px;
}
.preview-label i {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
  margin-right: 6px;
}
.preview-label b { font-weight: 600; }

/* iPhone 16 Pro Bezel styling */
.preview {
  aspect-ratio: 9/16;
  border: 3px solid #2c2c2e;
  border-radius: 28px;
  overflow: hidden;
  background: #000000;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1);
  position: relative;
}
.preview:before {
  /* Dynamic Island */
  content: '';
  position: absolute;
  top: 7px;
  left: 50%;
  transform: translateX(-50%);
  width: 54px;
  height: 10px;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  z-index: 10;
  pointer-events: none;
}
.preview iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
.preview-caption {
  display: flex;
  justify-content: space-between;
  padding: 10px 2px;
  color: var(--muted);
  font-size: 11px;
  border-bottom: 1px solid var(--line);
}
.preview-note { padding: 14px 2px; }
.preview-note strong {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-title);
}
.preview-note p {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
  margin: 4px 0 10px;
}
.copy-url {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--accent-light);
  font: 11px var(--apple-font);
  cursor: pointer;
  transition: all 0.15s;
}
.copy-url:hover {
  background: rgba(255, 255, 255, 0.08);
}
.copy-url span { font-size: 14px; }

/* Guide & Steps */
.guide-intro h2 {
  font-size: 22px;
  line-height: 1.35;
  margin: 6px 0;
}
.guide-steps ol {
  padding-left: 18px;
  margin: 12px 0;
}
.guide-steps li {
  margin: 8px 0;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
}
.source-size {
  display: flex;
  gap: 12px;
  margin: 14px 0;
}
.source-size span {
  flex: 1;
  font-size: 9px;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
}
.source-size strong {
  display: block;
  font-size: 24px;
  letter-spacing: -0.02em;
  font-weight: 700;
  color: var(--text-title);
  margin-top: 3px;
}
.copy-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
}
.copy-line code {
  flex: 1;
  overflow-wrap: anywhere;
  font-size: 11px;
}
.copy-line .button {
  font-size: 11px;
  padding: 6px 12px;
}

.faq {
  border-top: 1px solid var(--line);
  padding: 14px 0;
}
.faq summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-title);
}
.faq summary:hover { color: var(--accent-light); }
.faq p {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
  margin: 8px 0 0;
}

/* ========================================================
   RANKING & DEVOTEES VIEW
   ======================================================== */
.ranking-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 12px;
}
.ranking-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.ranking-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}
.ranking-table tr:hover td {
  background: rgba(255, 255, 255, 0.04);
}
.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
}
.rank-badge.rank-1 { background: #f5a623; color: #000; }
.rank-badge.rank-2 { background: #8e8e93; color: #000; }
.rank-badge.rank-3 { background: #a25f19; color: #fff; }
.rank-badge.rank-other { background: rgba(255, 255, 255, 0.06); color: var(--muted); }

.search-devotees-box {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

/* ========================================================
   SUPPORT SECTION (TẤN CÔNG AI)
   ======================================================== */
.support-card {
  text-align: center;
  padding: 36px 20px;
}
.support-seal {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--accent-gradient);
  color: #000000;
  font-size: 26px;
  font-weight: 700;
  margin: 0 auto 16px;
  box-shadow: 0 4px 20px var(--accent-glow);
}
.support-card h2 {
  font-size: 26px;
  font-weight: 700;
  margin: 4px 0 2px;
  color: var(--text-title);
}
.service-callout {
  display: flex;
  gap: 12px;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  text-align: left;
  margin: 18px 0;
}
.service-callout .service-icon {
  font-size: 24px;
  color: var(--accent);
  flex-shrink: 0;
}
.service-callout strong {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-title);
  letter-spacing: 0.03em;
  margin-bottom: 3px;
}
.service-callout p {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
}

.support-phone {
  display: block;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--accent-light);
  margin: 14px 0 20px;
}
.support-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.support-services-grid {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}
.service-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
}
.service-bullet {
  font-size: 13px;
  color: var(--accent);
  margin-top: 1px;
}
.service-item strong {
  color: var(--text-title);
  font-size: 12px;
}
.service-item div {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
}

/* Footer */
footer {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding-top: 20px;
  margin-top: 28px;
  font-size: 11px;
  color: var(--muted);
}
footer a {
  text-decoration: none;
  color: var(--accent-light);
  font-weight: 500;
}

/* Apple Floating Toast */
#toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 980px;
  background: rgba(28, 28, 30, 0.9);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  color: #f5f5f7;
  font-size: 12px;
  font-weight: 500;
  max-width: min(90vw, 500px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s cubic-bezier(0.25, 1, 0.5, 1);
}
#toast.visible { opacity: 1; }

/* Layout Controls */
.layout-controls {
  padding: 12px 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.layout-controls .button {
  padding: 8px 12px;
  font-size: 11px;
}
.layout-controls p {
  width: 100%;
  font-size: 11px;
  line-height: 1.6;
  color: var(--muted);
  margin: 4px 0 0;
}
.layout-controls [aria-pressed="true"] { outline: 2px solid var(--cyan); }

/* Gift Icons & Slots */
.tiktok-gift-icon {
  display: inline-block;
  width: 54px;
  height: 54px;
  flex-shrink: 0;
  background-image: url('/assets/tiktok-gifts-atlas.png');
  background-size: 700% 201.111111%;
  background-position: calc(var(--gift-column) * 100% / 6) center;
  background-repeat: no-repeat;
}

.gift-slot-row {
  display: grid;
  grid-template-columns: 20px 54px minmax(90px, 1fr) minmax(110px, 1.4fr);
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.gift-slot-row > b {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-light);
}
.gift-slot-row select, .gift-slot-row input {
  width: 100%;
  min-width: 0;
  margin: 0;
}

/* Audio Custom */
.audio-custom input[type=file] {
  font-size: 0;
  color: transparent;
  min-height: 38px;
  padding: 4px;
}
.audio-custom input[type=file]::file-selector-button {
  font: 11px var(--apple-font);
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.audio-custom input[type=file]::file-selector-button:hover {
  background: rgba(255, 255, 255, 0.14);
}
.audio-custom [id$="-name"] {
  font-size: 11px;
  color: var(--accent-light);
  overflow-wrap: anywhere;
}
.audio-custom [id$="-status"] {
  font-size: 11px;
  overflow-wrap: anywhere;
}
.audio-save-button {
  margin-top: 8px;
  min-width: 140px;
}

/* Responsive Media Queries */
@media(min-width: 1700px) {
  main { padding: 28px 48px; }
  .workspace { grid-template-columns: minmax(450px, 1fr) 360px; gap: 32px; }
  h1 { font-size: 30px; }
}

@media(max-width: 1200px) {
  .sidebar { width: 220px; padding: 20px 12px; }
  main { margin-left: 220px; padding: 20px; }
  .brand { font-size: 17px; }
  .nav { font-size: 12px; padding: 8px 10px; }
  .workspace { grid-template-columns: minmax(320px, 1fr) 260px; gap: 18px; }
  .header-actions { flex-wrap: wrap; justify-content: flex-end; }
  .page-header h1 { font-size: 23px; }
  .card { padding: 18px; }
  .stat { padding: 14px; }
  .provider-tag { display: none; }
}

@media(max-width: 1000px) {
  .sidebar { width: 195px; }
  main { margin-left: 195px; padding: 16px; }
  .workspace { grid-template-columns: minmax(280px, 1fr) 230px; gap: 14px; }
  .page-header { align-items: flex-start; }
  .header-actions .secondary { display: none; }
  .button { font-size: 11px; padding: 8px 12px; }
  .stats { gap: 8px; }
  .stat strong { font-size: 22px; }
  .card { padding: 16px; }
  .demo-grid { grid-template-columns: 1fr 1fr; }
  .two-col { gap: 12px; }
}

@media(max-width: 820px) {
  .sidebar {
    position: static;
    width: auto;
    inset: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 14px 18px;
    display: block;
  }
  .brand { font-size: 18px; }
  .sidebar nav {
    display: flex;
    flex-direction: row;
    gap: 4px;
    overflow: auto;
    margin-top: 10px;
    padding-bottom: 2px;
  }
  .nav {
    flex-shrink: 0;
    font-size: 11px;
    padding: 7px 10px;
    gap: 6px;
  }
  .nav > span { font-size: 14px; width: auto; }
  .nav-divider, .nav-caption, .owner-mini, .sidebar-foot { display: none; }
  main { margin: 0; padding: 18px; }
  .workspace { grid-template-columns: minmax(0, 1fr) 240px; gap: 16px; }
  .page-header { padding: 18px 0; }
  .page-header h1 { font-size: 22px; }
  .topbar { font-size: 9px; flex-wrap: wrap; gap: 8px; }
  .service-badge { display: none; }
  .page-header .header-actions { padding-top: 14px; }
  .session-bar { flex-wrap: wrap; }
}

@media(max-width: 640px) {
  main { padding: 14px 12px; }
  .workspace { grid-template-columns: 1fr; }
  .preview-column { position: static; width: 100%; max-width: 320px; margin: 10px auto 0; }
  .page-header { display: block; }
  .header-actions { justify-content: flex-start; padding-top: 12px !important; }
  .header-actions .secondary { display: inline-flex; }
  .page-header h1 { font-size: 20px; }
  .stats { gap: 6px; }
  .stat > span { font-size: 10px; }
  .stat p { display: none; }
  .stat strong { font-size: 20px; margin-bottom: 0; }
  .card { padding: 16px; }
  .two-col { grid-template-columns: 1fr; gap: 0; }
  .provider-tag { display: block; font-size: 7px; }
  .voice-row { flex-wrap: wrap; }
  .voice-row select { flex-basis: 100%; }
  .rule-head, .rule { grid-template-columns: .85fr 1.2fr 28px; gap: 6px; }
  .rule input { padding: 8px 6px; font-size: 11px; }
  .card-heading { gap: 8px; }
  .card-heading h2 { font-size: 15px; }
  .support-phone { font-size: 24px; }
  .support-actions { flex-wrap: wrap; }
  .copy-line { align-items: flex-start; flex-wrap: wrap; }
  .copy-line code { flex-basis: 100%; }
  footer { font-size: 9px; }
}

@media(max-width: 700px) {
  .gift-slot-row { grid-template-columns: 20px 48px 1fr; }
  .gift-slot-row input { grid-column: 2/4; }
  .gift-slot-row .tiktok-gift-icon { width: 48px; height: 48px; }
}
