/* =========================================================
   FOCUS READ — Redesigned CSS
   Font: Outfit (display) + Inter (body)
========================================================= */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700;900&family=Inter:wght@400;500;600&display=swap');

:root {
  --bg:         #f4f3ef;
  --surface:    #ffffff;
  --surface2:   #faf9f6;
  --border:     #e8e5de;
  --accent:     #2d6a4f;
  --accent2:    #40916c;
  --accent-lt:  #d8f3dc;
  --text:       #1a1a18;
  --text2:      #5a5a54;
  --text3:      #9a9a90;
  --red:        #c0392b;
  --red-lt:     #fdecea;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.07);
  --shadow:     0 4px 16px rgba(0,0,0,.09);
  --shadow-lg:  0 12px 40px rgba(0,0,0,.13);
  --radius:     12px;
  --radius-sm:  8px;
  --sidebar-w:  230px;
  --panel-w:    270px;
  --font-body:  'Inter', system-ui, sans-serif;
  --font-head:  'Outfit', system-ui, sans-serif;
  --transition: 0.18s ease;
}

/* DARK MODE TOKENS */
body.dark-mode {
  --bg:         #161614;
  --surface:    #1e1e1b;
  --surface2:   #252521;
  --border:     #2e2e2a;
  --accent:     #52b788;
  --accent2:    #74c69d;
  --accent-lt:  #1a3d2b;
  --text:       #eeede8;
  --text2:      #9b9b92;
  --text3:      #6a6a60;
  --red-lt:     #2e1a18;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.25);
  --shadow:     0 4px 16px rgba(0,0,0,.35);
  --shadow-lg:  0 12px 40px rgba(0,0,0,.5);
}

/* =========================================================
   RESET
========================================================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0; padding: 0;
}
html { height: 100%; }
body {
  height: 100%;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  transition: background var(--transition), color var(--transition);
  overflow: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: var(--font-body); cursor: pointer; }
input, select, textarea { font-family: var(--font-body); }

/* =========================================================
   LOGIN PAGE
========================================================= */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 64px;
  padding: 32px;
  background: var(--bg);
  background-image: radial-gradient(ellipse at 30% 20%, #d8f3dc55 0%, transparent 60%),
                    radial-gradient(ellipse at 70% 80%, #b7e4c755 0%, transparent 60%);
}

.login-card {
  width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.login-back-home {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text3);
  margin-bottom: -14px;
}

.login-back-home:hover {
  color: var(--accent);
  text-decoration: underline;
}

.login-brand {
  text-align: center;
}

.login-brand h1 {
  font-family: var(--font-head);
  font-size: 2rem;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -0.03em;
}

.login-brand p {
  color: var(--text2);
  font-size: 13px;
  margin-top: 4px;
}

.login-brand .logo-dot {
  display: inline-block;
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  margin-right: 2px;
  vertical-align: middle;
}

.login-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field-group input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text);
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.field-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-lt);
}

.btn-primary {
  width: 100%;
  padding: 13px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-head);
  letter-spacing: -0.01em;
  transition: background var(--transition), transform 0.1s;
}

.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.login-footer {
  text-align: center;
  font-size: 13px;
  color: var(--text2);
}

.login-footer a { color: var(--accent); font-weight: 600; }

.login-meta {
  border-top: 1px solid var(--border);
  padding-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.donate-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.donate-row p {
  font-size: 12px;
  color: var(--text2);
  flex: 1;
}

.donate-row .btn-donate {
  padding: 6px 12px;
  border: 1.5px solid var(--border);
  background: var(--surface2);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  transition: border-color var(--transition), background var(--transition);
}

.donate-row .btn-donate:hover {
  border-color: var(--accent);
  background: var(--accent-lt);
  color: var(--accent);
}

.trial-note {
  font-size: 12px;
  color: var(--text3);
  text-align: center;
  line-height: 1.5;
}

/* =========================================================
   AUTH (login / sign up / verify / forgot password)
========================================================= */
.auth-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px 0;
  color: var(--text2);
  font-size: 13px;
}

.auth-spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 18px;
}

.auth-tab {
  flex: 1;
  padding: 8px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 700;
  color: var(--text2);
  transition: background var(--transition), color var(--transition);
}

.auth-tab.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.auth-error {
  background: var(--red-lt);
  color: var(--red);
  border: 1px solid var(--red);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 12px;
  margin-bottom: 14px;
  line-height: 1.5;
}

.auth-notice {
  background: var(--accent-lt);
  color: var(--accent);
  border: 1px solid var(--accent2);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 12px;
  margin-bottom: 14px;
  line-height: 1.5;
}

.login-fields { margin-bottom: 16px; }

.btn-google {
  width: 100%;
  margin-top: 10px;
  padding: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  transition: border-color var(--transition), background var(--transition);
}

.btn-google:hover { border-color: var(--accent); background: var(--surface2); }

.auth-forgot {
  text-align: center;
  margin-top: 14px;
  font-size: 12px;
}

