/* =========================================================
   TangzhenBB — central brand file (v1.0)
   Every page, tool, app and game links to this ONE file:
     <link rel="stylesheet" href="/brand/brand.css">
   Change a value here once → it changes everywhere.
   ========================================================= */

/* ---------- 1. Font: Inter, self-hosted (no Google servers) ---------- */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/brand/fonts/Inter-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/brand/fonts/Inter-Medium.woff2") format("woff2");
}

/* ---------- 2. Brand tokens — edit THESE to change the CI ---------- */
:root {
  /* Colours */
  --tg-base:        #1B2430;  /* page background: deep blue */
  --tg-surface:     #243041;  /* cards, panels */
  --tg-surface-2:   #2C3A4E;  /* raised elements, hover */
  --tg-line:        #34435A;  /* hairlines, card borders */
  --tg-text:        #ECE5D8;  /* main text: warm beige */
  --tg-text-muted:  #A8A193;  /* secondary text: greige */
  --tg-accent:      #C9B49A;  /* highlighter: champagne */
  --tg-on-accent:   #1B2430;  /* text on champagne */
  --tg-danger:      #D98C7A;  /* errors (soft terracotta) */
  --tg-success:     #8FB89A;  /* confirmations (soft sage) */
  --tg-base-deep:   #121821;  /* side menu and phone tab bar: a shade darker than the page */
  --tg-main-top:    #26324A;  /* signed-in main area: a little brighter than the base, top … */
  --tg-main-bottom: #1F2836;  /* … fading back towards the base at the bottom */

  /* App colours (admin usage bars, charts). One per app, set in src/lib/apps.js. */
  --tg-app-0: #A8A193;  /* site and profiles: greige */
  --tg-app-1: #7FB5A6;  /* teal sage */
  --tg-app-2: #8FA8D6;  /* periwinkle */
  --tg-app-3: #C79AB4;  /* mauve */
  --tg-app-4: #D6C27A;  /* mustard */
  --tg-app-5: #9FB873;  /* olive */
  --tg-app-6: #D9A07E;  /* apricot */
  --tg-app-7: #6FA9C4;  /* steel blue */

  /* LED colours: strong, flat colours for progress rings and charts (Habits & goals, owner's choice 8 Nov 2026).
     No glow or gradient; use on dark surfaces (--tg-base-deep / --tg-base). */
  --tg-led-blue:   #6AAEF2;
  --tg-led-amber:  #EFC453;
  --tg-led-cyan:   #55D3E8;
  --tg-led-pink:   #EC74B9;
  --tg-led-lime:   #A6DB62;
  --tg-led-orange: #F09A55;
  --tg-led-violet: #A88DEB;
  --tg-led-gold:   #EDCB98;
  --tg-led-green:  #5AD68E;
  --tg-led-red:    #E8706B;
  --tg-led-off:    #2A3647;

  /* Glass (Apple-style bubbles) */
  --tg-glass:        rgba(236, 229, 216, 0.08);
  --tg-glass-hover:  rgba(236, 229, 216, 0.14);
  --tg-glass-edge:   rgba(236, 229, 216, 0.18);
  --tg-glass-accent: rgba(201, 180, 154, 0.88);
  --tg-glass-tint:   rgba(201, 180, 154, 0.16);
  /* Soft tints and edges for status and highlights (cards, bars, badges). */
  --tg-accent-edge:  rgba(201, 180, 154, 0.5);    /* champagne hairline: featured panels, hover */
  --tg-success-soft: rgba(143, 184, 154, 0.18);   /* sage wash: positive numbers, bars */
  --tg-success-edge: rgba(143, 184, 154, 0.5);
  --tg-danger-soft:  rgba(217, 140, 122, 0.18);   /* terracotta wash: negative numbers, bars */
  --tg-danger-edge:  rgba(217, 140, 122, 0.5);
  --tg-shadow-float: 0 10px 30px rgba(0, 0, 0, 0.35);   /* only for things floating over content (phone bars) */
  --tg-blur:         16px;

  /* Typography */
  --tg-font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --tg-size-xs: 0.75rem;   /* 12px labels */
  --tg-size-sm: 0.875rem;  /* 14px secondary */
  --tg-size-md: 1rem;      /* 16px body */
  --tg-size-lg: 1.375rem;  /* 22px section titles */
  --tg-size-xl: 2rem;      /* 32px page titles */
  --tg-weight-regular: 400;
  --tg-weight-medium:  500;

  /* Shape and spacing */
  --tg-radius-sm:   8px;
  --tg-radius:      14px;   /* cards */
  --tg-radius-pill: 999px;  /* buttons, chips */
  --tg-space-1: 4px;
  --tg-space-2: 8px;
  --tg-space-3: 12px;
  --tg-space-4: 16px;
  --tg-space-5: 24px;
  --tg-space-6: 40px;
  --tg-max-width: 1080px;

  /* Motion */
  --tg-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --tg-fast: 150ms;
}

