/* ============================================================
   Avvmo Design System — CSS Custom Properties & Global Styles
   Brand: Learning OS — "Become More."
   Theme: 安静书房 (Quiet Study) — warm, dark, minimal
   ============================================================ */

:root {
  /* === Color System === */
  /* Background layers — layered darkness like a study at night */
  --color-bg-deep:     #0D0D0F;   /* Deepest: page background */
  --color-bg-surface:  #141417;   /* Surface: cards, input backgrounds */
  --color-bg-elevated: #1A1A1E;   /* Elevated: hover states, panels */
  --color-bg-overlay:  #1F1F24;   /* Overlay: dialogs, modals */

  /* Text hierarchy */
  --color-text-primary:    #E8E6E1;   /* Primary text: warm off-white */
  --color-text-secondary:  #9B9994;   /* Secondary text: muted warm grey */
  --color-text-tertiary:   #6B6965;   /* Tertiary: hint text, placeholders */
  --color-text-disabled:   #4A4845;   /* Disabled text */

  /* Accent — subtle gold/amber, not flashy */
  --color-accent:          #C4A265;   /* Primary accent: warm gold */
  --color-accent-soft:     #A68A4E;   /* Soft accent: hover states */
  --color-accent-subtle:   rgba(196, 162, 101, 0.12); /* Very subtle accent bg */
  --color-accent-glow:     rgba(196, 162, 101, 0.24); /* Glow for focus states */

  /* Semantic colors — muted, not harsh */
  --color-success:  #6B9070;   /* Muted sage green */
  --color-warning:  #B8935C;   /* Muted amber */
  --color-error:    #9B5C5C;   /* Muted rose */

  /* === Typography === */
  --font-sans:     'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:     'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;

  --text-xs:   0.75rem;    /* 12px */
  --text-sm:   0.8125rem;  /* 13px */
  --text-base: 0.9375rem;  /* 15px */
  --text-md:   1.0625rem;  /* 17px */
  --text-lg:   1.25rem;    /* 20px */
  --text-xl:   1.5rem;     /* 24px */
  --text-2xl:  2rem;       /* 32px */
  --text-3xl:  2.5rem;     /* 40px */

  --leading-tight:   1.25;
  --leading-normal:  1.6;
  --leading-relaxed: 1.75;

  --weight-light:  300;
  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;

  /* === Spacing === */
  --space-1:  0.25rem;   /* 4px  */
  --space-2:  0.5rem;    /* 8px  */
  --space-3:  0.75rem;   /* 12px */
  --space-4:  1rem;      /* 16px */
  --space-5:  1.25rem;   /* 20px */
  --space-6:  1.5rem;    /* 24px */
  --space-8:  2rem;      /* 32px */
  --space-10: 2.5rem;    /* 40px */
  --space-12: 3rem;      /* 48px */
  --space-16: 4rem;      /* 64px */

  /* === Animation === */
  --ease-out:   cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --duration-fast:    150ms;
  --duration-normal:  300ms;
  --duration-slow:    600ms;
  --duration-glacial: 2000ms;   /* For ambient floating phrases */

  /* === Borders & Radius === */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --border-subtle: 1px solid rgba(255, 255, 255, 0.06);
  --border-normal: 1px solid rgba(255, 255, 255, 0.10);

  /* === Shadows === */
  --shadow-sm:   0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md:   0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg:   0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 24px var(--color-accent-subtle);

  /* === Layout === */
  --chat-panel-width:    340px;
  --dashboard-width:     300px;
  --header-height:       0px;    /* No header bar — chrome-free */
}

/* ============================================================
   Light Theme — user-selectable via data-theme="light"
   ============================================================ */

[data-theme="light"] {
  --color-bg-deep:     #F6F4EF;
  --color-bg-surface:  #FFFFFF;
  --color-bg-elevated: #EFEDE7;
  --color-bg-overlay:  #E7E4DC;

  --color-text-primary:    #2B2926;
  --color-text-secondary:  #6B6965;
  --color-text-tertiary:   #9B9994;
  --color-text-disabled:   #C6C3BB;

  --color-accent:          #A6843F;
  --color-accent-soft:     #8F7139;
  --color-accent-subtle:   rgba(196, 162, 101, 0.16);
  --color-accent-glow:     rgba(196, 162, 101, 0.35);

  --color-success:  #5E8264;
  --color-warning:  #A97F3D;
  --color-error:    #94594F;

  --border-subtle: 1px solid rgba(20, 20, 24, 0.08);
  --border-normal: 1px solid rgba(20, 20, 24, 0.14);

  --shadow-sm:   0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md:   0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg:   0 8px 32px rgba(0, 0, 0, 0.10);
  --shadow-glow: 0 0 24px rgba(196, 162, 101, 0.18);
}

/* ============================================================
   Reset & Base
   ============================================================ */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-normal);
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg-deep);
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}

/* ============================================================
   App Shell
   ============================================================ */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  position: relative;
  overflow: hidden;
}