.auth-forgot a { color: var(--text2); font-weight: 600; }
.auth-forgot a:hover { color: var(--accent); }

.auth-subtitle {
  font-size: 13px;
  color: var(--text2);
  text-align: center;
  line-height: 1.6;
  margin-bottom: 16px;
}

.auth-hint {
  font-size: 12px;
  color: var(--text3);
  text-align: center;
  line-height: 1.5;
  margin-bottom: 16px;
}

.verify-icon {
  font-size: 40px;
  text-align: center;
  margin-bottom: 6px;
}

.auth-block-btn {
  width: 100%;
  margin-top: 10px;
  justify-content: center;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: var(--bg, var(--surface));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text2);
  font-size: 13px;
  font-weight: 600;
}

.auth-gate.hidden { display: none; }

/* =========================================================
   APP LAYOUT
========================================================= */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--panel-w);
  height: 100vh;
  overflow: hidden;
  transition: grid-template-columns var(--transition);
  position: relative;
}

/* Collapsed state: JS toggles these classes on <body>, which zero out
   the width variables the grid columns above are built from. */
body.sidebar-collapsed { --sidebar-w: 0px; }
body.panel-collapsed   { --panel-w: 0px; }

/* =========================================================
   EDGE TOGGLE BUTTONS (collapse/expand sidebar & tools panel)
========================================================= */
.edge-toggle-btn {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 52px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  z-index: 500;
  box-shadow: var(--shadow-sm);
  transition: left var(--transition), right var(--transition),
              border-color var(--transition), background var(--transition), color var(--transition);
}

.edge-toggle-btn:hover {
  border-color: var(--accent);
  background: var(--accent-lt);
  color: var(--accent);
}

#sidebarToggleBtn {
  left: var(--sidebar-w);
  margin-left: -1px;
  border-radius: 0 8px 8px 0;
  border-left: none;
}

#panelToggleBtn {
  right: var(--panel-w);
  margin-right: -1px;
  border-radius: 8px 0 0 8px;
  border-right: none;
}

/* =========================================================
   SIDEBAR
========================================================= */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  transition: background var(--transition);
}

.sidebar-header {
  padding: 16px 14px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.sidebar-brand {
  font-family: var(--font-head);
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  white-space: nowrap;
}

.brand-dot {
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  row-gap: 4px;
}

.sidebar-nav a {
  padding: 5px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}

.sidebar-nav a:hover {
  background: var(--surface2);
  color: var(--text);
  text-decoration: none;
}

.account-row {
  position: relative;
  flex-shrink: 0;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}

.account-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: background var(--transition), border-color var(--transition);
}

.account-btn:hover {
  background: var(--surface2);
  border-color: var(--accent);
}

.account-avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}

.account-btn-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
  flex: 1;
  min-width: 0;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-chevron {
  font-size: 10px;
  color: var(--text3);
  flex-shrink: 0;
}

.account-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 14px;
  right: 14px;
  z-index: 40;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md, var(--shadow-sm));
  padding: 4px;
  display: flex;
  flex-direction: column;
}

.account-menu-header {
  padding: 8px 10px 10px;
}

.account-menu-email {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-menu-plan {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.account-plan-badge {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-lt);
  padding: 2px 7px;
  border-radius: 999px;
}

.account-since {
  font-size: 10.5px;
  color: var(--text3);
}

.account-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 2px 6px 4px;
}

.account-menu button,
.account-menu a {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text2);
  text-align: left;
  transition: background var(--transition), color var(--transition);
}

.account-menu button:hover {
  background: var(--surface2);
  color: var(--text);
}

.account-menu a#deleteAccountLink {
  color: var(--red);
}

.account-menu a#deleteAccountLink:hover {
  background: var(--red-lt);
}

/* Small secondary links (Help / About / Privacy / Terms) tucked into the
   bottom of the account menu, out of the way of the main app UI. */
.account-menu-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 6px 10px 4px;
}

.account-menu-links a {
  padding: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
}

.account-menu-links a:hover {
  color: var(--accent);
  text-decoration: underline;
  background: none;
}

/* ---------- Empty-library onboarding hint ---------- */
.library-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 36px 14px;
  gap: 4px;
}

.library-empty-icon {
  font-size: 28px;
  margin-bottom: 8px;
  opacity: 0.7;
}

.library-empty-title {
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.library-empty-desc {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.5;
  margin-bottom: 16px;
  max-width: 190px;
}

.library-empty-cta {
  display: inline-block;
  width: auto;
  padding: 9px 16px;
  font-size: 12.5px;
  cursor: pointer;
}

/* Library section */
.library-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  padding: 12px 10px 10px;
}

.library-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.library-title {
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text3);
}

.library-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.category-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 6px;
  align-items: center;
}

#libraryCategory {
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
}

#libraryCategory:focus { border-color: var(--accent); }

#addCategoryBtn, #deleteCategoryBtn {
  width: 32px; height: 32px;
  border: 1.5px solid var(--border);
  background: var(--surface2);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  color: var(--text2);
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}

