/* ==========================================================================
   ATech Thiên Cơ v3 — Imperial Observatory Shell & Obsidian Lacquer System
   ========================================================================== */

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

html {
  background-color: var(--bg-canvas);
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

body {
  position: relative;
  isolation: isolate;
  margin: 0;
  font-family: var(--p-font-sans);
  font-size: var(--p-text-base);
  font-weight: 400;
  line-height: 1.65;
  letter-spacing: 0.01em;
  background-color: transparent;
  color: var(--text-primary);
  min-height: 100dvh;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   LIVING ATMOSPHERIC BACKGROUND LAYERS (z: -3, -2, -1 — Strictly behind UI)
   ========================================================================== */
.tc-atmo-backdrop {
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(ellipse 96% 68% at 50% -8%, rgba(36, 52, 92, 0.84) 0%, rgba(14, 20, 38, 0.42) 48%, transparent 72%),
    radial-gradient(ellipse 76% 58% at 78% 22%, rgba(229, 183, 102, 0.16) 0%, rgba(148, 104, 42, 0.05) 48%, transparent 70%),
    radial-gradient(ellipse 68% 54% at 14% 82%, rgba(122, 96, 204, 0.16) 0%, transparent 66%),
    var(--bg-canvas);
}

.tc-atmo-mist {
  position: absolute;
  border-radius: 50%;
  will-change: transform, opacity;
  pointer-events: none;
}

.tc-atmo-mist--a {
  top: -22%;
  right: -12%;
  width: 74vmax;
  height: 74vmax;
  background: radial-gradient(circle, rgba(243, 207, 138, 0.22) 0%, rgba(196, 142, 58, 0.09) 38%, transparent 70%);
  animation: tcMistDriftA 17s ease-in-out infinite alternate;
}

.tc-atmo-mist--b {
  bottom: -24%;
  left: -14%;
  width: 78vmax;
  height: 78vmax;
  background: radial-gradient(circle, rgba(138, 112, 224, 0.22) 0%, rgba(52, 72, 138, 0.12) 44%, transparent 72%);
  animation: tcMistDriftB 21s ease-in-out infinite alternate;
}

.tc-atmo-mist--c {
  top: 24%;
  left: 22%;
  width: 58vmax;
  height: 58vmax;
  background: radial-gradient(circle, rgba(58, 86, 158, 0.18) 0%, rgba(229, 183, 102, 0.08) 42%, transparent 72%);
  animation: tcMistDriftC 25s ease-in-out infinite alternate;
}

body[data-atmo="observatory"] .tc-atmo-mist--a { opacity: 0.82; }
body[data-atmo="observatory"] .tc-atmo-mist--b { opacity: 0.78; }
body[data-atmo="observatory"] .tc-atmo-mist--c { opacity: 0.72; }
body[data-atmo="sanctuary"] .tc-atmo-mist--b {
  background: radial-gradient(circle, rgba(162, 128, 238, 0.26) 0%, rgba(62, 46, 118, 0.13) 46%, transparent 74%);
}

body.tc-atmo-paused .tc-atmo-mist,
body.tc-atmo-paused .tc-brand-crest::before {
  animation-play-state: paused !important;
}

@keyframes tcMistDriftA {
  0%   { transform: translate3d(0, 0, 0) scale(1); opacity: 0.82; }
  50%  { opacity: 1; }
  100% { transform: translate3d(-9%, 8%, 0) scale(1.14); opacity: 0.88; }
}

@keyframes tcMistDriftB {
  0%   { transform: translate3d(0, 0, 0) scale(1); opacity: 0.80; }
  50%  { opacity: 1; }
  100% { transform: translate3d(10%, -7%, 0) scale(1.12); opacity: 0.86; }
}

@keyframes tcMistDriftC {
  0%   { transform: translate3d(-4%, 3%, 0) scale(0.95); opacity: 0.65; }
  100% { transform: translate3d(6%, -5%, 0) scale(1.15); opacity: 0.96; }
}

.tc-atmo-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  pointer-events: none;
}

.tc-atmo-grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.032;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

/* ==========================================================================
   TYPOGRAPHY & ACCESSIBILITY UTILITIES
   ========================================================================== */
h1, h2 {
  font-family: var(--p-font-display);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.012em;
  margin: 0;
  text-wrap: balance;
}

h3, h4 {
  font-family: var(--p-font-sans);
  font-weight: 600;
  line-height: 1.32;
  margin: 0;
}

p {
  margin: 0;
  text-wrap: pretty;
}

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

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.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;
}

