@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=IBM+Plex+Mono:wght@400;500;600&family=Noto+Serif+Bengali:wght@400;500;600;700&family=Hind+Siliguri:wght@400;500;600&display=swap');

:root{
  --bg: #12161c;
  --surface: #1b212a;
  --surface-2: #222a34;
  --border: #2b3441;
  --text: #edeff2;
  --muted: #8b96a5;
  --mint: #4fd1c5;
  --mint-dim: rgba(79,209,197,.14);
  --amber: #f2b84b;
  --coral: #f4707b;
  --coral-dim: rgba(244,112,123,.12);
}

:root[data-theme="light"]{
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --border: #dde1e7;
  --text: #1b212a;
  --muted: #626b78;
  --mint: #1a9e91;
  --mint-dim: rgba(26,158,145,.12);
  --amber: #b3790f;
  --coral: #c73c47;
  --coral-dim: rgba(199,60,71,.10);
}

* { box-sizing: border-box; }

body{ transition: background-color .2s ease, color .2s ease; }

/* ---- theme toggle switch ---- */
.theme-toggle{
  /* position: fixed; */
  top: 18px;
  right: 5vw;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--muted);
  transition: border-color .15s ease, background-color .2s ease, color .2s ease;
}
.theme-toggle:hover{ border-color: var(--mint); color: var(--text); }
.theme-toggle svg{ display:block; width:14px; height:14px; flex-shrink:0; }
.theme-toggle .tt-sun{ display:none; }
.theme-toggle .tt-moon{ display:block; }
:root[data-theme="light"] .theme-toggle .tt-sun{ display:block; }
:root[data-theme="light"] .theme-toggle .tt-moon{ display:none; }

@media (max-width: 640px){
  .theme-toggle{ top: 12px; right: 5vw; padding: 5px 10px; }
}

/* ---- exam-hall sound toggle (bcctest.html only) ---- */
.sound-toggle .ts-off{ display:none; }
.sound-toggle.is-muted .ts-on{ display:none; }
.sound-toggle.is-muted .ts-off{ display:block; }

body {
  font-family: 'Hind Siliguri', 'Manrope', Arial, sans-serif;
  background:
    radial-gradient(1200px 500px at 15% -10%, rgba(79,209,197,.07), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(242,184,75,.05), transparent 55%),
    var(--bg);
  margin: 0;
  padding: 20px 5vw 80px;
  color: var(--text);
  min-height: 100vh;
}

.container {
  /* max-width: 1220px; */
  margin: 0 auto;
}