#addCategoryBtn:hover {
  border-color: var(--accent);
  background: var(--accent-lt);
  color: var(--accent);
}

#deleteCategoryBtn:hover {
  border-color: var(--red);
  background: var(--red-lt);
  color: var(--red);
}

.library-upload-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 12px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}

.library-upload-label:hover {
  border-color: var(--accent);
  background: var(--accent-lt);
  color: var(--accent);
}

.library-upload-label svg { flex-shrink: 0; }

#libraryPdfUpload { display: none; }

.upload-progress {
  display: flex;
  align-items: center;
  gap: 8px;
}

.upload-progress-track {
  flex: 1;
  height: 5px;
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.15s linear;
}

.upload-progress-text {
  font-size: 10px;
  font-weight: 700;
  color: var(--text3);
  white-space: nowrap;
  min-width: 42px;
  text-align: right;
}

.library-search {
  width: 100%;
  padding: 8px 10px 8px 32px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' viewBox='0 0 24 24' stroke='%239a9a90' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
}

.library-search:focus { border-color: var(--accent); }

/* Tag filter chips above the library list — clicking one narrows the list
   to documents carrying that tag; clicking it again clears the filter. */
.library-tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.library-tag-filter.is-hidden { display: none; }

.tag-chip {
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.tag-chip:hover { background: var(--accent-lt); color: var(--accent); }
.tag-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Small tag chips shown under a document's title/meta in the library list. */
.pdf-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.pdf-tag-chip {
  font-size: 10px;
  color: var(--text2);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
}

.library-list-scroll {
  flex: 1;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* Folders */
.folder {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  overflow: hidden;
  background: var(--surface);
}

.folder-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  cursor: pointer;
  user-select: none;
  background: var(--surface2);
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-head);
  color: var(--text2);
  gap: 6px;
}

.folder-header:hover { background: var(--accent-lt); color: var(--accent); }

.folder-header .count {
  font-size: 11px;
  background: var(--border);
  color: var(--text3);
  border-radius: 20px;
  padding: 1px 7px;
  margin-left: auto;
}

.folder-chevron {
  font-size: 10px;
  opacity: 0.6;
  transition: transform var(--transition);
}

.folder-icon { font-size: 12px; opacity: 0.85; }

.folder-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder.open .folder-chevron { transform: rotate(90deg); }

.folder-body {
  padding: 6px;
  display: none;
}

.folder.open .folder-body { display: block; }

/* PDF rows */
.pdf-row {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 4px;
  border: 1px solid transparent;
  transition: background var(--transition), border-color var(--transition);
}

.pdf-row:hover { background: var(--surface2); border-color: var(--border); }

.pdf-row.selected {
  background: var(--accent-lt);
  border-color: var(--accent2);
}

.pdf-left { min-width: 0; flex: 1; }

.pdf-row .title {
  font-weight: 600;
  font-size: 12px;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text);
}

.title-icon {
  margin-right: 5px;
  font-size: 11px;
  opacity: 0.8;
}

.pdf-row .meta {
  font-size: 10px;
  color: var(--text3);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pdf-actions {
  position: relative;
  flex-shrink: 0;
}

.pdf-menu-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 7px;
  font-size: 16px;
  color: var(--text3);
  line-height: 1;
  transition: border-color var(--transition), background var(--transition);
}

.pdf-menu-btn:hover {
  border-color: var(--border);
  background: var(--surface2);
  color: var(--text);
}

/* =========================================================
   MAIN CONTENT
========================================================= */
.main-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  gap: 0;
}

.pdf-reader {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin: 12px 12px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.pdf-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

#pdfTitle {
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.doc-search-toggle-btn {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--surface2);
  border-radius: var(--radius-sm);
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 13px;
  transition: background var(--transition), border-color var(--transition);
}
.doc-search-toggle-btn:hover,
.doc-search-toggle-btn.active {
  background: var(--accent-lt);
  border-color: var(--accent);
}

.doc-search-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface2);
}
.doc-search-bar .panel-input { width: auto; flex: 1; }

.doc-search-count {
  font-size: 11px;
  color: var(--text2);
  white-space: nowrap;
  min-width: 42px;
  text-align: center;
}

/* The temporary highlight put on the text-layer spans matched by a search,
   painted directly over the visible (canvas) text underneath. */
.textLayer span.search-hit {
  background: rgba(240, 140, 0, 0.35);
  border-radius: 2px;
}
.textLayer span.search-hit-active {
  background: rgba(224, 49, 49, 0.45);
}

/* =========================================================
   PDF DRAWING TOOLBAR (pen / highlighter / eraser)
========================================================= */
.draw-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.draw-tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.draw-tool-btn:hover { border-color: var(--accent); }

.draw-tool-btn.active {
  border-color: var(--accent);
  background: var(--accent-lt);
}

.draw-tool-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.draw-tool-btn:disabled:hover { border-color: var(--border); }

.draw-clear-btn {
  margin-left: auto;
}

.draw-sep {
  width: 1px;
  align-self: stretch;
  margin: 2px 2px;
  background: var(--border);
  flex-shrink: 0;
}

