/* C-MD Desktop — matches mobile's dark palette (#1a2535 / #223347 / #2e86c1) */

/* ── Theme variables ───────────────────────────────────────────────────
   Single, fixed dark (blue) palette — the app's default and only look. */
:root {
  --bg-page: #1a2535;
  --bg-card: #223347;
  --bg-card-alt: #26405a;
  --bg-topbar: #0f1e2e;
  --bg-hover: #16283c;
  --bg-tabs: #1e2f42;
  --bg-input: #1a2535;

  --border: #2b3e52;
  --border-strong: #2e5170;

  --text-heading: #fff;
  --text-body: #d8eaf6;
  --text-muted: #8daab8;
  --text-faint: #a9c2d4;
  --text-accent-light: #7fc4f0;
  --text-faint2: #c5daea;

  --accent: #2e86c1;
  --accent-hover: #3a9bd8;
  --accent-hover2: #3a7ab0;

  --bg-error: #3a1f1a;
  --text-error: #e88a7e;
  --text-error-strong: #e74c3c;
  --bg-success: #1f3a2a;
  --text-success: #7ee8a2;
  --text-success-strong: #5fc98a;
  --bg-danger-btn: #8e3b30;
  --bg-logout-btn: #2b1f1c;

  --scrollbar-border: #1a2535;

  --setup-bg: #131c28;
  --setup-header-bg: #0f1825;
  --setup-section-bg: #101a26;
  --setup-row-bg: #1a2836;
  --setup-row-hover: #213141;
  --setup-row-border: #16222f;
  --setup-resume-bg: #26384a;
  --setup-active-bg: #1c3247;
  --setup-group-bg: #1e2f42;
  --setup-group-hover: #243447;
  --setup-text-bright: #e8f1f8;
  --setup-text-dim: #7d93a8;
  --setup-text-dim2: #5a7f9e;
  --setup-placeholder: #4e6a80;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-page); color: var(--text-body); overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

/* ── Login ─────────────────────────────────────────────────────────────── */
#login-screen {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 100vh; padding: 30px;
}
#login-screen .logo-wrap { text-align: center; margin-bottom: 40px; }
#login-screen .logo-wrap h1 { font-size: 34px; color: var(--text-heading); letter-spacing: 1px; }
#login-screen .logo-wrap .ver { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--bg-card);
  border-radius: 12px; overflow: hidden; margin-bottom: 16px;
}
.login-card input {
  width: 100%; background: transparent; border: none; outline: none;
  color: var(--text-heading); font-size: 15px; padding: 15px 16px;
}
.login-card input::placeholder { color: var(--text-muted); }
.login-card .divider { height: 1px; background: var(--border); margin: 0 16px; }
.login-error { white-space: pre-line;
  width: 100%; max-width: 380px; background: var(--bg-error); border-radius: 8px;
  padding: 12px; margin-bottom: 16px; color: var(--text-error); font-size: 13px;
  text-align: center; display: none;
}
.login-note {
  width: 100%; max-width: 380px; background: var(--bg-success); border-radius: 8px;
  padding: 12px; margin-bottom: 16px; color: var(--text-success); font-size: 13px;
  text-align: center; display: none;
}
.btn-primary {
  width: 100%; max-width: 380px; background: var(--accent); color: #fff;
  border: none; border-radius: 25px; padding: 15px; font-size: 16px;
  font-weight: bold; margin-bottom: 12px;
}
.btn-primary:disabled { opacity: 0.6; cursor: default; }

/* ── Expired / locked screen ───────────────────────────────────────────── */
#locked-screen {
  display: none; align-items: center; justify-content: center;
  height: 100vh; padding: 30px;
}
.locked-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px;
  padding: 34px 30px; width: 460px; max-width: 100%; text-align: center;
}
.locked-card .locked-ic { font-size: 44px; margin-bottom: 12px; }
.locked-card h2 { color: var(--text-heading); font-size: 21px; margin-bottom: 12px; }
.locked-card p { color: var(--text-faint); font-size: 14px; line-height: 1.65; margin-bottom: 14px; }
.locked-card .locked-exp { color: var(--text-error); font-size: 13px; font-weight: 600; margin-bottom: 20px; }