.skip-link {
  position: fixed;
  top: -100px;
  left: 16px;
  z-index: var(--p-z-toast);
  padding: 10px 16px;
  background: var(--accent-primary);
  color: var(--text-on-accent);
  border-radius: var(--p-radius-sm);
  font-weight: 600;
  font-size: var(--p-text-sm);
}
.skip-link:focus {
  top: 12px;
}

/* ==========================================================================
   TOPBAR (Obsidian Lacquer Sticky Bar + Celestial Ring Brand Mark)
   ========================================================================== */
.tc-topbar {
  position: sticky;
  top: 0;
  z-index: var(--p-z-sticky);
  min-height: var(--topbar-height);
  padding: env(safe-area-inset-top) var(--p-space-4) 0;
  background: rgba(7, 10, 17, 0.84);
  border-bottom: 1px solid var(--border-hairline);
  box-shadow: inset 0 -1px 0 rgba(243, 207, 138, 0.06);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.tc-topbar-inner {
  max-width: var(--container-wide);
  margin: 0 auto;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--p-space-3);
}

.tc-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text-primary);
  min-height: 44px;
}

.tc-brand-crest {
  position: relative;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tc-brand-crest::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 1px dashed rgba(229, 183, 102, 0.34);
  animation: tcSpin 28s linear infinite;
}

.tc-brand img {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.tc-brand-name {
  font-family: var(--p-font-display);
  font-size: 1.38rem;
  font-weight: 600;
  letter-spacing: 0.015em;
  color: var(--text-primary);
  line-height: 1;
}

.tc-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 10px 0 4px;
  color: var(--text-secondary);
  font-size: var(--p-text-sm);
  font-weight: 500;
  border-radius: var(--p-radius-sm);
  transition: color var(--p-dur-fast) var(--p-ease-out);
}
.tc-back-link:hover {
  color: var(--text-accent);
}

.tc-desktop-nav {
  display: none;
  align-items: center;
  gap: 4px;
}

.tc-desktop-nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--p-radius-sm);
  color: var(--text-muted);
  font-size: var(--p-text-sm);
  font-weight: 500;
  border: 1px solid transparent;
  transition: color var(--p-dur-fast) var(--p-ease-out), background-color var(--p-dur-fast) var(--p-ease-out), border-color var(--p-dur-fast) var(--p-ease-out);
}

.tc-desktop-nav a:hover {
  color: var(--text-primary);
  background: rgba(229, 183, 102, 0.06);
}

.tc-desktop-nav a[aria-current="page"] {
  color: var(--accent-hover);
  background: var(--accent-tint);
  border-color: var(--border-hairline);
}

.tc-topbar-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.tc-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  gap: 6px;
  background: rgba(14, 19, 30, 0.72);
  border: 1px solid var(--border-hairline);
  border-radius: var(--p-radius-sm);
  color: var(--text-secondary);
  font-size: var(--p-text-xs);
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--p-dur-fast) var(--p-ease-out), color var(--p-dur-fast) var(--p-ease-out), background-color var(--p-dur-fast) var(--p-ease-out);
}
.tc-icon-btn:hover {
  border-color: var(--border-accent);
  color: var(--accent-hover);
  background: rgba(22, 29, 45, 0.9);
}

.tc-atmo-toggle {
  padding: 0;
  width: 44px;
  border-radius: 50%;
}
.tc-atmo-toggle.is-active {
  color: var(--accent-hover);
  border-color: var(--border-accent);
  background: rgba(229, 183, 102, 0.10);
}

/* ==========================================================================
   BOTTOM TAB BAR (Mobile < 1024px)
   ========================================================================== */
.tc-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--p-z-sticky);
  background: rgba(7, 10, 17, 0.92);
  border-top: 1px solid var(--border-hairline);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding-bottom: env(safe-area-inset-bottom);
}

.tc-tabbar-inner {
  max-width: 560px;
  margin: 0 auto;
  height: var(--tabbar-height);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.tc-tabbar a {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  min-height: 48px;
  transition: color var(--p-dur-fast) var(--p-ease-out);
}

.tc-tabbar a[aria-current="page"] {
  color: var(--accent-hover);
}

.tc-tabbar a[aria-current="page"]::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-hover), transparent);
}