.draw-color-row {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 4px;
}

.draw-color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12);
}

.draw-color-swatch.active {
  border-color: var(--text);
}

.draw-color-row.is-hidden,
.draw-size-row.is-hidden {
  display: none;
}

.draw-size-row {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 4px;
}

.draw-size-btn {
  width: 26px;
  height: 26px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 700;
  color: var(--text2);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}

.draw-size-btn:hover { border-color: var(--accent); }

.draw-size-btn.active {
  border-color: var(--accent);
  background: var(--accent-lt);
  color: var(--accent);
}

.pdf-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--surface2);
  display: flex;
  flex-direction: row;
}

.pdf-pane {
  flex: 1 1 100%;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.pdf-pane-compare {
  border-left: 1px solid var(--border);
}

.pdf-pane-compare.hidden {
  display: none;
}

.pdf-area:has(.pdf-pane-compare:not(.hidden)) .pdf-pane-primary,
.pdf-area:has(.pdf-pane-compare:not(.hidden)) .pdf-pane-compare,
.pdf-area.compare-active .pdf-pane-primary,
.pdf-area.compare-active .pdf-pane-compare {
  flex: 1 1 50%;
}

.compare-pane-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.compare-pane-select {
  flex: 1;
  min-width: 0;
}

.zoom-control {
  display: flex;
  align-items: center;
  gap: 2px;
}

.zoom-level {
  font-size: 12px;
  color: var(--text2);
  min-width: 38px;
  text-align: center;
  user-select: none;
}

.compare-pane-scroll {
  flex: 1;
}

/* Canvas-based PDF viewer (via PDF.js) — replaces the old <embed>, which
   doesn't render on iOS/most mobile browsers. Pages are drawn as a
   vertical, scrollable stack of <canvas> elements. */
.pdf-canvas-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 16px 12px 40px;
  min-height: 100%;
}

.pdf-page-wrap {
  position: relative;
  max-width: 100%;
}

.pdf-page-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  border-radius: 2px;
}

/* Invisible text layer from PDF.js, aligned exactly over the canvas above
   it — this is what lets you click-and-drag to select and copy real text
   from a PDF, instead of it just being a picture you can't interact with. */
.textLayer {
  position: absolute;
  inset: 0;
  overflow: clip;
  opacity: 1;
  line-height: 1;
  text-align: initial;
  transform-origin: 0 0;
}

.textLayer span,
.textLayer br {
  color: transparent;
  position: absolute;
  white-space: pre;
  cursor: text;
  transform-origin: 0% 0%;
}

.textLayer ::selection {
  background: rgba(45, 106, 79, 0.35);
}

/* Freehand drawing/highlighting layer, on top of the text layer — see
   js/annotate.js. Transparent by default; pointer-events is toggled
   between "none" (so text selection underneath still works) and "auto"
   (while a pen/highlighter/eraser tool is active) directly in JS. */
.draw-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none; /* so a finger drag draws instead of scrolling */
}

.pdf-empty-state,
.pdf-error-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text3);
  font-size: 13px;
}

/* Word (.docx) viewer — mammoth.js converts the file to HTML client-side;
   this wraps it in a page-like card so it reads similarly to the PDF pages
   above, instead of looking like a raw unstyled web page. */
.docx-page {
  width: 100%;
  max-width: 780px;
  background: #fff;
  color: #1a1a1a;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  border-radius: 2px;
  padding: 48px 56px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  line-height: 1.65;
  overflow-wrap: break-word;
}

