:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #1c2330;
  --border: rgba(255,255,255,0.08);
  --border2: rgba(255,255,255,0.14);
  --accent: #f0a500;
  --accent2: #e08800;
  --blue: #58a6ff;
  --green: #3fb950;
  --red: #f85149;
  --text: #e6edf3;
  --muted: #7d8590;
  --muted2: #9ba3ae;
  --mono: 'JetBrains Mono', monospace;
  --sans: 'Be Vietnam Pro', sans-serif;
  --radius: 10px;
  --radius-lg: 16px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ===================== LAYOUT ===================== */
.app { display: flex; flex-direction: column; min-height: 100vh; }

/* ===================== HEADER ===================== */
.header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-wrap: wrap;
}
.logo {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.logo span { color: var(--muted); font-weight: 400; }

.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  margin-left: auto;
}
.tab {
  padding: 6px 16px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--muted2);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  transition: all .2s;
}
.tab:hover { color: var(--text); background: var(--surface2); }
.tab.active { background: var(--accent); color: #000; font-weight: 600; }

.group-filter {
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
  outline: none;
}
.group-filter:focus { border-color: var(--accent); }

/* ===================== MAIN ===================== */
.main {
  flex: 1;
  padding: 2rem 1.5rem;
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
}

.section { display: none; }
.section.on { display: block; }

/* ===================== BUTTONS ===================== */
.btn {
  padding: 9px 22px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.btn:hover { background: var(--surface2); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent2); }

.add-btn {
  padding: 7px 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(240,165,0,.4);
  background: rgba(240,165,0,.1);
  color: var(--accent);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.add-btn:hover { background: rgba(240,165,0,.2); }

/* ===================== FLASHCARD ===================== */
.fc-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.fc-count {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  margin-left: auto;
}

.progress {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  margin-bottom: 1.75rem;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width .4s cubic-bezier(.4,0,.2,1);
}

.card-scene {
  perspective: 1000px;
  margin-bottom: 1.5rem;
  cursor: pointer;
  height: 220px;
}
.card-body {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform .5s cubic-bezier(.4,0,.2,1);
}
.card-scene.flipped .card-body { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border2);
  background: var(--surface);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  gap: 10px;
}
.card-face.back {
  transform: rotateY(180deg);
  background: var(--surface2);
  border-color: rgba(240,165,0,.25);
}

.card-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  position: absolute;
  top: 16px;
  left: 20px;
}
.card-group-tag {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent);
  position: absolute;
  top: 16px;
  right: 20px;
  background: rgba(240,165,0,.1);
  padding: 2px 8px;
  border-radius: 4px;
}
.card-cmd {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--blue);
  text-align: center;
  line-height: 1.7;
  word-break: break-word;
  max-width: 100%;
}
.card-desc {
  font-size: 17px;
  font-weight: 500;
  color: var(--text);
  text-align: center;
  line-height: 1.5;
}
.card-tip {
  font-size: 13px;
  color: var(--accent);
  font-style: italic;
  position: absolute;
  bottom: 16px;
}
.card-click-hint {
  font-size: 11px;
  color: var(--muted);
  position: absolute;
  bottom: 16px;
  right: 20px;
}

.fc-nav {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

/* ===================== QUIZ ===================== */
.score-row {
  display: flex;
  gap: 10px;
  margin-bottom: 1.25rem;
  align-items: center;
  flex-wrap: wrap;
}
.score-chip {
  padding: 5px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--mono);
}
.chip-ok { background: rgba(63,185,80,.15); color: var(--green); border: 1px solid rgba(63,185,80,.3); }
.chip-no { background: rgba(248,81,73,.15); color: var(--red);   border: 1px solid rgba(248,81,73,.3); }

.quiz-card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 1.25rem;
}
.quiz-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .75rem;
}
.quiz-q {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 1rem;
  line-height: 1.6;
}
.quiz-code {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  border-radius: var(--radius);
  color: var(--blue);
  display: block;
  margin-bottom: 1.25rem;
  line-height: 1.7;
  word-break: break-word;
  white-space: pre-wrap;
}

