/* ── 80-HD: Interstitial Journal ─────────────────────────────────────────── */

.hd-wrap {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 48px);
  background: #000900;
  color: var(--color-terminal-green);
  overflow: hidden;
}

/* ── Toolbar ────────────────────────────────────────────────────────────── */

.hd-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid rgba(51, 255, 51, 0.25);
  flex-shrink: 0;
  gap: 12px;
  flex-wrap: wrap;
}

.hd-toolbar-left {
  display: flex;
  align-items: baseline;
  gap: 2px;
}

.hd-title {
  font-family: var(--font-primary);
  font-size: 1.15rem;
  letter-spacing: 3px;
  color: var(--color-terminal-green);
}

.hd-blink {
  font-family: var(--font-primary);
  font-size: 1.15rem;
  color: var(--color-terminal-green);
  animation: hd-blink 1s step-end infinite;
}

@keyframes hd-blink {
  50% { opacity: 0; }
}

.hd-toolbar-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.hd-btn {
  background: transparent;
  border: 1px solid rgba(51, 255, 51, 0.5);
  color: var(--color-terminal-green);
  font-family: var(--font-primary);
  font-size: 0.95rem;
  padding: 5px 14px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: background 80ms, color 80ms, border-color 80ms;
  line-height: 1.4;
}

.hd-btn:hover,
.hd-btn:focus-visible {
  background: var(--color-terminal-green);
  color: #000900;
  border-color: var(--color-terminal-green);
  outline: none;
}

.hd-btn--now {
  border-color: var(--color-terminal-green);
  background: rgba(51, 255, 51, 0.08);
  font-weight: bold;
  letter-spacing: 2px;
}

.hd-btn--import {
  border-style: dashed;
  opacity: 0.7;
}

.hd-btn--import:hover,
.hd-btn--import:focus-visible {
  opacity: 1;
  border-style: solid;
}

/* Import feedback toast */
.hd-import-feedback {
  font-family: var(--font-primary);
  font-size: 0.78rem;
  color: var(--color-terminal-green);
  opacity: 0.65;
  padding: 0 4px;
  white-space: nowrap;
  animation: hd-fade 0.25s ease;
}

@keyframes hd-fade {
  from { opacity: 0; }
  to   { opacity: 0.65; }
}

/* ── Not-signed-in notice ───────────────────────────────────────────────── */

.hd-notice {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 20px;
  background: rgba(51, 255, 51, 0.04);
  border-bottom: 1px solid rgba(51, 255, 51, 0.1);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.hd-notice-text {
  font-family: var(--font-primary);
  font-size: 0.8rem;
  opacity: 0.55;
  letter-spacing: 1px;
}

.hd-export-btn {
  background: transparent;
  border: 1px solid rgba(51, 255, 51, 0.4);
  color: var(--color-terminal-green);
  font-family: var(--font-primary);
  font-size: 0.8rem;
  padding: 2px 10px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: background 80ms, color 80ms;
}

.hd-export-btn:hover {
  background: var(--color-terminal-green);
  color: #000;
}

/* ── Notes list ─────────────────────────────────────────────────────────── */

.hd-notes {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.hd-notes::-webkit-scrollbar {
  width: 5px;
}

.hd-notes::-webkit-scrollbar-track {
  background: #000900;
}

.hd-notes::-webkit-scrollbar-thumb {
  background: rgba(51, 255, 51, 0.2);
  border-radius: 2px;
}

/* ── Individual note row ────────────────────────────────────────────────── */

.hd-note-row {
  display: grid;
  grid-template-columns: 132px 1fr;
  border-bottom: 1px solid rgba(51, 255, 51, 0.08);
  min-height: 44px;
  transition: background 80ms;
}

.hd-note-row:hover {
  background: rgba(51, 255, 51, 0.025);
}

.hd-note-row--active {
  background: rgba(51, 255, 51, 0.04);
  border-bottom: 1px solid rgba(51, 255, 51, 0.25);
}

.hd-note-row--active:hover {
  background: rgba(51, 255, 51, 0.04);
}

/* ── Timestamp column ───────────────────────────────────────────────────── */

.hd-note-ts {
  padding: 10px 12px 10px 20px;
  font-family: 'Courier New', 'Courier Prime', monospace;
  font-size: 0.72rem;
  color: rgba(51, 255, 51, 0.5);
  white-space: pre;
  border-right: 1px solid rgba(51, 255, 51, 0.15);
  line-height: 1.55;
  flex-shrink: 0;
  user-select: none;
}

/* ── Content column ─────────────────────────────────────────────────────── */

.hd-note-content {
  padding: 10px 20px 10px 18px;
  display: flex;
  align-items: flex-start;
  min-width: 0;
}

.hd-note-text {
  font-family: var(--font-system);
  font-size: 0.95rem;
  color: var(--color-terminal-green);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
  width: 100%;
}

/* ── Active textarea ────────────────────────────────────────────────────── */

.hd-note-textarea {
  width: 100%;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--color-terminal-green);
  font-family: var(--font-system);
  font-size: 0.95rem;
  line-height: 1.6;
  resize: none;
  min-height: 1.6em;
  caret-color: var(--color-terminal-green);
  padding: 0;
  margin: 0;
}

.hd-note-textarea::placeholder {
  color: rgba(51, 255, 51, 0.25);
}

/* ── Empty state ────────────────────────────────────────────────────────── */

.hd-empty {
  padding: 48px 20px;
  opacity: 0.35;
  font-family: var(--font-primary);
  font-size: 0.9rem;
  text-align: center;
  letter-spacing: 1px;
}

/* ── Mobile ─────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .hd-note-row {
    grid-template-columns: 110px 1fr;
  }

  .hd-note-ts {
    padding: 8px 8px 8px 12px;
    font-size: 0.65rem;
  }

  .hd-note-content {
    padding: 8px 12px;
  }

  .hd-toolbar {
    padding: 8px 12px;
  }

  .hd-btn {
    font-size: 0.82rem;
    padding: 4px 10px;
  }
}

/* ── Summary Modal ──────────────────────────────────────────────────────── */

.hd-sum-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 9, 0, 0.82);
  z-index: 9000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px 20px;
  overflow-y: auto;
  backdrop-filter: blur(2px);
}