.docx-page img { max-width: 100%; height: auto; }
.docx-page table { border-collapse: collapse; max-width: 100%; }
.docx-page table td, .docx-page table th { border: 1px solid #ccc; padding: 4px 8px; }
.docx-page h1, .docx-page h2, .docx-page h3 { font-family: Georgia, "Times New Roman", serif; margin-top: 1em; }

@media (max-width: 520px) {
  .docx-page { padding: 24px 20px; }
}

.notes-section {
  position: relative; /* anchors the protruding edge tab cluster above */
  flex-shrink: 0;
  margin: 0 12px 12px;
  display: flex;
  flex-direction: column;
  height: 190px;
  overflow: visible;
  transition: height var(--transition, 0.2s ease);
}

/* The rounded card look lives on this inner wrapper, not on .notes-section
   itself, so the edge tab button can stick out above the top border
   without being clipped by overflow:hidden. */
.notes-section-inner {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* Clicking the expand button grows the panel from bottom to top so there's
   room to write notes or chat with the AI comfortably. */
.notes-section.expanded {
  height: 62vh;
}

/* Protruding cluster centered on the panel's top edge, styled to match the
   sidebar/tools-panel edge toggles (‹ ›) so it's just as easy to notice.
   Two SIDE-BY-SIDE buttons, each a one-way action (not a toggle): ▲ on the
   left always grows the panel, ▼ on the right always shrinks/closes it —
   so there's no single button that does opposite things depending on
   state, which people found confusing about the old stacked toggle. */
.notes-edge-tabs {
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  width: 64px;
  display: flex;
  flex-direction: row;
  border: 1.5px solid var(--border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  z-index: 5;
}

.notes-edge-tabs button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  height: 26px;
  border: none;
  background: transparent;
  color: var(--text2);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.notes-edge-tabs button:hover {
  background: var(--accent-lt);
  color: var(--accent);
}

.notes-edge-tabs button + button {
  border-left: 1px solid var(--border);
}

.expand-chevron,
.collapse-chevron {
  display: inline-block;
  font-size: 12px;
}

.notes-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px 8px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
}

.notes-header h2 {
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.bottom-tabs {
  display: flex;
  gap: 4px;
  min-width: 0;
  /* Three tabs (Notes / Chat / AI Assistant) can get tight on narrow
     panels — scroll horizontally instead of wrapping or overflowing. */
  overflow-x: auto;
  scrollbar-width: none;
}
.bottom-tabs::-webkit-scrollbar { display: none; }

.bottom-tab {
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted, var(--text));
  opacity: 0.6;
  cursor: pointer;
  transition: color var(--transition), opacity var(--transition), background var(--transition);
  white-space: nowrap;
}

.bottom-tab:hover { opacity: 0.9; }

.bottom-tab.active {
  color: var(--accent);
  opacity: 1;
  background: var(--surface-2, rgba(45, 106, 79, 0.08));
}

.notes-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.notes-section.collapsed .bottom-panel-body { display: none; }

/* Collapsed always wins over expanded, so there's never an empty
   expanded-height box with nothing visible inside it. */
.notes-section.collapsed,
.notes-section.collapsed.expanded {
  height: auto;
}

.bottom-panel-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.bottom-tab-panel {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.bottom-tab-panel.active {
  display: flex;
}

.notes-section textarea {
  width: 100%;
  flex: 1;
  padding: 10px 14px;
  resize: none;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
  outline: none;
  font-family: var(--font-body);
}

/* Nodes tab — NVivo-style coding: a toolbar to add a new named node, then a
   scrollable stack of node cards, each its own little textarea you paste
   excerpts into. */
#bottomPanelNodes {
  padding: 10px 14px 12px;
  overflow-y: auto;
  gap: 10px;
}

.nodes-toolbar {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.nodes-toolbar .panel-input { width: auto; flex: 1; }
.nodes-toolbar .secondary-btn { flex-shrink: 0; white-space: nowrap; }

.nodes-export-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.nodes-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.node-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}

.node-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

.node-title {
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.node-action-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  line-height: 1;
  opacity: 0.75;
  transition: background var(--transition), opacity var(--transition);
}
.node-action-btn:hover { background: var(--accent-lt); opacity: 1; }

.node-textarea {
  width: 100%;
  min-height: 110px;
  padding: 10px 12px;
  resize: vertical;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
  outline: none;
  font-family: var(--font-body);
}

/* AI tab reuses the existing chat-* classes from the right-panel chat/AI
   cards, so it only needs a little padding + scroll behavior here. */
#bottomPanelAi {
  padding: 10px 14px 12px;
  overflow-y: auto;
  gap: 8px;
}
#bottomPanelAi .chat-messages {
  flex: 1;
  min-height: 60px;
}

/* =========================================================
   RIGHT PANEL
========================================================= */
.right-panel {
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* Tool buttons row */
.tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 4px;
}

.tools button {
  padding: 9px 6px;
  border: 1.5px solid var(--border);
  background: var(--surface2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
  transition: border-color var(--transition), background var(--transition), color var(--transition), box-shadow var(--transition);
  font-family: var(--font-head);
}

.tools button:hover,
.tools button.active {
  border-color: var(--accent);
  background: var(--accent-lt);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* Generic panel card */
.panel-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  overflow: hidden;
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.panel-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.panel-card-title {
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}

.panel-close-btn {
  width: 24px; height: 24px;
  border: none;
  background: transparent;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  color: var(--text3);
  transition: background var(--transition), color var(--transition);
}

.panel-close-btn:hover {
  background: var(--red-lt);
  color: var(--red);
}

.panel-card-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Panel inputs */
.panel-input {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
}

.panel-input:focus { border-color: var(--accent); }

.panel-select {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
}

.panel-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.panel-btn-row {
  display: flex;
  gap: 6px;
}

.panel-btn {
  flex: 1;
  padding: 8px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
  font-family: var(--font-head);
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}

.panel-btn:hover {
  border-color: var(--accent);
  background: var(--accent-lt);
  color: var(--accent);
}

.panel-btn.accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.panel-btn.accent:hover { background: var(--accent2); border-color: var(--accent2); }

.panel-hint {
  font-size: 11px;
  color: var(--text3);
  line-height: 1.5;
}

/* =========================================================
   GOOGLE PANEL
========================================================= */
.translate-dir-btn {
  display: block;
  width: 100%;
  margin: 8px 0;
  padding: 7px 10px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--accent-lt);
  color: var(--accent);
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.translate-dir-btn:hover {
  border-color: var(--accent);
  background: var(--accent-lt);
}

.translate-result {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}

/* =========================================================
   MUSIC PANEL
========================================================= */
.music-vol-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.music-vol-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

/* =========================================================
   POMODORO PANEL
========================================================= */
.time-status {
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  text-align: center;
}

.time-left {
  font-family: var(--font-head);
  font-size: 32px;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: -0.02em;
  line-height: 1;
  margin: 4px 0;
}

.time-phase {
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.time-sets {
  font-size: 11px;
  color: var(--text3);
  margin-top: 4px;
}

.time-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* =========================================================
   CHAT PANEL
========================================================= */
.chat-doc-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text2);
}

#chatDocName {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--text);
}

