/* ============================================================
   FreshEye AI — design tokens (from fresheye_ai/DESIGN.md)
   ============================================================ */

:root {
  /* Surfaces */
  --surface: #f8f9ff;
  --surface-dim: #cbdbf5;
  --surface-bright: #f8f9ff;
  --surface-container-lowest: #ffffff;
  --surface-container-low: #eff4ff;
  --surface-container: #e5eeff;
  --surface-container-high: #dce9ff;
  --surface-container-highest: #d3e4fe;

  /* Content */
  --on-surface: #0b1c30;
  --on-surface-variant: #3c4a42;
  --outline: #6c7a71;
  --outline-variant: #bbcabf;
  --inverse-surface: #213145;
  --inverse-on-surface: #eaf1ff;

  /* Primary — emerald mint */
  --primary: #006c49;
  --on-primary: #ffffff;
  --primary-container: #10b981;
  --on-primary-container: #00422b;
  --primary-fixed: #6ffbbe;
  --primary-fixed-dim: #4edea3;

  /* Secondary — slate */
  --secondary: #565e74;
  --on-secondary: #ffffff;
  --secondary-container: #dae2fd;
  --on-secondary-container: #5c647a;
  --secondary-fixed: #dae2fd;
  --on-secondary-fixed: #131b2e;

  /* Tertiary — amber */
  --tertiary: #855300;
  --tertiary-container: #e29100;
  --tertiary-fixed: #ffddb8;
  --tertiary-fixed-dim: #ffb95f;
  --on-tertiary: #ffffff;
  --on-tertiary-fixed: #2a1700;
  --on-tertiary-fixed-variant: #653e00;

  /* Error — chilled coral */
  --error: #ba1a1a;
  --on-error: #ffffff;
  --error-container: #ffdad6;
  --on-error-container: #93000a;

  /* Type */
  --font-display: "Plus Jakarta Sans", "Segoe UI Variable Display", "Segoe UI", system-ui,
    -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-body: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system,
    "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Mono", "SFMono-Regular", Consolas, monospace;

  /* Shape */
  --radius-sm: 4px;
  --radius: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(11, 28, 48, 0.05);
  --shadow-card: 0 2px 12px rgba(11, 28, 48, 0.045);
  --shadow-panel: 0 4px 20px -2px rgba(15, 23, 42, 0.05);
  --shadow-lift: 0 10px 25px -4px rgba(15, 23, 42, 0.08), 0 2px 6px -1px rgba(15, 23, 42, 0.03);
  --shadow-overlay: 0 20px 40px -8px rgba(15, 23, 42, 0.14);
  --shadow-dock: 0 12px 32px rgba(11, 28, 48, 0.12);

  /* Layout */
  --shell: 480px;
  --gutter: 16px;
  --header-h: 64px;
  --nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);

  --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

html {
  background: #e9eff9;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 20px;
  color: var(--on-surface);
  background:
    radial-gradient(900px 480px at 50% -8%, #edf6ff 0%, rgba(248, 249, 255, 0) 62%),
    linear-gradient(180deg, #eef4fb 0%, #e6edf7 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg {
  display: block;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

::selection {
  background: rgba(16, 185, 129, 0.22);
}

:focus-visible {
  outline: 2px solid var(--primary-container);
  outline-offset: 2px;
}

/* ---------------------------------------------------------- */
/* Type utilities                                              */
/* ---------------------------------------------------------- */

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

.t-display {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  line-height: 40px;
  letter-spacing: -0.02em;
}
.t-headline-lg {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  line-height: 32px;
  letter-spacing: -0.01em;
}
.t-headline-md {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  line-height: 28px;
  letter-spacing: -0.01em;
}
.t-headline-sm {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  line-height: 24px;
}
.t-body-lg {
  font-size: 16px;
  line-height: 24px;
}
.t-body-md {
  font-size: 14px;
  line-height: 20px;
}
.t-body-sm {
  font-size: 12px;
  line-height: 16px;
}
.t-label-lg {
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.t-label-md {
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.t-label-sm {
  font-size: 10px;
  line-height: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.t-num {
  font-family: var(--font-body);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.muted {
  color: var(--secondary);
}
.text-primary {
  color: var(--primary);
}
.text-tertiary {
  color: var(--tertiary);
}
.text-error {
  color: var(--error);
}

/* ---------------------------------------------------------- */
/* Icon system                                                 */
/* ---------------------------------------------------------- */

.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}
.icon--sm {
  width: 16px;
  height: 16px;
}
.icon--xs {
  width: 13px;
  height: 13px;
}
.icon--lg {
  width: 24px;
  height: 24px;
}
.icon--fill {
  fill: currentColor;
  stroke: none;
}

/* ---------------------------------------------------------- */
/* Shared primitives                                           */
/* ---------------------------------------------------------- */

.stack {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stack-md {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.grow {
  flex: 1;
  min-width: 0;
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.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;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--primary-container);
}
.dot--lg {
  width: 8px;
  height: 8px;
}
.dot--tertiary {
  background: var(--tertiary-container);
}
.dot--error {
  background: var(--error);
}
.dot--muted {
  background: var(--outline-variant);
}
.dot--pulse {
  animation: dot-pulse 2.4s ease-in-out infinite;
}

@keyframes dot-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.35);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(16, 185, 129, 0);
  }
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: var(--radius-full);
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 16px;
  white-space: nowrap;
}
.pill--primary {
  background: rgba(16, 185, 129, 0.12);
  color: var(--primary);
}
.pill--tertiary {
  background: var(--tertiary-fixed);
  color: var(--on-tertiary-fixed);
}
.pill--error {
  background: var(--error-container);
  color: var(--on-error-container);
}
.pill--slate {
  background: var(--secondary-container);
  color: var(--on-secondary-container);
}
.pill--ink {
  background: rgba(33, 49, 69, 0.85);
  color: var(--inverse-on-surface);
  backdrop-filter: blur(6px);
}

.bar {
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--surface-container);
  overflow: hidden;
}
.bar__fill {
  height: 100%;
  border-radius: inherit;
  background: var(--primary-container);
  transition: width 0.5s var(--ease-spring);
}
.bar__fill--tertiary {
  background: var(--tertiary-container);
}
.bar__fill--error {
  background: var(--error);
}
.bar__fill--muted {
  background: var(--outline);
}
.bar--thin {
  height: 4px;
}

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface-container);
  border-radius: var(--radius-md);
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.spin {
  animation: spin 0.9s linear infinite;
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