@media (min-width: 1024px) {
  :root {
    --topbar-height: 64px;
  }
  .tc-topbar {
    min-height: var(--topbar-height);
  }
  .tc-topbar-inner {
    height: var(--topbar-height);
  }
  .tc-desktop-nav {
    display: inline-flex;
  }
  .tc-tabbar {
    display: none;
  }
}

/* ==========================================================================
   MAIN CONTAINER, LACQUER PLATES (.codex-card) & SPECULAR RIM (.tc-luminous)
   ========================================================================== */
.tc-main {
  max-width: var(--container-narrow);
  margin: 0 auto;
  padding: var(--p-space-5) var(--p-space-4) calc(var(--tabbar-height) + env(safe-area-inset-bottom) + 36px);
}

.tc-main--wide {
  max-width: var(--container-wide);
}

@media (min-width: 1024px) {
  .tc-main {
    padding: var(--p-space-8) var(--p-space-6) var(--p-space-12);
  }
}

.codex-card {
  position: relative;
  background: var(--surface-lacquer);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  padding: var(--p-space-5);
  box-shadow: var(--bevel-top), 0 14px 34px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.codex-card--elevated {
  background: var(--surface-lacquer-hi);
}

.codex-card--ai {
  background: var(--ai-surface-grad);
  border-color: var(--ai-border);
  box-shadow: inset 0 1px 0 rgba(185, 167, 238, 0.14);
}

/* Cursor-reactive tactile warm brass sheen on focal interactive lacquer surfaces */
.tc-luminous {
  --mx: 50%;
  --my: 20%;
  position: relative;
  overflow: hidden;
}

.tc-luminous::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(320px circle at var(--mx, 50%) var(--my, 20%), rgba(243, 207, 138, 0.12), transparent 64%);
  transition: opacity var(--p-dur-base) var(--ease-out-quart);
  z-index: 1;
}

@media (hover: hover) and (pointer: fine) {
  .tc-luminous:hover::before {
    opacity: 1;
  }
}

/* Signature Horological Corner Hairlines (Reserved strictly for Hero / Primary Plates) */
.codex-ticks::after {
  content: '';
  position: absolute;
  inset: 9px;
  border-radius: calc(var(--card-radius) - 6px);
  border: 1px solid rgba(229, 183, 102, 0.08);
  pointer-events: none;
}

/* Engraved Brass Chapter Divider */
.tc-chapter-rule {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: var(--p-space-8) 0 var(--p-space-6);
}

.tc-chapter-rule::before,
.tc-chapter-rule::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(229, 183, 102, 0.34), transparent);
}

.tc-chapter-rule span {
  font-family: var(--p-font-display);
  font-size: 0.95rem;
  font-style: italic;
  letter-spacing: 0.06em;
  color: var(--text-accent);
  white-space: nowrap;
}

/* Archival Cinnabar Seal Stamp (Ấn Triện) */
.tc-seal {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 4px;
  background: var(--seal-bg);
  border: 1px solid var(--seal-border);
  color: var(--seal-cinnabar);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Eyebrow & Page Title */
.tc-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--p-text-xs);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-accent);
  margin-bottom: var(--p-space-2);
}

.tc-page-title {
  font-size: clamp(1.9rem, 5vw, 2.75rem);
  color: var(--text-primary);
  margin-bottom: var(--p-space-2);
}

.tc-page-lead {
  font-size: var(--p-text-sm);
  color: var(--text-secondary);
  max-width: 56ch;
}

/* ==========================================================================
   BUTTONS, SEGMENTED CONTROLS & FORM CONTROLS (iOS 16px safe, >=48px tap)
   ========================================================================== */
.tc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--btn-height);
  padding: 10px var(--p-space-5);
  border-radius: var(--btn-radius);
  font-size: var(--p-text-sm);
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color var(--p-dur-fast) var(--p-ease-out), border-color var(--p-dur-fast) var(--p-ease-out), color var(--p-dur-fast) var(--p-ease-out), transform var(--p-dur-fast) var(--p-ease-out), box-shadow var(--p-dur-fast) var(--p-ease-out);
  touch-action: manipulation;
}

.tc-btn:active:not(:disabled) {
  transform: translateY(1px) scale(0.99);
}