.chat-prepare-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-status {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
}

.chat-messages {
  height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.chat-msg {
  font-size: 12px;
  line-height: 1.5;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-msg.user {
  background: var(--accent-lt);
  border: 1px solid var(--accent2);
  color: var(--text);
  align-self: flex-end;
  max-width: 90%;
}

.chat-msg.bot {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
}

.word-cloud {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 4px 12px;
  padding: 6px 4px;
  text-align: center;
}

.chat-input-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#chatQuestion {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  outline: none;
  resize: none;
  transition: border-color var(--transition);
}

#chatQuestion:focus { border-color: var(--accent); }

#chatSendBtn {
  align-self: flex-end;
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-head);
  transition: background var(--transition);
}

#chatSendBtn:hover { background: var(--accent2); }

/* =========================================================
   USAGE / PLAN SUMMARY CARD
========================================================= */
.usage-card {
  margin-top: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.usage-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.usage-card-title {
  font-family: var(--font-head);
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
}

.usage-card-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-lt);
  border-radius: 20px;
  padding: 2px 9px;
}

.usage-row { display: flex; flex-direction: column; gap: 5px; }

.usage-row-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text2);
  font-weight: 600;
}

.usage-bar {
  height: 6px;
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
}

.usage-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease, background var(--transition);
}

.usage-bar-fill.warn { background: #d97706; }
.usage-bar-fill.full { background: var(--red); }

.usage-hint {
  font-size: 10px;
  color: var(--text3);
  line-height: 1.4;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text2);
}
.stats-row span:last-child {
  font-weight: 700;
  color: var(--text);
}

/* =========================================================
   NIGHT/DAY SWITCH
========================================================= */
.mode-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  margin-top: auto;
  flex-shrink: 0;
}

.mode-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
}

.switch {
  position: relative;
  display: inline-block;
  width: 40px; height: 22px;
  flex-shrink: 0;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 22px;
  transition: background var(--transition);
  cursor: pointer;
}

.slider::before {
  position: absolute;
  content: "";
  height: 16px; width: 16px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: var(--shadow-sm);
}

.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* =========================================================
   SECONDARY BUTTONS
========================================================= */
.secondary-btn {
  padding: 6px 12px;
  border: 1.5px solid var(--border);
  background: var(--surface2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
  font-family: var(--font-head);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}

.secondary-btn:hover {
  border-color: var(--accent);
  background: var(--accent-lt);
  color: var(--accent);
}

/* =========================================================
   UTIL
========================================================= */
.hidden { display: none !important; }

/* Portal menu */
#fr-global-menu {
  background: var(--surface) !important;
  border: 1.5px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-lg) !important;
}

/* =========================================================
   ABOUT / HELP PAGES
========================================================= */
.info-page {
  font-family: var(--font-body);
  max-width: 820px;
  margin: 50px auto;
  padding: 0 20px;
  color: var(--text);
  line-height: 1.7;
}

.info-page h1 {
  font-family: var(--font-head);
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
  color: var(--text);
}

.info-page h2 {
  font-family: var(--font-head);
  font-size: 1.1rem;
  font-weight: 800;
  margin-top: 2em;
  margin-bottom: 0.5em;
  color: var(--text);
}

.info-page p { max-width: 700px; color: var(--text2); }

.info-page ul {
  padding-left: 20px;
  color: var(--text2);
}

.info-page li { margin-bottom: 6px; }

.info-page .note {
  background: var(--accent-lt);
  border-left: 4px solid var(--accent);
  padding: 12px 16px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 14px 0;
  font-size: 13px;
  color: var(--text);
}

.info-page .back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 32px;
  padding: 10px 18px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-weight: 600;
  font-size: 13px;
  transition: border-color var(--transition), color var(--transition);
}

.info-page .back-link:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

/* =========================================================
   RESPONSIVE — TABLET & MOBILE
   Below the breakpoint, the sidebar and tools panel stop taking a
   permanent grid column (which would otherwise squeeze the PDF down to
   nothing) and become slide-in overlays instead, triggered by the same
   edge-toggle buttons and body classes used on desktop.
========================================================= */
.mobile-backdrop {
  display: none;
}

