/* ═══════════════════════════════════════════════════════════════════════════
   HARBINGER — Terminal Journal
   ═══════════════════════════════════════════════════════════════════════════ */

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Courier New', Courier, monospace;
  background: #0d0d0d;
  color: #c8c4b8;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ─── App Shell ──────────────────────────────────────────────────────────── */

.harbinger {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */

.masthead-bar {
  flex-shrink: 0;
  background: #000;
  color: #fff;
  height: 50px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #222;
  gap: 16px;
  z-index: 10;
}

.title-mark {
  font-size: 18px;
  letter-spacing: 8px;
  font-weight: bold;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-tabs {
  display: flex;
  align-items: stretch;
  height: 100%;
}

.tab {
  display: flex;
  align-items: center;
  background: transparent;
  color: #aaa;
  border: none;
  border-left: 1px solid #2a2a2a;
  padding: 0 18px;
  font-family: 'Courier New', monospace;
  font-size: 10px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  text-transform: uppercase;
}

.tab:hover {
  background: #1a1a1a;
  color: #fff;
}

.tab.active {
  background: #fff;
  color: #000;
}

.tab.logout {
  color: #888;
  margin-left: 12px;
  border-left: 1px solid #2a2a2a;
}

.tab.logout:hover {
  color: #fff;
  background: #1a1a1a;
}

.tab.admin-btn {
  color: #888;
  letter-spacing: 1px;
}

.tab.admin-btn:hover {
  color: #fff;
  background: #1a1a1a;
}

/* ─── Workspace ──────────────────────────────────────────────────────────── */

.workspace {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.view-wrapper {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.loading-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  letter-spacing: 5px;
  color: #333;
}

/* ─── Archive: Full-list view (no entry selected) ────────────────────────── */

.archive-full-view {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  justify-content: center;
  background: #0d0d0d;
}

.archive-full-view .archive-list-pane {
  width: 100%;
  max-width: 760px;
  border-right: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ─── Archive: Split view (entry selected) ───────────────────────────────── */

.archive-split-view {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: row;
  background: #0d0d0d;
}

.archive-split-view .archive-list-pane {
  width: 300px;
  flex-shrink: 0;
  border-right: 1px solid #1e1e1e;
  background: #0a0a0a;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ─── Archive List Pane ──────────────────────────────────────────────────── */

.archive-list-header {
  flex-shrink: 0;
  padding: 14px 20px;
  border-bottom: 1px solid #1e1e1e;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.archive-list-header h2 {
  font-size: 10px;
  letter-spacing: 4px;
  color: #444;
  font-weight: normal;
}

.record-count {
  font-size: 9px;
  letter-spacing: 2px;
  color: #333;
}

.archive-list-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.archive-list-scroll::-webkit-scrollbar { width: 3px; }
.archive-list-scroll::-webkit-scrollbar-track { background: transparent; }
.archive-list-scroll::-webkit-scrollbar-thumb { background: #222; }

/* ─── Archive List Items ─────────────────────────────────────────────────── */

.archive-list-item {
  padding: 14px 20px;
  border-bottom: 1px solid #141414;
  cursor: pointer;
  transition: background 0.1s;
}

.archive-list-item:hover {
  background: #131313;
}

.archive-list-item.selected {
  background: #161616;
  border-left: 2px solid #fff;
  padding-left: 18px;
}

.item-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 5px;
}

.item-title {
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 1px;
  color: #c8c4b8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.item-date {
  font-size: 9px;
  letter-spacing: 1px;
  color: #3a3a3a;
  white-space: nowrap;
  flex-shrink: 0;
}

.item-preview {
  font-size: 10px;
  line-height: 1.4;
  color: #444;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Empty State ────────────────────────────────────────────────────────── */

.empty-archive {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 60px 20px;
}

.empty-archive-label {
  font-size: 11px;
  letter-spacing: 4px;
  color: #2e2e2e;
}

/* ─── Reading Pane ───────────────────────────────────────────────────────── */

.reading-pane {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 48px 64px;
  background: #f4f1e8;
  color: #1a1a1a;
  display: flex;
  flex-direction: column;
}

.reading-pane::-webkit-scrollbar { width: 5px; }
.reading-pane::-webkit-scrollbar-track { background: #ece9de; }
.reading-pane::-webkit-scrollbar-thumb { background: #bbb; }

.reading-header {
  flex-shrink: 0;
  margin-bottom: 28px;
}

.reading-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.reading-title {
  font-size: 20px;
  letter-spacing: 3px;
  line-height: 1.3;
  flex: 1;
  min-width: 0;
  word-break: break-word;
  color: #000;
}

.close-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  background: transparent;
  border: 1px solid #bbb;
  color: #888;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'Courier New', monospace;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-btn:hover {
  background: #000;
  border-color: #000;
  color: #fff;
}

.reading-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.reading-date {
  font-size: 10px;
  letter-spacing: 2px;
  color: #888;
}

.delete-btn {
  background: transparent;
  border: 1px solid #ccc;
  color: #aaa;
  padding: 4px 12px;
  font-family: 'Courier New', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.15s;
}

.delete-btn:hover {
  background: #b00;
  border-color: #b00;
  color: #fff;
}

.reading-divider {
  height: 1px;
  background: #ddd;
  margin: 0 0 28px;
  flex-shrink: 0;
}

.reading-content {
  font-size: 14px;
  line-height: 1.95;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: #222;
  flex: 1;
}

/* ─── Editor View ────────────────────────────────────────────────────────── */

.editor-sheet {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: #f4f1e8;
  color: #1a1a1a;
  padding: 48px 64px 64px;
  display: flex;
  flex-direction: column;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}

.editor-sheet::-webkit-scrollbar { width: 5px; }
.editor-sheet::-webkit-scrollbar-thumb { background: #bbb; }

.sheet-header {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid #d8d5cc;
  padding-bottom: 12px;
  margin-bottom: 28px;
}

.date-stamp {
  font-size: 10px;
  letter-spacing: 3px;
  color: #999;
}

.typewriter-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.headline-input {
  background: transparent;
  border: none;
  border-bottom: 2px solid #000;
  padding: 10px 0;
  font-family: 'Courier New', monospace;
  font-size: 20px;
  font-weight: bold;
  letter-spacing: 1px;
  text-transform: uppercase;
  outline: none;
  width: 100%;
  color: #000;
  margin-bottom: 8px;
}

.headline-input::placeholder { color: #ccc; font-weight: normal; }

.body-text {
  flex: 1;
  background: transparent;
  border: none;
  padding: 20px 0;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.9;
  resize: none;
  outline: none;
  min-height: 280px;
  color: #1a1a1a;
  width: 100%;
}

.body-text::placeholder { color: #bbb; }

.editor-footer {
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  padding-top: 16px;
  border-top: 1px solid #ddd;
  margin-top: 8px;
}

.publish-btn {
  background: #000;
  color: #f4f1e8;
  border: 2px solid #000;
  padding: 10px 32px;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.15s;
}

.publish-btn:hover {
  background: transparent;
  color: #000;
}

/* ─── Admin Login Overlay ────────────────────────────────────────────────── */

.admin-panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 20px;
}

.admin-panel {
  position: relative;
  background: #f4f1e8;
  color: #000;
  padding: 44px 40px 40px;
  border: 1px solid #000;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 0 80px rgba(0, 0, 0, 0.8);
}

.admin-panel .close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #bbb;
  width: auto;
  height: auto;
}

.admin-panel .close-btn:hover {
  background: none;
  border: none;
  color: #000;
}

/* ─── Login Form ─────────────────────────────────────────────────────────── */

.typewriter-login { width: 100%; }

.login-heading {
  font-size: 14px;
  letter-spacing: 5px;
  margin-bottom: 4px;
  color: #000;
}

.login-subhead {
  font-size: 9px;
  letter-spacing: 3px;
  color: #999;
  margin-bottom: 24px;
  text-transform: uppercase;
}

.login-rule {
  border: none;
  border-top: 1px solid #ccc;
  margin-bottom: 24px;
}

.credentials {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.typewriter-input {
  background: transparent;
  border: none;
  border-bottom: 1px solid #bbb;
  padding: 8px 0;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  letter-spacing: 2px;
  outline: none;
  width: 100%;
  color: #000;
  transition: border-color 0.2s;
}

.typewriter-input::placeholder {
  color: #bbb;
  font-size: 10px;
  letter-spacing: 3px;
}

.typewriter-input:focus { border-bottom-color: #000; }

.button-row {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.typewriter-btn {
  flex: 1;
  background: #000;
  color: #f4f1e8;
  border: 1px solid #000;
  padding: 11px;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  letter-spacing: 3px;
  cursor: pointer;
  transition: all 0.15s;
}

.typewriter-btn:hover {
  background: transparent;
  color: #000;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .masthead-bar {
    padding: 0 14px;
    height: 46px;
  }

  .title-mark {
    font-size: 14px;
    letter-spacing: 4px;
  }

  .tab {
    padding: 0 10px;
    font-size: 9px;
    letter-spacing: 1px;
  }

  /* Stack archive panes vertically on mobile */
  .archive-split-view {
    flex-direction: column;
  }

  .archive-split-view .archive-list-pane {
    width: 100%;
    flex-shrink: 0;
    border-right: none;
    border-bottom: 1px solid #1e1e1e;
    max-height: 38vh;
  }

  .reading-pane {
    padding: 24px 20px 40px;
  }

  .reading-title { font-size: 16px; letter-spacing: 2px; }

  .editor-sheet {
    padding: 24px 20px 48px;
    max-width: 100%;
  }

  .headline-input { font-size: 16px; }

  .admin-panel {
    padding: 36px 24px 28px;
  }
}

@media (min-width: 641px) and (max-width: 900px) {
  .archive-split-view .archive-list-pane {
    width: 240px;
  }

  .reading-pane {
    padding: 36px 40px;
  }

  .editor-sheet {
    padding: 36px 48px 56px;
  }
}