/* ── App shell: top brand bar + content + bottom nav ───────────────────── */
#app-screen { display: none; height: 100vh; }
.app-shell { display: grid; grid-template-columns: 210px minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); height: 100%; }
.topbar {
  grid-column: 1 / -1; grid-row: 1;
  display: flex; align-items: center; padding: 12px 22px; background: var(--bg-topbar);
  flex-shrink: 0; border-bottom: 1px solid var(--border);
}
.topbar .brand { color: var(--text-heading); font-size: 18px; font-weight: bold; flex: 1; }
.topbar .user-line { color: var(--text-muted); font-size: 13px; }

.content { grid-column: 2; grid-row: 2; overflow-y: auto; padding: 24px 28px 24px; }
.content h2 { color: var(--text-heading); font-size: 20px; margin-bottom: 18px; }

/* Vertical sidebar (was the bottom bar) */
.bottombar {
  grid-column: 1; grid-row: 2;
  display: flex; flex-direction: column; gap: 4px; padding: 14px 10px;
  background: var(--bg-topbar); border-right: 1px solid var(--border);
  overflow-y: auto;
}
.bottombar .nav-item {
  background: none; border: none; color: var(--text-muted);
  display: flex; flex-direction: row; align-items: center; gap: 12px;
  padding: 12px 14px; font-size: 14px; font-weight: 500; text-align: left;
  border-radius: 10px; border-left: 3px solid transparent; cursor: pointer;
}
.bottombar .nav-item .nav-ic { width: 22px; height: 22px; flex-shrink: 0; }
.bottombar .nav-item:hover { background: var(--bg-hover); color: var(--text-body); }
.bottombar .nav-item.active { color: var(--text-accent-light); border-left-color: var(--accent); background: var(--bg-hover); font-weight: 600; }

/* Greeting + study tip */
.greet { margin-bottom: 18px; }
.greet .hello { color: var(--text-heading); font-size: 24px; font-weight: 700; }
.greet .hello span { color: var(--text-accent-light); }
.greet .sub { color: var(--text-muted); font-size: 13px; margin-top: 3px; }
.tipcard {
  display: flex; gap: 14px; align-items: flex-start; margin-bottom: 22px;
  background: var(--bg-card); border: 1px solid var(--border-strong); border-left: 4px solid var(--accent);
  border-radius: 12px; padding: 14px 18px;
}
.tipcard .tip-ic { font-size: 22px; line-height: 1.2; }
.tipcard .tip-body { flex: 1; min-width: 0; }
.tipcard .tip-count { color: var(--text-muted); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 4px; }
.tipcard .tip-head { color: var(--text-heading); font-size: 15px; font-weight: 700; }
.tipcard .tip-text { color: var(--text-faint); font-size: 13.5px; line-height: 1.55; margin-top: 3px; }
.tipcard .tip-next { background: none; border: 1px solid var(--border-strong); color: var(--text-accent-light); border-radius: 8px; padding: 6px 12px; font-size: 12px; cursor: pointer; flex-shrink: 0; }
.tipcard .tip-next:hover { background: var(--bg-hover); }

