:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --text: #17211d;
  --muted: #62736b;
  --line: #dce4e0;
  --accent: #0f8b6f;
  --accent-dark: #096450;
  --warn: #b76e00;
  --danger: #b42318;
  --shadow: 0 16px 35px rgba(23, 33, 29, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 292px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  background: #10231d;
  color: #f9fffc;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: var(--radius);
  background: #e6c15a;
  color: #10231d;
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
}

.brand p {
  color: #b8c9c2;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: #f9fffc;
  text-align: left;
}

.nav button:hover,
.nav button.active {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.12);
}

.nav strong {
  color: #e6c15a;
  font-size: 12px;
}

.ghost-btn,
.primary-btn,
.secondary-btn {
  min-height: 40px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 9px 12px;
}

.ghost-btn {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  color: #f9fffc;
  text-align: center;
}

.primary-btn {
  background: var(--accent);
  color: #ffffff;
}

.primary-btn:hover {
  background: var(--accent-dark);
}

.secondary-btn {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--line);
}

.app-shell {
  margin-left: 292px;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.eyebrow {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar h2 {
  margin-top: 4px;
  font-size: 28px;
}

.search-wrap {
  flex: 1;
  max-width: 460px;
}

.search-wrap input,
select,
form input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.search-wrap input,
select,
form input {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 170px;
  padding: 12px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 139, 111, 0.14);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stats-grid article {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.stats-grid strong {
  display: block;
  font-size: 30px;
}

.stats-grid span {
  color: var(--muted);
  font-size: 14px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 5px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.mode-btn {
  min-height: 34px;
  padding: 6px 11px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.mode-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 6px 16px rgba(23, 33, 29, 0.08);
}

.toolbar select {
  width: 210px;
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(315px, 1fr));
  gap: 16px;
}

.note-card,
.flashcard,
.quiz-panel,
.editor-view form,
.paste-panel,
.empty-state {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.note-card {
  display: flex;
  min-height: 278px;
  flex-direction: column;
  padding: 18px;
}

.note-card.review {
  border-color: rgba(183, 110, 0, 0.45);
}

.note-card.done {
  border-color: rgba(15, 139, 111, 0.5);
}

.card-meta,
.flashcard-head,
.quiz-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.card-meta span,
.flashcard-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.note-card h3 {
  margin: 14px 0 8px;
  font-size: 18px;
  line-height: 1.3;
}

.note-card p,
.answer-body,
.quiz-panel p,
.paste-panel p {
  color: #3c4d45;
  line-height: 1.6;
}

.answer-body p {
  margin: 0 0 10px;
}

.answer-body ul,
.answer-body ol {
  margin: 0 0 10px 20px;
  padding: 0;
}

.answer-body li {
  margin: 5px 0;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 14px;
}

.card-actions button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  padding: 6px 10px;
}

.card-actions button.selected {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.card-actions button[data-action="delete"] {
  margin-left: auto;
  color: var(--danger);
}

.edit-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(15, 139, 111, 0.28);
  border-radius: var(--radius);
  background: rgba(15, 139, 111, 0.08);
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
}

.edit-banner button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 4px 9px;
}

.study-view {
  max-width: 900px;
}

.flashcard,
.quiz-panel {
  padding: 24px;
}

.flashcard h3,
.quiz-panel h3 {
  margin: 24px 0 14px;
  font-size: 26px;
  line-height: 1.25;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.quiz-head {
  align-items: start;
}

.quiz-head h3 {
  margin-top: 4px;
}

.quiz-head strong {
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--surface-2);
}

details {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfc;
}

summary {
  cursor: pointer;
  font-weight: 800;
}

.editor-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: 16px;
}

.editor-view form,
.paste-panel {
  padding: 18px;
}

form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px;
  gap: 12px;
}

.paste-panel h3 {
  margin: 0 0 8px;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 32px;
  color: var(--muted);
  text-align: center;
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .sidebar {
    position: static;
    width: auto;
    max-height: none;
  }

  .app-shell {
    margin-left: 0;
    padding: 18px;
  }

  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .search-wrap,
  .toolbar select {
    max-width: none;
    width: 100%;
  }

  .stats-grid,
  .editor-view,
  .form-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    gap: 10px;
  }

  .topbar h2,
  .flashcard h3,
  .quiz-panel h3 {
    font-size: 22px;
  }

  .card-actions button {
    flex: 1 1 auto;
  }

  .card-actions button[data-action="delete"] {
    margin-left: 0;
  }
}