@media (max-width: 880px) {
  .app-layout {
    grid-template-columns: 0px 1fr 0px;
  }

  /* Taking the sidebar/right-panel out of grid flow below (position: fixed)
     leaves main-content as the grid's only in-flow item, so auto-placement
     would otherwise drop it into column 1 (0px wide) instead of column 2. */
  .main-content {
    grid-column: 2;
  }

  .sidebar,
  .right-panel {
    position: fixed;
    top: 0;
    bottom: 0;
    width: min(84vw, 300px);
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    transition: transform var(--transition);
  }

  .sidebar {
    left: 0;
    transform: translateX(-100%);
  }

  .right-panel {
    right: 0;
    transform: translateX(100%);
  }

  body:not(.sidebar-collapsed) .sidebar { transform: translateX(0); }
  body:not(.panel-collapsed) .right-panel { transform: translateX(0); }

  /* Panels now overlay instead of pushing content, so the toggle tabs
     always sit at the true viewport edge rather than following --sidebar-w. */
  #sidebarToggleBtn { left: 0 !important; border-radius: 0 8px 8px 0; }
  #panelToggleBtn   { right: 0 !important; border-radius: 8px 0 0 8px; }

  /* Bigger touch targets */
  .edge-toggle-btn {
    width: 26px;
    height: 60px;
  }

  .mobile-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 900;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
  }

  body.sidebar-collapsed.panel-collapsed .mobile-backdrop {
    display: none;
  }

  body:not(.sidebar-collapsed) .mobile-backdrop,
  body:not(.panel-collapsed) .mobile-backdrop {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  .pdf-reader, .notes-section { margin-left: 8px; margin-right: 8px; }
  .tools { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 520px) {
  .sidebar, .right-panel { width: 88vw; }
  .pdf-reader, .notes-section { margin-left: 6px; margin-right: 6px; }
  .notes-section:not(.expanded) { height: 140px; }
  .login-card { width: 92vw; padding: 28px 22px; }
}

.legal-updated {
  font-size: 12px;
  color: var(--text3);
  margin-top: -8px;
}

.login-footer-links {
  text-align: center;
  margin-top: 14px;
}
.login-footer-links a {
  font-size: 11.5px;
  color: var(--text3);
}
.login-footer-links a:hover { color: var(--accent); }
.login-footer-links .sep { color: var(--text3); margin: 0 6px; }

/* ---------- Language switcher ---------- */
.lang-mount { display: flex; justify-content: flex-end; align-items: center; gap: 4px; flex-shrink: 0; }
.lang-switch {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 6px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  appearance: auto;
  max-width: 92px;
}
.lang-switch:hover { border-color: var(--accent); }
.lang-switch option { background: var(--bg); color: var(--text); }
.login-page .lang-mount { justify-content: center; margin-bottom: 14px; }
.login-page .lang-switch { font-size: 12.5px; padding: 5px 10px; max-width: none; }
.info-page .lang-mount { justify-content: flex-end; margin-bottom: 10px; }
.sidebar-header .lang-mount { margin-top: 0; }

/* =========================================================
   LANDING PAGE (index.html — marketing homepage)
========================================================= */
.landing-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.landing-nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 32px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.landing-brand {
  font-family: var(--font-head);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
}
.landing-brand:hover { text-decoration: none; color: var(--text); }

.landing-nav-links {
  display: flex;
  gap: 24px;
  margin-right: auto;
}

.landing-nav-links a {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text2);
}
.landing-nav-links a:hover { color: var(--accent); text-decoration: none; }

.landing-nav-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.landing-login-link {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text2);
  white-space: nowrap;
}
.landing-login-link:hover { color: var(--accent); text-decoration: none; }

.landing-nav-cta {
  width: auto;
  padding: 9px 18px;
  font-size: 13.5px;
  white-space: nowrap;
}
.landing-nav-cta:hover { text-decoration: none; }

/* ---------- Hero ---------- */
.landing-hero {
  background: var(--bg);
  background-image: radial-gradient(ellipse at 20% 10%, #d8f3dc55 0%, transparent 55%);
  padding: 80px 32px;
}

.landing-hero-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 56px;
}

.landing-hero-text {
  flex: 0 0 43%;
  max-width: 43%;
}

.landing-eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 14px;
}

.landing-hero-text h1 {
  font-family: var(--font-head);
  font-size: 2.5rem;
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 18px;
}

.landing-hero-desc {
  color: var(--text2);
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 28px;
}

.landing-hero-cta-row { margin-bottom: 14px; }

.landing-hero-btn {
  width: auto;
  display: inline-block;
  padding: 13px 26px;
}
.landing-hero-btn:hover { text-decoration: none; }

.landing-hero-note {
  font-size: 12.5px;
  color: var(--text3);
}

.landing-hero-media {
  flex: 1;
  display: flex;
  justify-content: center;
}

.landing-hero-img-btn {
  position: relative;
  display: block;
  width: 100%;
  max-width: 620px;
  padding: 0;
  border: none;
  background: none;
  cursor: zoom-in;
  transition: transform 0.15s ease;
}

.landing-hero-img-btn:hover { transform: translateY(-2px); }

