/* /thoughts/ - Empty Thoughts surface.
 * Private cognition vault. Tree + ranked list.
 * Inherits site palette (dark monochrome, JetBrains Mono).
 */

.thoughts-shell {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  background: #0a0a0a;
  color: #d4d4d4;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 13px;
  z-index: 10;
}

.thoughts-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 14px 22px;
  border-bottom: 1px solid #1f1f1f;
  background: #0a0a0a;
  gap: 16px;
}

.thoughts-topbar-left { display: flex; align-items: center; gap: 16px; }

.thoughts-nav-home {
  color: #d4d4d4;
  text-decoration: none;
  font-size: 12px;
  letter-spacing: 0.04em;
  opacity: 0.7;
  transition: opacity 0.18s;
}
.thoughts-nav-home:hover { opacity: 1; }

.thoughts-nav-sep {
  color: #3a3a3a;
  font-size: 12px;
  user-select: none;
}
.thoughts-topbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.thoughts-tab {
  color: #6b6b6b;
  text-decoration: none;
  font-size: 12px;
  letter-spacing: 0.04em;
  padding: 4px 0;
  border-bottom: 1px solid transparent;
  transition: color 0.18s, border-color 0.18s;
}
.thoughts-tab:hover { color: #d4d4d4; }
.thoughts-tab--active {
  color: #d4d4d4;
  border-bottom-color: #d4d4d4;
}

.thoughts-btn {
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.05em;
  background: transparent;
  color: #d4d4d4;
  border: 1px solid #2a2a2a;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.thoughts-btn:hover {
  background: #161616;
  border-color: #4a4a4a;
}
.thoughts-btn--primary {
  border-color: #6b6b6b;
  color: #fff;
}
.thoughts-btn--primary:hover {
  background: #1a1a1a;
  border-color: #d4d4d4;
}
.thoughts-btn--ghost {
  color: #6b6b6b;
  border-color: #1f1f1f;
}
.thoughts-btn--ghost:hover {
  color: #b76060;
  border-color: #b76060;
}

/* -------- one-tap capture button -------- */
.th-capture-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.06em;
  background: transparent;
  color: #fff;
  border: 1px solid #6b6b6b;
  min-width: 118px;
  min-height: 34px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.th-capture-btn:hover { background: #1a1a1a; border-color: #d4d4d4; }
.th-capture-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #6b6b6b;
  display: inline-block;
  transition: background 0.15s, box-shadow 0.15s;
}
.th-capture-btn:hover .th-capture-dot { background: #d4d4d4; }
.th-capture-btn.is-recording {
  border-color: #b76060;
  color: #f0d0d0;
}
.th-capture-btn.is-recording .th-capture-dot {
  background: #d04646;
  box-shadow: 0 0 0 0 rgba(208, 70, 70, 0.6);
  animation: th-capture-pulse 1.05s ease-out infinite;
}
@keyframes th-capture-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(208, 70, 70, 0.6); }
  70%  { box-shadow: 0 0 0 9px rgba(208, 70, 70, 0); }
  100% { box-shadow: 0 0 0 0 rgba(208, 70, 70, 0); }
}
.th-capture-btn.is-busy {
  border-color: #6b6b6b;
  color: #d4d4d4;
  cursor: progress;
}
.th-capture-btn.is-busy .th-capture-dot {
  background: #d4d4d4;
  animation: th-capture-blink 0.8s ease-in-out infinite;
}
@keyframes th-capture-blink {
  0%, 100% { opacity: 0.35; }
  50%      { opacity: 1; }
}
.th-capture-btn.is-done { border-color: #6db66d; color: #cfe8cf; }
.th-capture-btn.is-done .th-capture-dot { background: #6db66d; }
.th-capture-btn.is-error { border-color: #b76060; color: #f0d0d0; }
.th-capture-btn.is-error .th-capture-dot { background: #d04646; }

.th-capture-aux {
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.08em;
  background: transparent;
  color: #b0b0b0;
  border: 1px solid #4a4a4a;
  padding: 6px 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.th-capture-aux:hover { background: #1a1a1a; border-color: #d4d4d4; color: #fff; }
.th-capture-aux.is-paused { border-color: #c4a05a; color: #e8d59a; }

.th-capture-status {
  font-size: 11px;
  letter-spacing: 0.04em;
  color: #6b6b6b;
  max-width: 360px;
  text-align: right;
  margin-right: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.th-capture-status.is-ok  { color: #6db66d; }
.th-capture-status.is-err { color: #b76060; }
.th-capture-status:empty { display: none; }

.th-type-form {
  display: flex;
  align-items: center;
  flex: 0 1 420px;
  min-width: 240px;
  border: 1px solid #2a2a2a;
  background: #070707;
}
.th-type-input {
  min-width: 0;
  width: 100%;
  height: 34px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 12px;
  color: #d4d4d4;
  background: transparent;
  border: 0;
  outline: 0;
}
.th-type-input::placeholder { color: #4a4a4a; }
.th-type-submit {
  height: 34px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: #b0b0b0;
  background: transparent;
  border: 0;
  border-left: 1px solid #2a2a2a;
  cursor: pointer;
}
.th-type-submit:hover {
  color: #fff;
  background: #141414;
}

/* -------- tree canvas -------- */
.thoughts-canvas-wrap {
  position: relative;
  overflow: hidden;
  background: #050505;
  background-image:
    radial-gradient(circle at 50% 50%, rgba(255,255,255,0.015) 0%, transparent 70%),
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: auto, 40px 40px, 40px 40px;
}

.thoughts-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.thoughts-canvas.is-panning { cursor: grabbing; }

.thoughts-canvas-hint {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(360px, 82vw);
  color: #4a4a4a;
  font-size: 13px;
  pointer-events: none;
  letter-spacing: 0.03em;
  text-align: center;
  line-height: 1.6;
}
.thoughts-canvas-hint strong { color: #d4d4d4; font-weight: 500; }

.thoughts-zoom-readout {
  position: absolute;
  bottom: 16px;
  right: 18px;
  color: #4a4a4a;
  font-size: 11px;
  letter-spacing: 0.05em;
  pointer-events: none;
}

/* tree node */
.th-node {
  cursor: pointer;
}
.th-node rect {
  fill: #0d0d0d;
  stroke: #5a5a5a;
  stroke-width: 1;
  filter: drop-shadow(0 10px 24px rgba(0,0,0,0.45));
  transition: stroke 0.18s, fill 0.18s;
}
.th-node:hover rect { stroke: #d4d4d4; fill: #141414; }
.th-node.is-selected rect { stroke: #fff; stroke-width: 1.5; fill: #1a1a1a; }
.th-node text {
  fill: #d4d4d4;
  font-family: inherit;
  font-size: 14px;
  pointer-events: none;
}
.th-node .th-node-count {
  fill: #6b6b6b;
  font-size: 11px;
}
.th-edge {
  stroke: #2a2a2a;
  stroke-width: 1;
  fill: none;
}

/* -------- drawer -------- */
.thoughts-drawer {
  position: absolute;
  top: 50px;
  right: 0;
  bottom: 0;
  width: clamp(340px, 28vw, 440px);
  background: #0a0a0a;
  border-left: 1px solid #1f1f1f;
  box-shadow: -24px 0 48px rgba(0,0,0,0.45);
  display: grid;
  grid-template-rows: auto 1fr auto;
  animation: th-drawer-in 0.22s ease-out;
}
@keyframes th-drawer-in {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.thoughts-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid #1f1f1f;
}
.thoughts-drawer-title {
  font-size: 13px;
  letter-spacing: 0.04em;
  color: #d4d4d4;
}
.thoughts-drawer-close {
  background: transparent; border: none; color: #6b6b6b;
  font-size: 18px; cursor: pointer; padding: 4px 8px;
}
.thoughts-drawer-close:hover { color: #d4d4d4; }
.thoughts-drawer-body {
  overflow-y: auto;
  padding: 12px 20px;
}
.thoughts-drawer-foot {
  padding: 14px 20px;
  border-top: 1px solid #1f1f1f;
}

.th-drawer-thought {
  display: block;
  padding: 14px 0;
  border-bottom: 1px dashed #1f1f1f;
  cursor: pointer;
  color: #d4d4d4;
  transition: color 0.15s;
}
.th-drawer-thought:hover { color: #fff; }
.th-drawer-thought-title {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
}
.th-drawer-thought-meta {
  font-size: 11px;
  color: #6b6b6b;
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.th-drawer-thought-view {
  margin-top: 10px;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: #9a9a9a;
}
.th-drawer-thought:hover .th-drawer-thought-view { color: #fff; }
.th-drawer-empty {
  color: #4a4a4a;
  font-size: 12px;
  padding: 18px 0;
}

/* -------- ranked list -------- */
.thoughts-ranked-wrap {
  overflow-y: auto;
  padding: 22px clamp(16px, 4vw, 48px) 80px;
}
.thoughts-ranked-legend {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(4, 70px);
  gap: 16px;
  padding: 0 12px 8px;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: #6b6b6b;
}
.thoughts-ranked-legend .rank-axis { text-align: right; }
.thoughts-ranked-legend .rank-axis:first-child { text-align: left; visibility: hidden; }

.thoughts-ranked-list {
  list-style: none;
  margin: 0; padding: 0;
}
.th-rank-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(4, 70px);
  gap: 16px;
  align-items: center;
  padding: 14px 12px;
  border-bottom: 1px dashed #1a1a1a;
  cursor: pointer;
  transition: background 0.18s, transform 0.4s ease;
}
.th-rank-row:hover { background: #0e0e0e; }
.th-rank-rank {
  color: #6b6b6b;
  font-size: 11px;
  width: 30px;
  display: inline-block;
}
.th-rank-title-wrap { min-width: 0; }
.th-rank-title {
  font-size: 13px;
  color: #d4d4d4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.th-rank-branch {
  font-size: 10px;
  color: #6b6b6b;
  margin-top: 3px;
  letter-spacing: 0.04em;
}
.th-rank-bar {
  font-family: inherit;
  font-size: 11px;
  text-align: right;
  letter-spacing: 0;
  color: #d4d4d4;
  white-space: nowrap;
}
.rank-axis--leverage, .th-rank-bar.is-leverage { color: #d4d4d4; }
.rank-axis--conviction, .th-rank-bar.is-conviction { color: #b8b8b8; }
.rank-axis--friction, .th-rank-bar.is-friction { color: #8a8a8a; }
.rank-axis--composite, .th-rank-bar.is-composite { color: #fff; font-weight: 500; }

.thoughts-ranked-empty {
  color: #4a4a4a;
  font-size: 12px;
  padding: 60px 12px;
  text-align: center;
}

/* -------- modals (shared) -------- */
.th-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.78);
  display: grid;
  place-items: center;
  z-index: 1000;
  animation: th-fade-in 0.18s ease-out;
}
.th-modal[hidden] { display: none; }
/* Same fix for the drawer + canvas-hint which also rely on the hidden attr. */
.thoughts-drawer[hidden] { display: none; }
.thoughts-canvas-hint[hidden] { display: none; }
.thoughts-ranked-empty[hidden] { display: none; }
@keyframes th-fade-in { from { opacity: 0; } to { opacity: 1; } }
.th-modal-card {
  background: #0d0d0d;
  border: 1px solid #2a2a2a;
  padding: 28px 28px 22px;
  width: min(420px, 92vw);
  position: relative;
  z-index: 1001;
  animation: th-pop-in 0.22s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes th-pop-in {
  from { transform: scale(0.96); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
.th-modal-card--wide { width: min(640px, 96vw); }
.th-modal-close {
  position: absolute; top: 8px; right: 12px;
  background: transparent; border: none; color: #6b6b6b;
  font-size: 22px; cursor: pointer;
}
.th-modal-close:hover { color: #fff; }
.th-modal-title {
  font-size: 12px;
  letter-spacing: 0.06em;
  color: #6b6b6b;
  margin-bottom: 16px;
}
.th-form { display: flex; flex-direction: column; gap: 10px; }
.th-form-row { display: flex; align-items: center; gap: 12px; }
.th-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: #6b6b6b;
}
.th-input {
  font-family: inherit;
  font-size: 13px;
  background: #050505;
  color: #d4d4d4;
  border: 1px solid #2a2a2a;
  padding: 9px 11px;
  outline: none;
  transition: border-color 0.15s;
}
.th-input:focus { border-color: #d4d4d4; }
.th-textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
.th-btn {
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.05em;
  background: transparent;
  color: #d4d4d4;
  border: 1px solid #3a3a3a;
  padding: 9px 16px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.th-btn:hover { background: #161616; border-color: #d4d4d4; }
.th-btn:disabled { opacity: 0.4; cursor: wait; }
.th-btn--primary { border-color: #d4d4d4; color: #fff; }
.th-btn--primary:hover { background: #1a1a1a; }
.th-btn--ghost { color: #6b6b6b; border-color: #1f1f1f; }
.th-btn--ghost:hover { color: #b76060; border-color: #b76060; }

.th-msg {
  font-size: 11px;
  color: #6b6b6b;
  min-height: 14px;
  letter-spacing: 0.03em;
}
.th-msg.is-err { color: #b76060; }
.th-msg.is-ok  { color: #6bb76b; }

.th-record-status {
  font-size: 11px;
  color: #6b6b6b;
  letter-spacing: 0.03em;
}
.th-record-btn-active { color: #b76060; border-color: #b76060; }

/* detail */
.th-detail-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 70vh;
  overflow-y: auto;
  padding-right: 4px;
}
.th-detail-section { display: flex; flex-direction: column; gap: 6px; }
.th-detail-section-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: #6b6b6b;
}
.th-detail-section-body {
  font-size: 13px;
  color: #d4d4d4;
  line-height: 1.55;
  white-space: pre-wrap;
}
.th-detail-scores {
  display: grid;
  grid-template-columns: repeat(3, 1fr) auto;
  gap: 14px;
  padding: 10px 0;
  border-top: 1px solid #1f1f1f;
  border-bottom: 1px solid #1f1f1f;
}
.th-detail-score {
  display: flex; flex-direction: column; gap: 4px;
}
.th-detail-score-label { font-size: 10px; color: #6b6b6b; letter-spacing: 0.08em; }
.th-detail-score-val { font-size: 16px; color: #d4d4d4; }
.th-detail-score-bar {
  font-family: inherit;
  font-size: 11px;
  color: #6b6b6b;
  letter-spacing: 0;
}
.th-detail-score--composite .th-detail-score-val { color: #fff; font-weight: 500; font-size: 18px; }
.th-detail-rationale {
  font-size: 11px;
  color: #8a8a8a;
  font-style: italic;
}
.th-detail-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

@media (max-width: 640px) {
  .thoughts-shell {
    font-size: 12px;
  }

  .thoughts-topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "tabs record"
      "type type"
      "status status"
      "aux aux";
    align-items: stretch;
    gap: 8px;
    padding: 10px 14px 12px;
  }

  .thoughts-topbar-left {
    grid-area: tabs;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    min-width: 0;
  }

  .thoughts-tab {
    font-size: 11px;
  }

  .thoughts-topbar-right {
    display: contents;
  }

  .th-type-form {
    grid-area: type;
    min-width: 0;
    width: 100%;
  }

  .th-capture-status {
    grid-area: status;
    max-width: none;
    margin-right: 0;
    text-align: left;
    white-space: normal;
    overflow: visible;
  }

  .th-capture-btn,
  .th-capture-aux {
    min-height: 34px;
    padding: 7px 10px;
  }

  .th-capture-btn {
    grid-area: record;
    justify-content: center;
    min-width: 96px;
    align-self: center;
  }

  .th-capture-aux {
    grid-row: 4;
    min-width: 0;
  }
  #th-capture-pause { grid-column: 1; }
  #th-capture-restart { grid-column: 2; }

  .thoughts-drawer {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: min(46vh, 390px);
    border-left: 0;
    border-top: 1px solid #2a2a2a;
    box-shadow: 0 -22px 44px rgba(0,0,0,0.58);
    z-index: 20;
    animation: th-drawer-up 0.2s ease-out;
  }

  @keyframes th-drawer-up {
    from { transform: translateY(18px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }

  .thoughts-drawer-head {
    padding: 12px 14px;
  }

  .thoughts-drawer-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .thoughts-drawer-body {
    padding: 8px 14px 16px;
  }

  .th-drawer-thought {
    padding: 12px 0;
  }

  .th-drawer-thought-title {
    font-size: 13px;
  }

  .th-drawer-thought-meta {
    gap: 8px;
  }

  .thoughts-ranked-wrap {
    padding: 18px 12px 80px;
  }

  .thoughts-ranked-legend,
  .th-rank-row {
    grid-template-columns: minmax(0, 1fr) 56px 56px 56px 58px;
    gap: 8px;
  }

  .th-rank-bar {
    font-size: 10px;
  }

  .th-modal {
    place-items: end center;
    padding: 10px;
  }

  .th-modal-card,
  .th-modal-card--wide {
    width: 100%;
    max-height: calc(100vh - 20px);
    padding: 22px 16px 16px;
    overflow: hidden;
  }

  .th-detail-body {
    max-height: calc(100vh - 96px);
    gap: 12px;
  }

  .th-detail-scores {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
}