.tc-btn:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.tc-btn--primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
  border-color: rgba(246, 213, 148, 0.55);
  box-shadow: inset 0 1px 0 rgba(255, 246, 224, 0.45), 0 6px 18px rgba(0, 0, 0, 0.35);
}
.tc-btn--primary:hover:not(:disabled) {
  background: var(--btn-primary-hover);
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255, 246, 224, 0.55), 0 10px 24px rgba(0, 0, 0, 0.42);
}

.tc-btn--secondary {
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-fg);
  border-color: var(--btn-secondary-bd);
  box-shadow: var(--bevel-top);
}
.tc-btn--secondary:hover:not(:disabled) {
  background: rgba(26, 33, 52, 0.92);
  border-color: var(--accent-hover);
  color: var(--accent-hover);
  transform: translateY(-1px);
}

.tc-btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}
.tc-btn--ghost:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: var(--border-accent);
  background: rgba(229, 183, 102, 0.06);
}

.tc-btn--full {
  width: 100%;
}

.tc-btn--sm {
  min-height: 44px;
  padding: 0 14px;
  font-size: var(--p-text-xs);
}

/* Segmented Control */
.tc-segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  background: rgba(5, 7, 12, 0.85);
  border: 1px solid var(--border-hairline);
  border-radius: var(--p-radius-md);
}

.tc-segmented button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--p-radius-sm);
  color: var(--text-muted);
  font-size: var(--p-text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--p-dur-fast) var(--p-ease-out), color var(--p-dur-fast) var(--p-ease-out), border-color var(--p-dur-fast) var(--p-ease-out);
}

.tc-segmented button[aria-selected="true"],
.tc-segmented button.active {
  background: var(--surface-lacquer-hi);
  color: var(--accent-hover);
  border-color: var(--border-accent);
  box-shadow: var(--bevel-top);
}

/* Form Controls */
.tc-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.tc-label {
  font-size: var(--p-text-xs);
  font-weight: 500;
  color: var(--text-secondary);
}

.tc-input,
.tc-select,
.tc-textarea {
  width: 100%;
  min-height: var(--input-height);
  padding: 10px 12px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--input-radius);
  color: var(--text-primary);
  font-size: 16px; /* Prevents iOS Safari auto-zoom */
  line-height: 1.4;
  transition: border-color var(--p-dur-fast) var(--p-ease-out), background-color var(--p-dur-fast) var(--p-ease-out), box-shadow var(--p-dur-fast) var(--p-ease-out);
}

.tc-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23C0BBB0' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 34px;
}

.tc-input::placeholder,
.tc-textarea::placeholder {
  color: var(--text-muted);
}

.tc-input:focus,
.tc-select:focus,
.tc-textarea:focus {
  border-color: var(--border-focus);
  background: rgba(8, 11, 18, 0.94);
  outline: none;
  box-shadow: var(--focus-ring);
}

.tc-hint {
  font-size: var(--p-text-xs);
  color: var(--text-muted);
}

/* Status Pills */
.tc-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--p-radius-pill);
  font-size: var(--p-text-xs);
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
}
.tc-pill--brass { background: var(--accent-tint); color: var(--accent-hover); border-color: var(--border-hairline); }
.tc-pill--good  { background: var(--status-good-bg); color: var(--status-good); border-color: rgba(122, 202, 151, 0.3); }
.tc-pill--bad   { background: var(--status-bad-bg); color: var(--status-bad); border-color: rgba(238, 128, 126, 0.3); }
.tc-pill--warn  { background: var(--status-warn-bg); color: var(--status-warn); border-color: rgba(233, 168, 108, 0.3); }
.tc-pill--ai    { background: var(--ai-surface); color: var(--ai-accent); border-color: var(--ai-border); }

/* Editorial Brass Affiliate Bookmark */
.brass-callout {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface-lacquer);
  border: 1px solid var(--border-hairline);
  border-radius: var(--p-radius-md);
  color: var(--text-primary);
  box-shadow: var(--bevel-top);
  transition: background-color var(--p-dur-fast) var(--p-ease-out), border-color var(--p-dur-fast) var(--p-ease-out);
}
.brass-callout:hover {
  border-color: var(--border-accent);
}
.brass-callout-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--p-radius-sm);
  background: var(--accent-tint);
  border: 1px solid var(--border-hairline);
  color: var(--accent-hover);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brass-callout-title {
  display: block;
  font-size: var(--p-text-sm);
  font-weight: 600;
  color: var(--accent-hover);
}
.brass-callout-desc {
  display: block;
  font-size: var(--p-text-xs);
  color: var(--text-secondary);
}

