:root {
  --brain: #7c3aed;
  --brain-deep: #4c1d95;
  --brain-soft: #f3e8ff;
  --brain-warm: #f59e0b;
}

[data-theme="dark"] {
  --brain-soft: rgba(124, 58, 237, .18);
}

body[data-travel-tool="brain"] { --accent: var(--brain); --accent-soft: var(--brain-soft); }

.tb-hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, .55fr);
  gap: clamp(28px, 6vw, 80px);
  align-items: end;
  min-height: 420px;
  margin-bottom: 18px;
  padding: clamp(30px, 6vw, 70px);
  border-radius: 26px;
  color: #fff;
  background:
    radial-gradient(circle at 84% 17%, rgba(245, 158, 11, .32), transparent 25%),
    radial-gradient(circle at 12% 100%, rgba(167, 139, 250, .3), transparent 38%),
    linear-gradient(135deg, #251147 0%, #4c1d95 48%, #183d3d 100%);
  box-shadow: 0 28px 70px rgba(49, 17, 91, .2);
}

.tb-hero::after {
  content: "";
  position: absolute;
  right: 7%;
  top: 13%;
  width: 116px;
  height: 116px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 50%;
  box-shadow: 0 0 0 22px rgba(255,255,255,.04), 0 0 0 44px rgba(255,255,255,.025);
}

