:root {
  --white: #f8f8f6;
  --paper: #ecebe8;
  --card: #ffffff;
  --ink: #111111;
  --muted: #5c6066;
  --line: rgba(17, 17, 17, 0.11);
  --dark: #14161a;
  --dark-card: #1c1f26;
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--white); color: var(--ink); font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif; line-height: 1.6; }
a { color: inherit; }

/* Header */
.tl-header { position: sticky; top: 0; z-index: 40; background: rgba(248, 248, 246, 0.94); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.tl-header-inner { max-width: 1160px; margin: 0 auto; padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.tl-brand { text-decoration: none; font-weight: 700; font-size: 1.05rem; letter-spacing: 0.02em; display: inline-flex; align-items: baseline; gap: 8px; }
.tl-brand small { font-size: 0.72rem; letter-spacing: 0.14em; color: var(--muted); font-weight: 500; }
.tl-nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 0.9rem; }
.tl-nav a { text-decoration: none; color: var(--muted); font-weight: 500; }
.tl-nav a:hover, .tl-nav a.is-active { color: var(--ink); font-weight: 600; }

/* Buttons (high contrast guaranteed) */
.tl-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 18px; border-radius: 999px; border: 1px solid var(--ink); background: var(--ink); color: #ffffff !important; font-family: inherit; font-size: 0.88rem; font-weight: 600; text-decoration: none; cursor: pointer; transition: background-color 0.2s ease, opacity 0.2s ease; }
.tl-btn:hover { background: #2a2d34; }
.tl-btn-light { background: #ffffff; color: #111111 !important; border-color: #ffffff; }
.tl-btn-light:hover { background: #ecebe8; border-color: #ecebe8; }
.tl-btn-ghost { background: transparent; color: var(--ink) !important; border-color: rgba(17, 17, 17, 0.28); }
.tl-btn-ghost:hover { background: rgba(17, 17, 17, 0.06); border-color: var(--ink); }
.tl-btn-ghost-dark { background: rgba(255, 255, 255, 0.12); color: #ffffff !important; border-color: rgba(255, 255, 255, 0.45); }
.tl-btn-ghost-dark:hover { background: rgba(255, 255, 255, 0.22); border-color: #ffffff; }
.tl-btn-sm { min-height: 32px; padding: 5px 12px; font-size: 0.8rem; }

/* Container & Hero */
.tl-wrap { max-width: 1160px; margin: 0 auto; padding: 28px 20px 72px; }
.tl-crumbs { font-size: 0.82rem; color: var(--muted); margin-bottom: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.tl-crumbs a { text-decoration: none; }
.tl-crumbs a:hover { color: var(--ink); }
.tl-hero { margin-bottom: 24px; }
.tl-eyebrow { margin: 0 0 8px; font-size: 0.76rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.tl-hero h1 { margin: 0 0 10px; font-size: clamp(1.65rem, 3.4vw, 2.35rem); line-height: 1.22; letter-spacing: -0.01em; }
.tl-hero p.tl-lead { margin: 0; max-width: 780px; color: var(--muted); font-size: 0.98rem; }
.tl-hero-bar { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* Cards & Grid */
.tl-grid-calc { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: 20px; align-items: start; margin-bottom: 28px; }
.tl-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.tl-card-dark { background: linear-gradient(150deg, #121418 0%, #1d2128 100%); border-color: rgba(255, 255, 255, 0.14); color: #f5f5f5; }
.tl-card h2 { margin: 0 0 14px; font-size: 1.12rem; }
.tl-card-dark h2 { color: #ffffff; }

/* Form Inputs */
.tl-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tl-field { display: grid; gap: 5px; }
.tl-field.full { grid-column: 1 / -1; }
.tl-field label { font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.tl-input, .tl-select { width: 100%; height: 42px; padding: 0 12px; border: 1px solid rgba(17, 17, 17, 0.2); border-radius: 10px; background: var(--white); color: var(--ink); font-family: inherit; font-size: 0.92rem; }
.tl-input:focus, .tl-select:focus { outline: 2px solid var(--ink); outline-offset: 1px; background: #ffffff; }
.tl-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.tl-chip { padding: 6px 12px; border-radius: 999px; border: 1px solid rgba(17, 17, 17, 0.18); background: var(--white); color: var(--ink); font-family: inherit; font-size: 0.8rem; font-weight: 500; cursor: pointer; }
.tl-chip:hover { border-color: var(--ink); }
.tl-chip.is-active { background: var(--ink); color: #ffffff; border-color: var(--ink); }

/* Metrics & Progress */
.tl-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.tl-metric { padding: 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.1); }
.tl-metric span { display: block; font-size: 0.75rem; color: #b8bcc4; }
.tl-metric strong { display: block; font-size: 1.35rem; margin-top: 2px; color: #ffffff; }
.tl-metric.is-deficit strong { color: #7ee787; }
.tl-metric.is-surplus strong { color: #ffca80; }

.tl-macros { display: grid; gap: 10px; margin-bottom: 16px; }
.tl-macro-row { display: grid; gap: 4px; }
.tl-macro-head { display: flex; justify-content: space-between; font-size: 0.82rem; color: #d6d9df; }
.tl-bar { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); overflow: hidden; }
.tl-bar > i { display: block; height: 100%; border-radius: 999px; background: #ffffff; transition: width 0.25s ease; }

.tl-submetrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.tl-submetric span { display: block; font-size: 0.76rem; color: var(--muted); }
.tl-submetric strong { font-size: 1.05rem; }

/* Selected Food List */
.tl-selected-list { display: grid; gap: 8px; max-height: 260px; overflow-y: auto; margin-bottom: 14px; }
.tl-selected-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.1); font-size: 0.86rem; }
.tl-selected-name b { display: block; color: #ffffff; }
.tl-selected-name small { color: #b8bcc4; font-size: 0.76rem; }
.tl-gram-ctrl { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; }
.tl-gram-btn { width: 28px; height: 28px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.35); background: transparent; color: #ffffff; font-weight: 700; cursor: pointer; font-family: inherit; }
.tl-gram-btn:hover { background: rgba(255, 255, 255, 0.18); }
.tl-gram-val { min-width: 48px; text-align: center; font-weight: 600; color: #ffffff; font-size: 0.82rem; }
.tl-empty { padding: 16px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); color: #b8bcc4; font-size: 0.86rem; text-align: center; }

/* Food & Exercise Catalog */
.tl-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.tl-search { flex: 1 1 260px; max-width: 440px; }
.tl-count { font-size: 0.84rem; color: var(--muted); }
.tl-food-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-top: 14px; }
.tl-food-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; justify-content: space-between; gap: 10px; }
.tl-food-card h3 { margin: 0; font-size: 0.98rem; display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.tl-food-card h3 small { font-size: 0.75rem; color: var(--muted); font-weight: 400; }
.tl-food-meta { font-size: 0.78rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 10px; }
.tl-food-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tl-kcal-tag { font-weight: 700; font-size: 0.9rem; }

/* Exercise Directory */
.tl-ex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 14px; margin-top: 16px; }
.tl-ex-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.tl-ex-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.tl-ex-head h3 { margin: 0; font-size: 1.02rem; line-height: 1.35; }
.tl-ex-en { margin: 2px 0 0; font-size: 0.78rem; color: var(--muted); }
.tl-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tl-tag { padding: 3px 9px; border-radius: 999px; background: var(--paper); color: var(--ink); font-size: 0.74rem; font-weight: 500; }
.tl-ex-drawer { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 10px; font-size: 0.86rem; }
.tl-ex-drawer[hidden] { display: none; }
.tl-ex-drawer h4 { margin: 0 0 4px; font-size: 0.84rem; }
.tl-ex-drawer ul { margin: 0; padding-left: 18px; color: #2b2e34; }
.tl-ex-drawer li { margin-bottom: 4px; }
.tl-ex-promo { padding: 12px; border-radius: 12px; background: var(--dark); color: #f5f5f5; font-size: 0.82rem; display: grid; gap: 8px; }
.tl-ex-promo p { margin: 0; color: #d4d7dd; }

/* Bottom CTA */
.tl-cta { margin-top: 32px; padding: 26px; border-radius: 20px; background: var(--dark); color: #f5f5f5; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px; }
.tl-cta-copy { max-width: 680px; }
.tl-cta h2 { margin: 0 0 8px; font-size: 1.3rem; color: #ffffff; }
.tl-cta p { margin: 0 0 14px; color: #c9ccd2; font-size: 0.92rem; }
.tl-cta-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* Footer */
.tl-footer { border-top: 1px solid var(--line); background: var(--paper); }
.tl-footer-inner { max-width: 1160px; margin: 0 auto; padding: 24px 20px; font-size: 0.84rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 10px 20px; justify-content: space-between; }
.tl-footer nav { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.tl-footer a { text-decoration: none; }

/* QR Modal & Toast */
.tl-modal-overlay { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(10, 10, 10, 0.62); opacity: 0; visibility: hidden; transition: opacity 0.2s ease, visibility 0.2s ease; }
.tl-modal-overlay.is-open { opacity: 1; visibility: visible; }
.tl-modal { position: relative; width: min(400px, 100%); background: var(--white); color: var(--ink); border-radius: 22px; padding: 30px 24px 24px; text-align: center; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35); }
.tl-modal-close { position: absolute; top: 12px; right: 14px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: rgba(17, 17, 17, 0.08); color: var(--ink); font-size: 1.25rem; cursor: pointer; }
.tl-modal img { display: block; width: 188px; height: 188px; margin: 16px auto; padding: 10px; background: #ffffff; border-radius: 16px; border: 1px solid var(--line); }
.tl-modal p { margin: 8px 0 0; font-size: 0.84rem; color: var(--muted); }
.tl-toast { position: fixed; left: 50%; bottom: 24px; z-index: 160; transform: translate(-50%, 14px); opacity: 0; pointer-events: none; max-width: min(92vw, 420px); padding: 11px 20px; border-radius: 999px; background: rgba(17, 17, 17, 0.94); color: #ffffff; font-size: 0.86rem; text-align: center; transition: opacity 0.2s ease, transform 0.2s ease; }
.tl-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .tl-grid-calc { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .tl-metrics { grid-template-columns: 1fr; }
  .tl-form-grid { grid-template-columns: 1fr; }
  .tl-ex-grid { grid-template-columns: 1fr; }
}