.landing-hero-img-btn:hover .landing-hero-zoom-hint { opacity: 1; }

.landing-hero-zoom-hint {
  position: absolute;
  bottom: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  background: rgba(20, 24, 22, 0.72);
  color: #fff;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.landing-hero-media img {
  width: 100%;
  max-width: 620px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: block;
}

/* ---------- Generic section scaffolding ---------- */
.landing-section {
  padding: 90px 32px;
}

.landing-section-alt {
  background: var(--surface2);
}

.landing-section-inner {
  max-width: 1200px;
  margin: 0 auto;
}

.landing-section-inner h2 {
  font-family: var(--font-head);
  font-size: 1.9rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--text);
  max-width: 720px;
  margin-bottom: 14px;
}

.landing-section-desc {
  color: var(--text2);
  font-size: 14.5px;
  max-width: 640px;
  margin-bottom: 44px;
  line-height: 1.6;
}

.landing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 24px;
}

.landing-card h3 {
  font-family: var(--font-head);
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.landing-card p {
  color: var(--text2);
  font-size: 13.5px;
  line-height: 1.6;
}

/* ---------- 3-step "how it works" ---------- */
.landing-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

/* ---------- Two-tool explainer ---------- */
.landing-dual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.landing-card-lg { padding: 32px 28px; }
.landing-card-lg h3 { font-size: 1.15rem; margin-bottom: 12px; }
.landing-card-lg p { font-size: 14px; }

/* ---------- Features grid ---------- */
.landing-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

/* ---------- Who it's for ---------- */
.landing-who-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 720px;
}

.landing-who-list li {
  color: var(--text2);
  font-size: 14.5px;
  line-height: 1.6;
  padding-left: 20px;
  position: relative;
}

.landing-who-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* ---------- Privacy / trust band ---------- */
.landing-trust-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 28px;
}

.landing-trust-list li {
  color: var(--text2);
  font-size: 13.5px;
  line-height: 1.6;
  padding-left: 22px;
  position: relative;
}

.landing-trust-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--accent);
  font-weight: 700;
}

.landing-privacy-link {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--accent);
}

/* ---------- Final CTA band ---------- */
.landing-final {
  background: var(--accent);
  padding: 80px 32px;
}

.landing-final-inner {
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
}

.landing-final-inner h2 {
  font-family: var(--font-head);
  font-size: 1.9rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: #fff;
  margin-bottom: 14px;
}

.landing-final-inner p {
  color: #eafaf1;
  font-size: 14.5px;
  margin-bottom: 26px;
}

.landing-final-btn {
  display: inline-block;
  background: #fff;
  color: var(--accent);
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 15px;
  padding: 13px 28px;
  border-radius: var(--radius-sm);
  transition: transform 0.1s;
}
.landing-final-btn:hover { text-decoration: none; transform: translateY(-1px); }

.landing-final-note {
  margin-top: 16px !important;
  font-size: 12.5px;
  color: #d8f3dc !important;
}

/* ---------- Footer ---------- */
.landing-footer {
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 40px 32px;
}

.landing-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.landing-footer-logo {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 14px;
  color: var(--text);
  display: flex;
  align-items: center;
  margin-bottom: 4px;
}

.landing-footer-brand p:last-child {
  font-size: 12.5px;
  color: var(--text3);
}

.landing-footer-links {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.landing-footer-links a {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
}
.landing-footer-links a:hover { color: var(--accent); }

.landing-nav .lang-mount,
.landing-nav-actions .lang-mount { justify-content: flex-end; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .landing-hero-inner { flex-direction: column; }
  .landing-hero-text { flex: none; max-width: 100%; text-align: center; }
  .landing-hero-cta-row { display: flex; justify-content: center; }
  .landing-steps, .landing-dual, .landing-features {
    grid-template-columns: 1fr;
  }
  .landing-nav-links { display: none; }
}

@media (max-width: 560px) {
  .landing-nav-inner { padding: 14px 18px; }
  .landing-hero { padding: 56px 18px; }
  .landing-hero-text h1 { font-size: 1.9rem; }
  .landing-section { padding: 60px 18px; }
  .landing-final { padding: 56px 18px; }
  .landing-footer { padding: 32px 18px; }
  .landing-footer-inner { flex-direction: column; align-items: flex-start; }
  .landing-nav-actions { gap: 12px; }
  .landing-login-link { display: none; }
}

/* ---------- Hero screenshot lightbox ---------- */
body.lightbox-open { overflow: hidden !important; }

.hero-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10, 12, 11, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  cursor: zoom-out;
}

.hero-lightbox.hidden { display: none; }

.hero-lightbox img {
  max-width: 95vw;
  max-height: 90vh;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  cursor: default;
}

.hero-lightbox-close {
  position: fixed;
  top: 20px;
  right: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.hero-lightbox-close:hover { background: rgba(255, 255, 255, 0.25); }

@media (max-width: 560px) {
  .hero-lightbox { padding: 16px; }
  .hero-lightbox-close { top: 12px; right: 12px; }
}