/* ---------- 3. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--tg-base);
  color: var(--tg-text);
  font-family: var(--tg-font);
  font-size: var(--tg-size-md);
  font-weight: var(--tg-weight-regular);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-weight: var(--tg-weight-medium); line-height: 1.25; margin: 0 0 var(--tg-space-3); letter-spacing: -0.01em; }
h1 { font-size: var(--tg-size-xl); }
h2 { font-size: var(--tg-size-lg); }
h3 { font-size: var(--tg-size-md); }
p  { margin: 0 0 var(--tg-space-4); }

a { color: var(--tg-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.tg-muted  { color: var(--tg-text-muted); }
.tg-accent { color: var(--tg-accent); }
.tg-label  { font-size: var(--tg-size-xs); color: var(--tg-accent); letter-spacing: 0.04em; }

.tg-container { max-width: var(--tg-max-width); margin: 0 auto; padding: 0 var(--tg-space-4); }

:focus-visible { outline: 2px solid var(--tg-accent); outline-offset: 2px; }

/* ---------- 4. Buttons (glass bubbles) ---------- */
.tg-btn {
  display: inline-flex; align-items: center; gap: var(--tg-space-2);
  font: inherit; font-size: var(--tg-size-sm); font-weight: var(--tg-weight-medium);
  color: var(--tg-text);
  background: var(--tg-glass);
  border: 1px solid var(--tg-glass-edge);
  border-radius: var(--tg-radius-pill);
  padding: 9px 18px;
  cursor: pointer;
  backdrop-filter: blur(var(--tg-blur));
  -webkit-backdrop-filter: blur(var(--tg-blur));
  transition: background var(--tg-fast) var(--tg-ease), transform var(--tg-fast) var(--tg-ease);
  text-decoration: none;
}
.tg-btn:hover  { background: var(--tg-glass-hover); text-decoration: none; }
.tg-btn:active { transform: scale(0.97); }

/* Main action: near-solid champagne, one per screen */
.tg-btn--primary {
  background: var(--tg-glass-accent);
  color: var(--tg-on-accent);
  border-color: rgba(236, 229, 216, 0.35);
}
.tg-btn--primary:hover { background: var(--tg-accent); }

/* ---------- 5. Chips (categories, filters) ---------- */
.tg-chip {
  display: inline-flex; align-items: center;
  font: inherit; font-size: var(--tg-size-xs);
  color: var(--tg-text-muted);
  background: var(--tg-glass);
  border: 1px solid var(--tg-glass-edge);
  border-radius: var(--tg-radius-pill);
  padding: 5px 12px;
  cursor: pointer;
}
.tg-chip.is-active {
  color: var(--tg-text);
  background: var(--tg-glass-tint);
  border-color: rgba(201, 180, 154, 0.55);
}

/* ---------- 6. Cards ---------- */
.tg-card {
  background: var(--tg-surface);
  border: 1px solid var(--tg-line);
  border-radius: var(--tg-radius);
  padding: var(--tg-space-4);
}
.tg-card--featured { border-color: rgba(201, 180, 154, 0.55); }

.tg-icon-tile {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: var(--tg-glass-tint);
  color: var(--tg-accent);
}

/* ---------- 7. Form fields ---------- */
.tg-input {
  width: 100%;
  font: inherit; color: var(--tg-text);
  background: var(--tg-glass);
  border: 1px solid var(--tg-glass-edge);
  border-radius: var(--tg-radius-sm);
  padding: 10px 12px;
}
.tg-input::placeholder { color: var(--tg-text-muted); }
.tg-input:focus { outline: none; border-color: var(--tg-accent); }
.tg-error { color: var(--tg-danger); font-size: var(--tg-size-xs); }

/* ---------- 8. Header + logo ---------- */
.tg-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--tg-space-4) 0;
}
.tg-logo { display: inline-flex; align-items: center; gap: var(--tg-space-3); color: var(--tg-text); text-decoration: none; }
.tg-logo:hover { text-decoration: none; }
.tg-logo__word { font-size: 1.25rem; font-weight: var(--tg-weight-medium); letter-spacing: -0.02em; }
.tg-logo__word span { color: var(--tg-accent); }

/* Language switch (EN / DE) */
.tg-lang { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--tg-radius-pill); background: var(--tg-glass); border: 1px solid var(--tg-glass-edge); }
.tg-lang button { font: inherit; font-size: var(--tg-size-xs); color: var(--tg-text-muted); background: none; border: 0; padding: 4px 10px; border-radius: var(--tg-radius-pill); cursor: pointer; }
.tg-lang button[aria-pressed="true"] { background: var(--tg-glass-accent); color: var(--tg-on-accent); }

/* ---------- 9. Grid for tool cards ---------- */
.tg-grid { display: grid; gap: var(--tg-space-3); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- 10. Danger buttons (destructive actions) ---------- */
.tg-btn--danger { color: var(--tg-danger); border-color: rgba(217, 140, 122, 0.45); }
.tg-btn--danger:hover { background: rgba(217, 140, 122, 0.12); }
.tg-btn--danger-solid { background: var(--tg-danger); color: var(--tg-on-accent); border-color: transparent; }
.tg-btn--danger-solid:hover { background: #E39C8B; }
.tg-btn:disabled { opacity: .6; cursor: wait; }

/* ---------- 11. Dialog (confirmations) ---------- */
.tg-dialog {
  width: min(460px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--tg-glass-edge);
  border-radius: 22px; background: var(--tg-surface); color: var(--tg-text);
}
.tg-dialog::backdrop { background: rgba(10, 14, 20, 0.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.tg-dialog__inner { padding: var(--tg-space-5); }
.tg-dialog__icon { display: inline-flex; width: 44px; height: 44px; align-items: center; justify-content: center; border-radius: 14px; background: rgba(217, 140, 122, 0.14); color: var(--tg-danger); margin-bottom: var(--tg-space-3); }
.tg-dialog__icon svg { width: 22px; height: 22px; }
.tg-dialog__buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--tg-space-2); margin-top: var(--tg-space-4); }

/* ---------- 12. Checkbox ---------- */
.tg-check { display: flex; align-items: flex-start; gap: 10px; font-size: var(--tg-size-sm); cursor: pointer; margin-top: var(--tg-space-3); }
.tg-check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--tg-accent); flex: none; }