/* ============================================================
   Scrollbar — minimal, dark
   ============================================================ */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--color-text-disabled);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-tertiary);
}

/* ============================================================
   Typography utilities
   ============================================================ */

.text-accent { color: var(--color-accent); }
.text-secondary { color: var(--color-text-secondary); }
.text-tertiary { color: var(--color-text-tertiary); }
.text-center { text-align: center; }

.font-mono { font-family: var(--font-mono); }

/* ============================================================
   Selection
   ============================================================ */

::selection {
  background: var(--color-accent-subtle);
  color: var(--color-accent);
}

/* ============================================================
   Focus ring — subtle glow
   ============================================================ */

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--color-bg-deep), 0 0 0 3px var(--color-accent-glow);
  border-radius: var(--radius-sm);
}

/* ============================================================
   Loading states
   ============================================================ */

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInSlow {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes typing-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.animate-fade-in {
  animation: fadeIn var(--duration-normal) var(--ease-out) forwards;
}

.animate-fade-in-slow {
  animation: fadeInSlow var(--duration-slow) var(--ease-out) forwards;
}

/* ============================================================
   Theme Toggle Button
   ============================================================ */

.theme-toggle {
  width: 36px;
  height: 36px;
  background: transparent;
  border: var(--border-normal);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all var(--duration-fast) var(--ease-out);
}

.theme-toggle:hover {
  border-color: var(--color-accent-soft);
  color: var(--color-accent);
}

/* ============================================================
   Quick Reply Chips
   ============================================================ */

.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: center;
}

.quick-reply-chip {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: var(--color-bg-surface);
  border: var(--border-normal);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all var(--duration-fast) var(--ease-out);
}

.quick-reply-chip:hover {
  border-color: var(--color-accent-soft);
  color: var(--color-accent);
  background: var(--color-bg-elevated);
}

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

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  width: min(400px, 92vw);
  background: var(--color-bg-overlay);
  border: var(--border-normal);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  box-shadow: var(--shadow-lg);
  color: var(--color-text-primary);
}

.modal__tabs {
  display: flex;
  gap: var(--space-4);
  border-bottom: var(--border-subtle);
  margin-bottom: var(--space-6);
}

.modal__tab {
  background: none;
  border: none;
  color: var(--color-text-tertiary);
  cursor: pointer;
  font-size: var(--text-base);
  font-family: var(--font-sans);
  padding: var(--space-2) 0;
  transition: color var(--duration-fast) var(--ease-out);
}

.modal__tab--active {
  color: var(--color-accent);
  border-bottom: 2px solid var(--color-accent);
}

.modal__form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.modal__title {
  margin: 0 0 var(--space-4);
  font-size: var(--text-lg);
  color: var(--color-text-primary);
}

.modal__label {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  margin-bottom: -8px;
}

.modal__input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg-surface);
  border: var(--border-normal);
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
}

.modal__input:focus {
  outline: none;
  border-color: var(--color-accent-soft);
}

.modal__submit {
  padding: var(--space-3) var(--space-6);
  background: var(--color-accent);
  color: var(--color-bg-deep);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  margin-top: var(--space-2);
  transition: background var(--duration-fast) var(--ease-out);
}

.modal__submit:hover {
  background: var(--color-accent-soft);
}

.modal__error {
  color: var(--color-error);
  font-size: var(--text-sm);
  display: none;
}

.modal__hint {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  display: none;
}

/* 上云前扩围（2026-09-01，部署方案 §3.2）：登录弹层协议勾选 */
.modal__agree {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  line-height: 1.5;
  cursor: pointer;
  user-select: none;
}

.modal__agree input {
  margin-top: 3px;
  accent-color: var(--color-accent);
  flex-shrink: 0;
}

.modal__agree a {
  color: var(--color-accent);
  text-decoration: none;
}

.modal__agree a:hover {
  text-decoration: underline;
}

/* 节点 14（2026-08-24）：删除路线二次确认弹窗（内嵌，用户拍板 §14.17） */
.modal__text {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: 1.6;
  margin: 0 0 var(--space-6);
}

.modal__list {
  display: block;
  color: var(--color-text-primary);
  margin-top: var(--space-2);
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

.modal__btn {
  padding: var(--space-2) var(--space-5);
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  transition: all var(--duration-fast) var(--ease-out);
}

.modal__btn:hover {
  border-color: var(--color-accent);
  color: var(--color-text-primary);
}

.modal__btn--danger {
  border-color: var(--color-error);
  color: var(--color-error);
}

.modal__btn--danger:hover {
  background: var(--color-error);
  border-color: var(--color-error);
  color: #fff;
}

.modal__btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* 节点 11（2026-08-24）：快捷登录（测试账号）——次级按钮 */
.modal__quick {
  padding: var(--space-2) var(--space-5);
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  margin-top: var(--space-2);
  transition: all var(--duration-fast) var(--ease-out);
}

.modal__quick:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* ============================================================
   Utility: visually hidden (screen reader only)
   ============================================================ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