/* ==========================================================================
   SHARED ORACLE CHAT, STREAMING SKELETON & BOTTOM SHEET
   ========================================================================== */
@keyframes tcPulse {
  0%, 100% { opacity: 0.35; transform: scale(0.88); }
  50% { opacity: 1; transform: scale(1.1); }
}

@keyframes tcShimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes tcSpin {
  to { transform: rotate(360deg); }
}

.tc-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: tcSpin 750ms linear infinite;
  display: inline-block;
}

.tc-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.tc-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ai-accent);
  animation: tcPulse 1.1s ease-in-out infinite;
}
.tc-dots span:nth-child(2) { animation-delay: 0.18s; }
.tc-dots span:nth-child(3) { animation-delay: 0.36s; }

.tc-skeleton-line {
  height: 13px;
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(229,183,102,0.12) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: tcShimmer 1.8s ease-in-out infinite;
  margin-bottom: 10px;
}

.tc-chat-bubbles {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 440px;
  overflow-y: auto;
  padding-right: 4px;
}

.tc-bubble {
  padding: 13px 16px;
  border-radius: var(--p-radius-md);
  font-size: var(--p-text-sm);
  line-height: 1.72;
  max-width: 92%;
}

.tc-bubble--bot {
  align-self: flex-start;
  background: rgba(10, 14, 22, 0.88);
  border: 1px solid var(--border-hairline);
  color: var(--text-primary);
}

.tc-bubble--user {
  align-self: flex-end;
  background: rgba(28, 34, 52, 0.85);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.tc-quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tc-quick-chips button {
  min-height: 36px;
  padding: 6px 12px;
  background: rgba(8, 11, 18, 0.82);
  border: 1px solid var(--border-hairline);
  border-radius: var(--p-radius-pill);
  color: var(--text-secondary);
  font-size: var(--p-text-xs);
  cursor: pointer;
  transition: border-color var(--p-dur-fast) var(--p-ease-out), color var(--p-dur-fast) var(--p-ease-out);
}
.tc-quick-chips button:hover {
  border-color: var(--border-accent);
  color: var(--accent-hover);
}

/* Modal / Bottom Sheet */
.tc-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--p-z-modal);
  background: var(--surface-scrim);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.tc-sheet-backdrop.open {
  display: flex;
}

.tc-sheet {
  width: 100%;
  max-width: 600px;
  max-height: 85dvh;
  overflow-y: auto;
  background: var(--surface-lacquer-hi);
  border: 1px solid var(--border-accent);
  border-radius: var(--p-radius-lg) var(--p-radius-lg) 0 0;
  padding: var(--p-space-5);
  padding-bottom: calc(var(--p-space-5) + env(safe-area-inset-bottom));
  box-shadow: var(--bevel-top);
}

@media (min-width: 768px) {
  .tc-sheet-backdrop {
    align-items: center;
    padding: var(--p-space-6);
  }
  .tc-sheet {
    border-radius: var(--p-radius-lg);
  }
}

.tc-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border-hairline);
}

/* Error & Alert Box */
.tc-alert {
  padding: 12px 14px;
  border-radius: var(--p-radius-sm);
  font-size: var(--p-text-sm);
  border: 1px solid var(--border-hairline);
}
.tc-alert--error {
  background: var(--status-bad-bg);
  border-color: rgba(238, 128, 126, 0.35);
  color: var(--status-bad);
}
.tc-alert--warn {
  background: var(--status-warn-bg);
  border-color: rgba(233, 168, 108, 0.35);
  color: var(--status-warn);
}

.tc-footer {
  text-align: center;
  padding: var(--p-space-8) 0 var(--p-space-4);
  margin-top: var(--p-space-8);
  border-top: 1px solid var(--border-hairline);
  font-size: var(--p-text-xs);
  color: var(--text-muted);
}

@media (prefers-reduced-motion: reduce) {
  body:not(.tc-atmo-forced) .tc-atmo-mist,
  body:not(.tc-atmo-forced) .tc-brand-crest::before,
  body:not(.tc-atmo-forced) .tc-skeleton-line,
  body:not(.tc-atmo-forced) .tc-dots span {
    animation: none !important;
  }
}