.opts { display: flex; flex-direction: column; gap: 8px; }
.opt {
  padding: 11px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  transition: all .15s;
  line-height: 1.5;
  word-break: break-word;
}
.opt:hover:not([disabled]) { border-color: var(--border2); background: var(--surface2); }
.opt.correct { background: rgba(63,185,80,.12); border-color: var(--green); color: var(--green); }
.opt.wrong   { background: rgba(248,81,73,.12); border-color: var(--red);   color: var(--red); }

.feedback {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 1rem;
  display: none;
  line-height: 1.5;
}
.feedback.ok { background: rgba(63,185,80,.1); border: 1px solid rgba(63,185,80,.3); color: #7ee787; }
.feedback.no { background: rgba(248,81,73,.1); border: 1px solid rgba(248,81,73,.3); color: #ff7b72; }

/* ===================== LIST / TRA CỨU ===================== */
.list-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.list-table { width: 100%; border-collapse: collapse; }
.list-table th {
  padding: 11px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.list-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-size: 13px;
}
.list-table tr:last-child td { border-bottom: none; }
.list-table tr:hover td { background: var(--surface2); }

.num-dot {
  display: inline-flex;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(240,165,0,.15);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
}
.cmd-cell  { font-family: var(--mono); font-size: 12px; color: var(--blue); line-height: 1.6; word-break: break-word; }
.desc-cell { color: var(--text); line-height: 1.5; }
.tip-cell  { font-style: italic; color: var(--muted2); font-size: 12px; }

.group-name-row td {
  background: rgba(240,165,0,.06);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 7px 14px;
  border-bottom: 1px solid var(--border);
}

/* ===================== CHECKBOX & BULK ===================== */
.row-chk {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

.bulk-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  margin-bottom: .75rem;
  border-radius: var(--radius);
  background: rgba(240,165,0,.08);
  border: 1px solid rgba(240,165,0,.25);
  flex-wrap: wrap;
}
.bulk-bar.visible { display: flex; }

.bulk-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  font-family: var(--mono);
}

.bulk-del-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(248,81,73,.4);
  background: rgba(248,81,73,.1);
  color: var(--red);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.bulk-del-btn:hover { background: rgba(248,81,73,.2); }

.bulk-cancel-btn {
  padding: 5px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--muted2);
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
  margin-left: auto;
}
.bulk-cancel-btn:hover { color: var(--text); background: var(--surface2); }

/* row selected highlight */
.list-table tr.selected td { background: rgba(240,165,0,.06); }

/* action buttons in row */
.row-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: flex-end;
}
.row-edit-btn, .row-del-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  transition: all .15s;
  flex-shrink: 0;
}
.row-edit-btn { color: var(--blue); }
.row-edit-btn:hover { background: rgba(88,166,255,.12); border-color: rgba(88,166,255,.4); }
.row-del-btn  { color: var(--red); }
.row-del-btn:hover  { background: rgba(248,81,73,.12); border-color: rgba(248,81,73,.4); }

/* ===================== MODAL ===================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  width: 100%;
  max-width: 520px;
  transform: translateY(16px);
  transition: transform .25s;
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-title span { color: var(--accent); }

.field { margin-bottom: 1rem; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
  resize: vertical;
  transition: border-color .15s;
}
.field textarea { min-height: 80px; }
.field select   { font-family: var(--sans); }
.field input:focus,
.field textarea:focus,
.field select:focus { border-color: var(--accent); }

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 1.25rem;
}
.btn-ghost {
  padding: 8px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--muted2);
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

/* ===================== TOAST ===================== */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 300;
  background: var(--green);
  color: #000;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  transform: translateY(60px);
  opacity: 0;
  transition: all .3s;
  pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ===================== SCROLLBAR ===================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 600px) {
  .header  { padding: 1rem; gap: .75rem; }
  .main    { padding: 1.25rem 1rem; }
  .card-scene { height: 240px; }
  .card-cmd   { font-size: 13px; }
  .tabs    { margin-left: 0; width: 100%; justify-content: center; }
}