/* Databases search */
.srch-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 4px 0 6px; }
.srch-bar input[type=text] { flex: 1; min-width: 240px; background: var(--bg-input); color: var(--text-body); border: 1px solid var(--border-strong); border-radius: 10px; padding: 10px 14px; font-size: 14px; }
.srch-bar input[type=text]:focus { outline: none; border-color: var(--accent); }
.srch-count { color: var(--text-muted); font-size: 12.5px; margin: 14px 0 2px; }
.srch-hit { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; cursor: pointer; }
.srch-hit:hover { border-color: var(--accent); background: var(--bg-card-alt); }
.srch-top { display: flex; gap: 10px; align-items: baseline; }
.srch-where { flex-shrink: 0; font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--text-accent-light); background: var(--bg-hover); border: 1px solid var(--border); border-radius: 20px; padding: 1px 8px; }
.srch-title { color: var(--text-heading); font-size: 14px; font-weight: 600; line-height: 1.4; }
.srch-snip { color: var(--text-faint); font-size: 13px; line-height: 1.5; margin-top: 5px; }
.srch-meta { color: var(--text-muted); font-size: 11.5px; margin-top: 4px; }
.srch-hit mark, .srch-snip mark, .srch-title mark { background: #f5d76e; color: #1a1a1a; border-radius: 3px; padding: 0 2px; }

/* Flashcards */
.fc-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.fc-bar select, .fc-bar input[type=text] {
  background: var(--bg-input); color: var(--text-body); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 13px; max-width: 220px;
}
.fc-bar input[type=text] { min-width: 180px; }
.fc-seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 9px; overflow: hidden; }
.fc-seg button { background: none; border: none; color: var(--text-muted); padding: 7px 13px; font-size: 12.5px; cursor: pointer; }
.fc-seg button.on { background: var(--accent); color: #fff; font-weight: 600; }
.fc-group { color: var(--text-accent-light); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; margin: 20px 0 10px; border-bottom: 1px solid var(--bg-card); padding-bottom: 6px; }
.fc-group small { color: var(--text-muted); font-weight: 500; letter-spacing: 0; text-transform: none; margin-left: 6px; }
.fc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.fc-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.fc-card .fc-q { color: var(--text-heading); font-size: 14px; font-weight: 600; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.fc-card .fc-a { color: var(--text-faint); font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; border-top: 1px dashed var(--border-strong); padding-top: 8px; display: none; }
.fc-card.show .fc-a { display: block; }
.fc-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.fc-tag { background: var(--bg-hover); border: 1px solid var(--border); color: var(--text-muted); border-radius: 20px; padding: 2px 9px; font-size: 11px; }
.fc-actions { display: flex; gap: 6px; margin-top: auto; }
.fc-overlay { position: fixed; inset: 0; background: rgba(5,12,20,.72); z-index: 9000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.fc-modal { background: var(--bg-page); border: 1px solid var(--border-strong); border-radius: 14px; width: min(620px, 100%); max-height: 92vh; overflow-y: auto; padding: 22px 24px; }
.fc-modal h3 { color: var(--text-heading); font-size: 18px; margin-bottom: 14px; }
.fc-modal label { display: block; color: var(--text-muted); font-size: 12px; margin: 12px 0 5px; }
.fc-modal input, .fc-modal textarea { width: 100%; background: var(--bg-input); color: var(--text-body); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; font-size: 14px; font-family: inherit; }
.fc-modal textarea { min-height: 96px; resize: vertical; }
.fc-row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.fc-modal .fc-btns { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.fc-pics { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.fc-pics img { max-width: 100%; max-height: 180px; border-radius: 8px; border: 1px solid var(--border-strong); background: #fff; cursor: zoom-in; object-fit: contain; }
.fc-flip .fc-pics { justify-content: center; }
.fc-flip .fc-pics img { max-height: 260px; }
.fc-imgrow { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.fc-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.fc-thumb { position: relative; }
.fc-thumb img { width: 76px; height: 76px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border-strong); background: #fff; display: block; }
.fc-thumb button { position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; border-radius: 50%; border: none; background: #c0392b; color: #fff; font-size: 13px; line-height: 20px; cursor: pointer; padding: 0; }
.fc-err { color: var(--text-error); font-size: 12.5px; margin-top: 10px; min-height: 16px; }
.fc-study { text-align: center; }
.fc-study .fc-prog { color: var(--text-muted); font-size: 12px; margin-bottom: 10px; }
.fc-flip { min-height: 220px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: var(--bg-card); border: 1px solid var(--border-strong); border-radius: 14px; padding: 26px; cursor: pointer; user-select: none; }
.fc-flip .fc-side { color: var(--text-muted); font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; }
.fc-flip .fc-text { color: var(--text-heading); font-size: 19px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.fc-study .fc-nav { display: flex; justify-content: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* ── Blue scrollbars everywhere (matches the app) ──────────────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--accent) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 5px; border: 2px solid var(--scrollbar-border); }
::-webkit-scrollbar-thumb:hover { background: var(--accent-hover); }

/* ── Smooth page changes: dark base while loading, soft fade-in ─────────── */
html { background: var(--bg-page); color-scheme: dark; }
html.booting #login-screen { display: none !important; }

/* ── Cards / lists ─────────────────────────────────────────────────────── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.sort-tabs { display: flex; background: var(--bg-tabs); border-radius: 8px; overflow: hidden; margin-bottom: 12px; max-width: 420px; }
.sort-tab { flex: 1; background: none; border: none; color: var(--text-muted); font-size: 13px; padding: 11px 0; border-bottom: 2px solid transparent; cursor: pointer; }
.sort-tab:hover { color: var(--text-body); }
.sort-tab.active { color: var(--accent); font-weight: 700; border-bottom-color: var(--accent); }
.card-list { display: flex; flex-direction: column; gap: 10px; }
.card-list .item-card { padding: 14px 18px; }
.card-list .item-card .meta .name { font-size: 15px; }
.item-card {
  background: var(--bg-card); border-radius: 12px; padding: 16px;
  display: flex; gap: 12px; align-items: center;
}
.item-card img.icon { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; background: var(--bg-page); }
.item-card .icon-ph {
  width: 46px; height: 46px; border-radius: 10px; background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: bold; font-size: 18px; flex-shrink: 0;
}
.item-card .meta { flex: 1; min-width: 0; }
.item-card .meta .name { color: var(--text-heading); font-size: 14px; font-weight: 600; line-height: 1.35; word-break: break-word; }
.item-card .meta .sub { color: var(--text-muted); font-size: 12px; margin-top: 3px; }
.item-card .actions { display: flex; gap: 6px; flex-shrink: 0; }
.btn-small {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 8px 14px; font-size: 12px; font-weight: 600;
}
.btn-small.secondary { background: var(--border); }
.btn-small.danger { background: var(--bg-danger-btn); }
.btn-small:disabled { opacity: 0.55; cursor: default; }

.progress-bar { height: 6px; background: var(--bg-page); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.progress-bar > div { height: 100%; background: var(--accent); width: 0%; transition: width 0.25s; }
.dl-status { color: var(--text-muted); font-size: 11px; margin-top: 5px; }

.search-row { display: flex; gap: 10px; margin-bottom: 18px; }
.search-row input {
  flex: 1; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text-heading); font-size: 14px; padding: 11px 14px; outline: none;
}
.search-row select {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text-body); font-size: 13px; padding: 0 12px; outline: none;
}

.empty-note { color: var(--text-muted); font-size: 14px; padding: 30px 0; text-align: center; }

/* ── Launch dialog ─────────────────────────────────────────────────────── */
.modal-back {
  display: none; position: fixed; inset: 0; background: #000a;
  align-items: center; justify-content: center; z-index: 50;
}
.modal {
  background: var(--bg-card); border-radius: 14px; padding: 24px; width: 380px;
}
.modal h3 { color: var(--text-heading); font-size: 17px; margin-bottom: 16px; }
.modal .row { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; }
.modal label { color: var(--text-muted); font-size: 13px; width: 90px; }
.modal select, .modal input[type=number] {
  flex: 1; background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text-heading); font-size: 14px; padding: 9px 12px; outline: none;
}
.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

/* ── Account ───────────────────────────────────────────────────────────── */
.acct-block { background: var(--bg-card); border-radius: 12px; padding: 18px 20px; margin-bottom: 14px; }
.acct-block .k { color: var(--text-muted); font-size: 12px; }
.acct-block .v { color: var(--text-heading); font-size: 15px; margin-top: 4px; }
.report-box {
  background: var(--bg-input); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px; color: var(--text-body); font-size: 13px; line-height: 1.6;
  white-space: pre-wrap; margin-top: 12px; max-height: 420px; overflow-y: auto; display: none;
}

/* ── Profile card + AI card (app-style) ────────────────────────────────── */
.profile-card {
  display: flex; align-items: center; gap: 14px; background: var(--bg-card);
  border-radius: 14px; padding: 18px 22px; margin-bottom: 12px;
}
.profile-card .avatar {
  width: 52px; height: 52px; border-radius: 26px; background: var(--bg-page);
  display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0;
}
.profile-card .profile-name { color: var(--text-heading); font-size: 17px; font-weight: 700; }
.profile-card .profile-expiry { font-size: 12px; margin-top: 3px; }
.profile-card .profile-logout {
  background: var(--bg-logout-btn); border: none; color: var(--text-error); font-size: 18px;
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
}
.ai-card {
  display: flex; align-items: center; gap: 14px; width: 100%;
  background: linear-gradient(135deg, var(--bg-card), var(--bg-card-alt)); border: 1px solid var(--border-strong);
  border-radius: 14px; padding: 16px 18px; margin-bottom: 8px; cursor: pointer;
}
.ai-card:hover { border-color: var(--accent-hover2); }
.ai-card .ai-icon {
  width: 44px; height: 44px; border-radius: 22px; background: var(--bg-page);
  display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0;
}
.ai-card .ai-title { color: var(--text-heading); font-size: 15px; font-weight: 600; }
.ai-card .ai-desc { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

.ai-modal-back {
  display: none; position: fixed; inset: 0; background: #000b;
  align-items: center; justify-content: center; z-index: 70; padding: 30px;
}
.ai-modal {
  background: var(--bg-page); border-radius: 16px; width: 620px; max-width: 100%;
  max-height: 85vh; display: flex; flex-direction: column;
  border: 1px solid var(--border);
}
.ai-modal-head {
  display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border);
  color: var(--text-heading); font-size: 16px; font-weight: 600;
}
.ai-modal-head span { flex: 1; }
.ai-modal-head button { background: none; border: none; color: var(--text-muted); font-size: 20px; cursor: pointer; }
.ai-modal-body { padding: 18px 22px; overflow-y: auto; }


/* ── Account page: wide professional layout ────────────────────────────── */
.acct-wrap { max-width: 1100px; margin: 0 auto; padding-bottom: 40px; }
.acct-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.acct-cols > div { min-width: 0; }
@media (max-width: 900px) { .acct-cols { grid-template-columns: 1fr; } }

/* Jump back in (recent QBanks / test) */
.rc-title { color: var(--text-muted); font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; margin: 2px 0 8px; }
.rc-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.rc-card { display: flex; align-items: center; gap: 10px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; cursor: pointer; text-align: left; min-width: 190px; max-width: 320px; color: var(--text-body); font-family: inherit; }
.rc-card:hover { background: var(--bg-card-alt); border-color: var(--accent); }
.rc-card.rc-test { border-color: var(--accent); max-width: 400px; }
.rc-ic { width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; background: var(--bg-page); }
.rc-ic img { width: 100%; height: 100%; object-fit: cover; }
.rc-ic.rc-light { background: #fff; padding: 5px; box-sizing: border-box; }
.rc-ic.rc-light img { object-fit: contain; }
.rc-ph { color: #fff; background: var(--accent); width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; }
.rc-tx { display: flex; flex-direction: column; min-width: 0; }
.rc-tx b { color: var(--text-heading); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-tx small { color: var(--text-muted); font-size: 11.5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
