@import url('https://fonts.googleapis.com/css2?family=Kalam:wght@400;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
  --board: #24352C;
  --board-dark: #1A2921;
  --card: #F3EEDD;
  --ink: #2B2B2B;
  --chalk: #F3EEDD;
  --green: #4D6B57;
  --red: #C1604A;
  --blue: #6E9DB0;
  --yellow: #E4B94D;
  --sage: #7C9473;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--board);
  color: var(--chalk);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
}

h1, h2, h3, .display { font-family: 'Kalam', cursive; }
.mono { font-family: 'JetBrains Mono', monospace; }

#app { max-width: 780px; margin: 0 auto; padding-bottom: 4rem; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem 0.5rem;
}
.topbar h1 { margin: 0; font-size: 1.6rem; }
.userinfo { font-size: 0.85rem; opacity: 0.85; display: flex; align-items: center; gap: 0.5rem; }

nav.tabs {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  padding: 0.5rem 1.25rem 1rem;
}
nav.tabs button {
  background: rgba(243,238,221,0.08);
  color: var(--chalk);
  border: none; border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem; cursor: pointer;
  font-family: 'Inter', sans-serif;
}
nav.tabs button.active { background: var(--yellow); color: var(--ink); font-weight: 600; }

#adminTabs {
  margin: 0; padding: 0;
  display: flex; gap: 0.4rem; flex-wrap: wrap;
}
#adminTabs button {
  background: rgba(0,0,0,0.12);
  color: var(--ink);
  border: none; border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem; cursor: pointer;
  font-family: 'Inter', sans-serif;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
#adminTabs button:hover {
  background: rgba(0,0,0,0.16);
}
#adminTabs button.active {
  background: rgba(0,0,0,0.22);
  color: var(--chalk);
  font-weight: 600;
  border-bottom: 3px solid var(--green);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

main { padding: 0 1.25rem 2rem; }

.card {
  background: var(--card); color: var(--ink);
  border-radius: 14px; padding: 1.1rem;
  margin-bottom: 1rem; box-shadow: 0 6px 18px rgba(0,0,0,0.25);
}

input, select, textarea {
  font-family: 'Inter', sans-serif;
  width: 100%; padding: 0.55rem 0.7rem;
  border-radius: 9px; border: 1px solid rgba(0,0,0,0.15);
  margin-bottom: 0.6rem; font-size: 0.92rem; background: #fff;
  overflow-wrap: break-word; word-wrap: break-word;
}

/* File input styling */
input[type="file"] {
  display: none;
}
.file-upload-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.6rem;
  background: rgba(0,0,0,0.08);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.15);
}
.file-upload-label:hover {
  background: rgba(0,0,0,0.12);
}
textarea { min-height: 70px; resize: vertical; white-space: pre-wrap; }

button.btn {
  font-family: 'Inter', sans-serif; cursor: pointer;
  border: none; border-radius: 9px; padding: 0.6rem 1rem;
  font-weight: 600; font-size: 0.9rem; color: #fff;
}
.btn-primary { background: var(--green); }
.btn-danger { background: var(--red); }
.btn-secondary { background: var(--blue); }
.btn-outline { background: rgba(0,0,0,0.06); color: var(--ink); }
button.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.row { display: flex; gap: 0.5rem; }
.row > * { flex: 1; }

.tag {
  display: inline-block; font-size: 0.72rem; padding: 0.15rem 0.55rem;
  border-radius: 999px; background: rgba(0,0,0,0.08); margin-right: 0.3rem;
}

.subject-pill {
  display: inline-block; padding: 0.15rem 0.6rem; border-radius: 999px;
  font-size: 0.72rem; color: #fff; font-weight: 600;
}

.option-row {
  display: flex; align-items: center; gap: 0.3rem;
  margin-bottom: 0.5rem; padding: 0.3rem 0.4rem; border-radius: 8px;
  background: rgba(0,0,0,0.03);
}
.option-row input[type="checkbox"] { flex-shrink: 0; width: 18px; height: 18px; margin: 0; }
.option-row input[type="text"] { margin-bottom: 0; flex: 1; }
.option-row.correct { background: rgba(76,140,90,0.18); }
.option-row.wrong { background: rgba(193,96,74,0.18); }

.error-box {
  background: rgba(193,96,74,0.25); border: 1px solid var(--red);
  color: var(--chalk); padding: 0.6rem 0.8rem; border-radius: 9px;
  margin-bottom: 0.8rem; font-size: 0.85rem;
}
.success-box {
  background: rgba(76,140,90,0.25); border: 1px solid var(--green);
  color: var(--chalk); padding: 0.6rem 0.8rem; border-radius: 9px;
  margin-bottom: 0.8rem; font-size: 0.85rem;
}

.small { font-size: 0.78rem; opacity: 0.7; }
.center { text-align: center; }
.mb-0 { margin-bottom: 0 !important; }
.hidden { display: none !important; }

.question-image, .option-image { max-width: 100%; border-radius: 8px; margin-bottom: 0.6rem; }
.option-image { max-height: 90px; }

.progress-bar {
  height: 8px; border-radius: 999px; background: rgba(0,0,0,0.08); overflow: hidden;
}
.progress-bar > div { height: 100%; border-radius: 999px; }

.list-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem; padding: 0.5rem 0; border-bottom: 1px solid rgba(0,0,0,0.08);
}
.list-item:last-child { border-bottom: none; }

.set-grid-item {
  border: 3px solid rgba(0,0,0,0.1); padding: 1rem; border-radius: 8px; background: rgba(0,0,0,0.02);
  cursor: pointer; text-align: left; transition: all 0.3s;
  display: flex; flex-direction: column;
}
.set-grid-item:hover { background: rgba(0,0,0,0.05); border-color: rgba(0,0,0,0.15); }
.set-grid-item.active {
  background: rgba(0,0,0,0.15);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2), inset 0 0 0 2px var(--chalk);
  border-color: var(--green);
  border-width: 3px;
}

/* Responsive Design */
@media (max-width: 600px) {
  #app { max-width: 100%; padding-bottom: 4rem; }
  main { padding: 0 0.75rem 2rem; }
  .topbar { padding: 0.75rem 0.75rem 0.5rem; }
  nav.tabs { padding: 0.5rem 0.75rem 1rem; gap: 0.3rem; }
  nav.tabs button { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
  .card { padding: 0.8rem; margin-bottom: 0.8rem; }
  input, select, textarea { padding: 0.5rem 0.6rem; margin-bottom: 0.5rem; font-size: 0.9rem; }
  textarea { min-height: 60px; }
  .row { gap: 0.4rem; }
  .list-item { gap: 0.3rem; padding: 0.4rem 0; flex-wrap: wrap; }
  .option-row { gap: 0.25rem; padding: 0.25rem 0.3rem; }
  #setsGrid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important; }
  .set-grid-item { padding: 0.8rem; border-width: 2px; }
  .set-grid-item span:first-child { font-size: 0.9rem; word-break: break-word; }
}

@media (min-width: 601px) and (max-width: 1024px) {
  #app { max-width: 900px; }
}

@media (min-width: 1025px) {
  #app { max-width: 1000px; }
  main { padding: 0 2rem 2rem; }
}