/* ---- heading / hero ---- */
h1 {
  margin: 0;
  margin-bottom: 6px;
  font-family: 'Manrope', sans-serif;
  font-size: clamp(26px, 3.2vw, 38px);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.caret{
  display:inline-block;width:3px;height:.85em;background:var(--mint);
  animation:blink 1.1s steps(1) infinite;transform:translateY(2px);margin-left:2px;
}
@media (prefers-reduced-motion: reduce){ .caret{animation:none;opacity:1;} }
@keyframes blink{50%{opacity:0;}}

.page-eyebrow{
  font-family:'IBM Plex Mono',monospace;
  font-size:12px;letter-spacing:.14em;text-transform:uppercase;
  color:var(--mint);margin:0 0 10px;display:flex;align-items:center;gap:10px;
}
.page-eyebrow::before{content:"";width:18px;height:1px;background:var(--mint);display:inline-block;}

.page-sub{ color: var(--muted); margin: 6px 0 0; font-size: 14.5px; max-width: 60ch; }

.page-header{
  display:flex;justify-content:space-between;align-items:flex-end;gap:20px;flex-wrap:wrap;
  margin-bottom: 28px;
}

.stat-strip{display:flex;gap:10px;flex-wrap:wrap;}
.stat-chip{
  background:var(--surface);border:1px solid var(--border);border-radius:10px;
  padding:10px 16px;min-width:96px;
}
.stat-chip .n{font-family:'IBM Plex Mono',monospace;font-size:20px;font-weight:600;color:var(--text);}
.stat-chip .l{font-size:11px;color:var(--muted);letter-spacing:.04em;margin-top:2px;}

/* ---- toolbar (add button + search) ---- */
.toolbar{
  display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:16px;
  margin: 0 0 22px;padding-bottom:20px;border-bottom:1px solid var(--border);
}

.search-wrap{position:relative;flex:1;min-width:220px;max-width:360px;}
.search-wrap input{
  width:100%;background:var(--surface);border:1px solid var(--border);color:var(--text);
  border-radius:10px;padding:11px 14px 11px 38px;font-family:'Hind Siliguri',sans-serif;font-size:14.5px;
  outline:none;transition:border-color .15s ease;
}
.search-wrap input:focus{border-color:var(--mint);}
.search-wrap svg{position:absolute;left:12px;top:50%;transform:translateY(-50%);opacity:.55;pointer-events:none;}

/* ---- sort toggle (new, additive — asc/desc ordering of paragraph list) ---- */
.sort-toggle{
  display:inline-flex;align-items:center;gap:7px;flex-shrink:0;
  background:var(--surface);border:1px solid var(--border);border-radius:10px;
  padding:10px 14px;color:var(--muted);cursor:pointer;
  font-family:'IBM Plex Mono',monospace;font-size:12.5px;font-weight:600;
  transition:border-color .15s ease,color .15s ease,background .15s ease;
}
.sort-toggle:hover{ border-color:var(--mint); color:var(--text); transform:none; box-shadow:none; }
.sort-toggle.desc{ background:var(--mint-dim); border-color:var(--mint); color:var(--mint); }
.sort-toggle svg{ display:block; width:15px; height:15px; flex-shrink:0; }

/* ---- category filter chips ---- */
.chips{display:flex;gap:8px;flex-wrap:wrap;margin:0 0 22px;}
.chip{
  font-size:12.5px;padding:7px 13px;border-radius:999px;border:1px solid var(--border);
  color:var(--muted);cursor:pointer;background:transparent;font-family:'Hind Siliguri',sans-serif;
  transition:all .15s ease;white-space:nowrap;
}
.chip:hover{border-color:var(--mint);color:var(--text);}
.chip.active{background:var(--mint-dim);border-color:var(--mint);color:var(--mint);}

/* ---- generic card ---- */
/* .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 22px 18px;
  margin-bottom: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,.18);
} */

.card h2 {
  margin-top: 0;
  font-size: 12.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
}

/* ---- inputs & buttons (generic, used across pages) ---- */
input[type="text"], textarea {
  width: 100%;
  padding: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  font-size: 15px;
  margin-bottom: 12px;
  font-family: 'Hind Siliguri', sans-serif;
  resize: vertical;
  outline: none;
  transition: border-color .15s ease;
}
input[type="text"]::placeholder, textarea::placeholder{ color: var(--muted); }
input[type="text"]:focus, textarea:focus{ border-color: var(--mint); }

button {
  background: var(--mint);
  color: #0b1414;
  border: none;
  padding: 10px 18px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 700;
  font-family: 'Manrope', 'Hind Siliguri', sans-serif;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

button:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(79,209,197,.22); }
button:active { transform: translateY(0); }

/* the "Add Paragraph" link-button on index.html */
.container > a > button{
  display:inline-flex;align-items:center;gap:8px;margin-bottom: 26px;
}

/* ---- paragraph list (index.html) ---- */
.list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.para-item {
  display: flex;
  flex-direction: column;
  padding: 18px 18px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  transition: border-color .2s ease, transform .2s ease;
}
.para-item:hover{ border-color: rgba(79,209,197,.4); transform: translateY(-2px); }

.para-item .info { flex: 1; min-width: 0; margin-bottom: 14px; }
.para-item .info .info-top{
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}
.para-item .info .title {
  font-weight: 700;
  font-size: 15.5px;
  font-family: 'Hind Siliguri', sans-serif;
  margin-bottom: 6px;
}
.para-item .info .cat-tag{
  font-size:10.5px;padding:3px 9px;border-radius:999px;background:var(--surface);
  color:var(--amber);font-family:'IBM Plex Mono',monospace;letter-spacing:.03em;
  white-space:nowrap;flex-shrink:0;
}
.para-item .info .preview {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-family: 'Noto Serif Bengali', serif;
  line-height: 1.6;
}

.para-item .info .char-count {
  color: var(--muted);
  font-size: 11.5px;
  font-family: 'IBM Plex Mono', monospace;
  margin-top: 4px;
}

.para-item .actions { display: flex; gap: 8px; flex-shrink: 0; }
.para-item .actions button{
  padding: 9px 0; font-size: 12.5px; border-radius: 8px; flex: 1;
}
.para-item .actions .start-btn { background: var(--mint); color: #0b1414; }
.para-item .actions .start-btn:hover { background: #3fc1b4; }
.para-item .actions .edit-btn { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.para-item .actions .edit-btn:hover { background: #26303c; }
.para-item .actions .delete-btn { background: var(--coral-dim); color: var(--coral); display: none;}
.para-item .actions .delete-btn:hover { background: rgba(244,112,123,.22); box-shadow:none; }

.empty-msg { color: var(--muted); text-align: center; padding: 40px 0; font-family:'Hind Siliguri',sans-serif; }

/* ---- back link (add.html / test.html) ---- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  /* margin-bottom: 16px; */
  color: var(--mint);
  text-decoration: none;
  font-size: 13.5px;
  font-family: 'IBM Plex Mono', monospace;
}
.back-link:hover{ text-decoration: underline; }

/* ---- typing test page ---- */
.paragraph-display {
  font-family: 'Noto Serif Bengali', serif;
  font-size: 18px;
  line-height: 1.9;
  padding: 20px;
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 16px;
  user-select: none;
  max-height: 350px;
  overflow-y: auto;
}

.stats-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0;
  font-size: 13px;
  color: var(--muted);
}
.stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  font-family: 'IBM Plex Mono', monospace;
}
.stat span { font-weight: 700; color: var(--mint); font-size: 16px; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

.restart-btn { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.restart-btn:hover { background: #26303c; box-shadow:none; }

.submit-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

.result-card { text-align: center; }
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 10px;
}
.result-grid div {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 8px;
}
.result-grid strong { display: block; font-size: 20px; font-family:'IBM Plex Mono',monospace; color: var(--mint); }
.result-grid span { font-size: 12px; color: var(--muted); }

/* ---- backspace-used words + typing-behavior panels (result card) ---- */
.typing-behavior { margin-top: 18px; }

.backspace-words {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 18px;
  text-align: left;
}
.backspace-words .bw-col {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.backspace-words h3 {
  margin: 0 0 8px;
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-family: 'IBM Plex Mono', monospace;
}
.backspace-words .bw-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.backspace-words .bw-word {
  font-family: 'Noto Serif Bengali', serif;
  font-size: 13.5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  color: var(--coral);
}

.word-compare {
  margin-top: 18px;
  text-align: left;
  max-height: 300px;
  overflow-y: auto;
}
.word-compare table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.word-compare th, .word-compare td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.word-compare th { color: var(--muted); font-weight: 600; font-family:'IBM Plex Mono',monospace; font-size: 11.5px; text-transform: uppercase; letter-spacing:.04em; }
.word-compare .half { color: var(--amber); }
.word-compare .full { color: var(--coral); }

/* .paragraph-display .correct { color: var(--mint); } */
/* .paragraph-display .incorrect { color: var(--coral); background: rgba(244,112,123,.14); border-radius: 3px; } */
/* .paragraph-display .pending { color: var(--muted); } */
/* .paragraph-display .current { border-bottom: 2px solid var(--mint); } */

.typing-input { 
  font-family: 'Noto Serif Bengali', serif;
  font-size: 18px;
  line-height: 1.9;
}

.empty{
  grid-column:1/-1;text-align:center;padding:60px 20px;color:var(--muted);
  border:1px dashed var(--border);border-radius:14px;font-family:'Hind Siliguri',sans-serif;
}

.copy-correct-btn {
  display: inline-block;
  margin: 12px 0;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  background: #2563eb;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}
.copy-correct-btn:hover {
  background: #1d4ed8;
}

/* ---- name field on test.html + back-link row ---- */
.back-link-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

.name-input { margin-bottom: 14px; max-width: 320px; }
input#nameInput {
    padding: 2px 20px;
}

.save-status {
  font-size: 12.5px;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--muted);
  margin: 10px 0 0;
}
.save-status.ok { color: var(--mint); }
.save-status.err { color: var(--coral); }

/* ---- history.html table ---- */
.history-table-wrap { overflow-x: auto; }
.history-table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 620px; }
.history-table th, .history-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
.history-table th {
  color: var(--muted);
  font-weight: 600;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.history-table td:nth-child(2) { font-family: 'Hind Siliguri', sans-serif; white-space: normal; }
.history-table td:nth-child(3) { color: var(--muted); white-space: normal; }
.history-table td:nth-child(4) { color: var(--mint); font-family: 'IBM Plex Mono', monospace; font-weight: 700; }