.tb-hero-copy, .tb-hero-proof { position: relative; z-index: 1; min-width: 0; }
.tb-hero .tt-kicker { color: #fcd34d; }
.tb-hero h1 { max-width: 11ch; margin: 8px 0 0; color: #fff; font-size: clamp(2.8rem, 8vw, 6rem); line-height: .88; font-weight: 800; letter-spacing: -.075em; overflow-wrap: anywhere; }
.tb-hero p { max-width: 63ch; margin: 22px 0 0; color: #e9d5ff; font-size: clamp(.9rem, 1.5vw, 1.08rem); line-height: 1.68; }
.tb-hero .tt-btn:not(.tt-btn-primary) { border-color: rgba(255,255,255,.3); background: rgba(255,255,255,.08); color: #fff; }
.tb-hero .tt-btn-primary { background: #f59e0b; border-color: #f59e0b; color: #251147; }

.tb-hero-proof { display: grid; gap: 9px; }
.tb-hero-proof > div { display: grid; grid-template-columns: 68px minmax(0, 1fr); gap: 12px; align-items: center; padding: 13px 15px; border: 1px solid rgba(255,255,255,.18); border-radius: 15px; background: rgba(12, 8, 28, .25); backdrop-filter: blur(12px); }
.tb-hero-proof strong { color: #fff; font-size: 1.65rem; line-height: 1; }
.tb-hero-proof span { color: #ddd6fe; font-size: .68rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }

.tb-boundary { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 14px; align-items: start; margin-bottom: 48px; padding: 17px 19px; border: 1px solid color-mix(in srgb, var(--brain), transparent 72%); border-radius: 16px; background: color-mix(in srgb, var(--brain-soft), var(--surface, #fff) 45%); }
.tb-boundary > i { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: var(--brain); color: #fff; font-size: 1.08rem; }
.tb-boundary strong { display: block; color: var(--text); font-size: .8rem; }
.tb-boundary p { margin: 4px 0 0; color: var(--muted); font-size: .7rem; line-height: 1.6; }

.tb-library { scroll-margin-top: 90px; }
.tb-library-grid { display: grid; grid-template-columns: minmax(250px, 300px) minmax(0, 1fr); gap: 18px; align-items: start; }
.tb-filters { position: sticky; top: 88px; display: grid; gap: 13px; }
.tb-filters .tt-field { margin: 0; }
.tb-filters .tt-btn { width: 100%; }
.tb-memory-column { min-width: 0; }
.tb-signal-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 12px; color: var(--muted); font-size: .64rem; }
.tb-signal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tb-signal-legend i { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; }
.tb-signal-legend i.current { background: #059669; }
.tb-signal-legend i.recheck { background: #d97706; }
.tb-signal-legend i.changed { background: #7c3aed; }
.tb-signal-legend i.closed { background: #dc2626; }

.tb-memory-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.tb-memory-card { position: relative; overflow: hidden; min-width: 0; display: flex; flex-direction: column; padding: 19px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); box-shadow: 0 10px 30px rgba(15, 23, 42, .05); }
.tb-memory-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: #94a3b8; }
.tb-memory-card[data-signal="current"]::before { background: #059669; }
.tb-memory-card[data-signal="recheck"]::before { background: #d97706; }
.tb-memory-card[data-signal="changed"]::before { background: #7c3aed; }
.tb-memory-card[data-signal="not-found"]::before, .tb-memory-card[data-signal="closed"]::before { background: #dc2626; }
.tb-memory-top { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.tb-memory-place { min-width: 0; color: var(--brain); font-size: .65rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; overflow-wrap: anywhere; }
.tb-memory-card h3 { margin: 12px 0 5px; color: var(--text); font-size: 1.04rem; font-weight: 800; letter-spacing: -.02em; overflow-wrap: anywhere; }
.tb-memory-story { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 3; -webkit-box-orient: vertical; margin: 0; color: var(--muted); font-size: .73rem; line-height: 1.6; overflow-wrap: anywhere; }
.tb-memory-tip { margin: 15px 0 0; padding: 11px 12px; border-radius: 11px; background: var(--input); color: var(--text); font-size: .7rem; line-height: 1.5; overflow-wrap: anywhere; }
.tb-memory-tip strong { display: block; margin-bottom: 2px; color: var(--brain); font-size: .6rem; letter-spacing: .06em; text-transform: uppercase; }
.tb-memory-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; }
.tb-memory-meta span { display: inline-flex; align-items: center; gap: 5px; min-width: 0; padding: 5px 7px; border-radius: 999px; background: var(--input); color: var(--muted); font-size: .6rem; overflow-wrap: anywhere; }
.tb-memory-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: auto; padding-top: 16px; }
.tb-memory-actions .tt-btn { flex: 1 1 auto; }
.tb-signal { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 999px; background: var(--input); color: var(--muted); font-size: .59rem; font-weight: 750; white-space: nowrap; }
.tb-signal.current { background: var(--good-soft, #ecfdf5); color: var(--good, #047857); }
.tb-signal.recheck { background: var(--warn-soft, #fff7ed); color: #b45309; }
.tb-signal.changed { background: var(--brain-soft); color: var(--brain); }
.tb-signal.not-found, .tb-signal.closed { background: var(--bad-soft, #fef2f2); color: var(--bad, #b91c1c); }
.tb-share-mark { color: var(--brain); }
.tb-empty strong, .tb-empty span { display: block; }
.tb-empty strong { color: var(--text); font-size: .88rem; }
.tb-empty span { max-width: 52ch; margin: 5px auto 15px; }

.tb-capture { margin-top: 52px; scroll-margin-top: 90px; }
.tb-form-section { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 12px; align-items: start; margin: 30px 0 15px; padding-top: 22px; border-top: 1px solid var(--border); }
.tb-form-section:first-of-type { margin-top: 10px; padding-top: 0; border-top: 0; }
.tb-form-number { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--brain-soft); color: var(--brain); font-size: .68rem; font-weight: 800; }
.tb-form-section h3 { margin: 0; color: var(--text); font-size: .88rem; font-weight: 800; }
.tb-form-section p { margin: 4px 0 0; color: var(--muted); font-size: .68rem; line-height: 1.5; }
.tb-share-choice { margin-top: 18px; background: color-mix(in srgb, var(--brain-soft), var(--surface) 60%); }
.tb-share-choice strong { display: block; color: var(--text); }

.tb-handoff { margin-top: 18px; scroll-margin-top: 90px; }
.tb-handoff-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tb-handoff-grid article { min-width: 0; display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 10px; align-content: start; padding: 15px; border: 1px solid var(--border); border-radius: 14px; background: var(--input); }
.tb-handoff-grid article > i { color: var(--brain); font-size: 1.2rem; }
.tb-handoff-grid h3 { margin: 0; color: var(--text); font-size: .82rem; font-weight: 750; }
.tb-handoff-grid p { margin: 5px 0 13px; color: var(--muted); font-size: .67rem; line-height: 1.5; }
.tb-handoff-grid .tt-btn { grid-column: 1 / -1; width: 100%; }
.tb-import-history { margin-top: 13px; color: var(--muted); font-size: .66rem; }
.tb-import-history ul { margin: 7px 0 0; padding-left: 18px; }

.tb-dialog { width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; padding: 0; border: 0; background: transparent; }
.tb-dialog::backdrop { background: rgba(15, 7, 31, .76); backdrop-filter: blur(5px); }
.tb-dialog[open] { display: grid; place-items: center; padding: 28px; }
.tb-dialog-card { position: relative; width: min(920px, 100%); max-height: calc(100dvh - 56px); overflow: auto; padding: clamp(22px, 5vw, 44px); border-radius: 22px; background: var(--surface); color: var(--text); box-shadow: 0 32px 90px rgba(0,0,0,.35); }
.tb-dialog-small { width: min(680px, 100%); }
.tb-dialog-close { position: absolute; z-index: 2; right: 14px; top: 14px; width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--text); }
.tb-dialog-intro { margin: 8px 54px 20px 0; color: var(--muted); font-size: .78rem; }
.tb-detail-head { padding-right: 55px; }
.tb-detail-head h2 { margin: 8px 0 5px; color: var(--text); font-size: clamp(1.7rem, 5vw, 3rem); font-weight: 800; letter-spacing: -.045em; overflow-wrap: anywhere; }
.tb-detail-lede { color: var(--muted); font-size: .84rem; line-height: 1.7; }
.tb-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 22px; }
.tb-detail-block { min-width: 0; padding: 15px; border-radius: 14px; background: var(--input); }
.tb-detail-block.wide { grid-column: 1 / -1; }
.tb-detail-block span { display: block; margin-bottom: 5px; color: var(--brain); font-size: .6rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.tb-detail-block p { margin: 0; color: var(--text); font-size: .73rem; line-height: 1.62; overflow-wrap: anywhere; }
.tb-update-list { display: grid; gap: 8px; margin-top: 22px; }
.tb-update-row { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; padding: 12px; border-left: 3px solid var(--brain); border-radius: 0 11px 11px 0; background: var(--input); }
.tb-update-row strong, .tb-update-row small { display: block; }
.tb-update-row strong { color: var(--text); font-size: .68rem; }
.tb-update-row small { margin-top: 3px; color: var(--muted); font-size: .6rem; }
.tb-update-row p { margin: 0; color: var(--text); font-size: .7rem; line-height: 1.55; overflow-wrap: anywhere; }

@media (max-width: 980px) {
  .tb-hero { grid-template-columns: 1fr; min-height: 0; }
  .tb-hero-proof { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tb-hero-proof > div { grid-template-columns: 1fr; }
  .tb-library-grid { grid-template-columns: 1fr; }
  .tb-filters { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tb-filters .tt-panel-head { grid-column: 1 / -1; }
  .tb-handoff-grid { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .tb-hero { padding: 28px 21px; border-radius: 20px; }
  .tb-hero h1 { font-size: clamp(2.8rem, 17vw, 4.8rem); }
  .tb-hero-proof { grid-template-columns: 1fr; }
  .tb-hero-proof > div { grid-template-columns: 62px minmax(0, 1fr); }
  .tb-memory-grid, .tb-filters, .tb-detail-grid { grid-template-columns: 1fr; }
  .tb-filters .tt-panel-head, .tb-detail-block.wide { grid-column: 1; }
  .tb-dialog[open] { padding: 0; }
  .tb-dialog-card { width: 100%; min-height: 100dvh; max-height: 100dvh; border-radius: 0; padding: 24px 18px 34px; }
  .tb-update-row { grid-template-columns: 1fr; }
}

@media print {
  .tb-hero { min-height: 0; color: #111827; background: #fff; box-shadow: none; border: 1px solid #d1d5db; }
  .tb-hero h1, .tb-hero-proof strong { color: #111827; }
  .tb-hero p, .tb-hero-proof span { color: #475569; }
  .tb-hero-proof > div { background: #fff; border-color: #d1d5db; }
  .tb-filters, .tb-capture, .tb-handoff, .tb-boundary, .tb-memory-actions { display: none !important; }
  .tb-library-grid { display: block; }
  .tb-memory-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