.hd-sum-modal {
  width: 100%;
  max-width: 760px;
  background: #000e00;
  border: 1px solid rgba(51, 255, 51, 0.35);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 80px);
  box-shadow: 0 0 40px rgba(51, 255, 51, 0.08);
}

/* ── Modal header ───────────────────────────────────────────────────────── */

.hd-sum-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(51, 255, 51, 0.25);
  flex-shrink: 0;
  gap: 12px;
  flex-wrap: wrap;
}

.hd-sum-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hd-sum-title {
  font-family: var(--font-primary);
  font-size: 1rem;
  color: var(--color-terminal-green);
  letter-spacing: 2px;
}

.hd-sum-range {
  font-family: var(--font-primary);
  font-size: 0.72rem;
  color: rgba(51, 255, 51, 0.45);
  letter-spacing: 1px;
}

.hd-sum-close,
.hd-sum-copy {
  background: transparent;
  border: 1px solid rgba(51, 255, 51, 0.4);
  color: var(--color-terminal-green);
  font-family: var(--font-primary);
  font-size: 0.85rem;
  padding: 4px 12px;
  cursor: pointer;
  letter-spacing: 1px;
  white-space: nowrap;
  transition: background 80ms, color 80ms;
}

.hd-sum-close:hover,
.hd-sum-copy:hover {
  background: var(--color-terminal-green);
  color: #000900;
}

/* ── Modal body ─────────────────────────────────────────────────────────── */

.hd-sum-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  min-height: 120px;
}

.hd-sum-body::-webkit-scrollbar { width: 5px; }
.hd-sum-body::-webkit-scrollbar-track { background: #000e00; }
.hd-sum-body::-webkit-scrollbar-thumb { background: rgba(51, 255, 51, 0.2); }

/* Streaming plain-text output */
.hd-sum-stream {
  font-family: var(--font-primary);
  font-size: 0.88rem;
  color: rgba(51, 255, 51, 0.85);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.65;
  margin: 0;
}

/* Cursor animation while waiting */
.hd-sum-cursor {
  font-family: var(--font-primary);
  color: var(--color-terminal-green);
  animation: hd-blink 0.8s step-end infinite;
}

/* ── Rendered markdown ──────────────────────────────────────────────────── */

.hd-sum-rendered {
  font-family: var(--font-system);
  font-size: 0.95rem;
  color: rgba(51, 255, 51, 0.9);
  line-height: 1.7;
}

.hd-sum-rendered h1,
.hd-sum-rendered h2,
.hd-sum-rendered h3 {
  font-family: var(--font-primary);
  color: var(--color-terminal-green);
  margin: 1.4em 0 0.5em;
  font-weight: normal;
  letter-spacing: 1px;
}

.hd-sum-rendered h1 { font-size: 1.1rem; border-bottom: 1px solid rgba(51,255,51,0.2); padding-bottom: 4px; }
.hd-sum-rendered h2 { font-size: 1rem; }
.hd-sum-rendered h3 { font-size: 0.9rem; opacity: 0.8; }

.hd-sum-rendered h1:first-child,
.hd-sum-rendered h2:first-child,
.hd-sum-rendered h3:first-child { margin-top: 0; }

.hd-sum-rendered p {
  margin: 0.6em 0;
}

.hd-sum-rendered ul {
  margin: 0.4em 0 0.6em 1.2em;
  padding: 0;
  list-style: none;
}

.hd-sum-rendered ul li::before {
  content: '\2014\00a0';
  color: rgba(51, 255, 51, 0.4);
}

.hd-sum-rendered ul ul {
  margin-left: 1.2em;
  margin-top: 0.2em;
}

.hd-sum-rendered ul ul li::before {
  content: '\00b7\00a0\00a0';
  color: rgba(51, 255, 51, 0.3);
}

.hd-sum-rendered li {
  display: flex;
  margin: 0.25em 0;
  line-height: 1.55;
}

.hd-sum-rendered strong {
  color: var(--color-terminal-green);
  font-weight: 600;
}

.hd-sum-rendered em {
  font-style: italic;
  opacity: 0.8;
}

.hd-sum-rendered hr {
  border: none;
  border-top: 1px solid rgba(51, 255, 51, 0.15);
  margin: 1.2em 0;
}

.hd-sum-rendered code {
  font-family: 'Courier New', monospace;
  font-size: 0.88em;
  background: rgba(51, 255, 51, 0.07);
  padding: 1px 5px;
  border-radius: 2px;
}

/* Login prompt link */
.hd-sum-login-link {
  color: var(--color-terminal-green);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.hd-sum-login-link:hover {
  opacity: 0.7;
}

/* Error state */
.hd-sum-error {
  font-family: var(--font-primary);
  font-size: 0.9rem;
  color: rgba(51, 255, 51, 0.6);
  opacity: 0.7;
  padding: 12px 0;
}

/* ── Mobile summary adjustments ─────────────────────────────────────────── */

@media (max-width: 540px) {
  .hd-sum-overlay {
    padding: 16px 8px;
    align-items: flex-start;
  }

  .hd-sum-modal {
    max-height: calc(100vh - 32px);
  }

  .hd-sum-body {
    padding: 16px;
  }

  .hd-sum-header {
    padding: 10px 14px;
  }
}
