:root {
  color-scheme: dark;
  --bg: #101111;
  --panel: #171a19;
  --panel-2: #202523;
  --line: rgba(216, 209, 195, 0.13);
  --text: #f5f1e8;
  --muted: #a5aaa8;
  --soft: #d8d1c3;
  --green: #39d98a;
  --lime: #b8e35f;
  --yellow: #f4d35e;
  --coral: #ff8a5b;
  --red: #ff4f6d;
  --cyan: #48c7d8;
  --accent: #39d98a;
  --accent-contrast: #07110b;
  --shadow: 0 20px 58px rgba(0, 0, 0, 0.28);
  --soft-shadow: 0 14px 38px rgba(0, 0, 0, 0.2);
}

body[data-theme="graphite"] {
  --bg: #0d0f10;
  --panel: #17191c;
  --panel-2: #22262a;
  --line: #3a4046;
  --text: #f3f5f5;
  --muted: #a9b0b4;
  --soft: #d5dbdd;
}

body[data-theme="forest"] {
  --bg: #101411;
  --panel: #18201b;
  --panel-2: #202a24;
  --line: #344038;
  --text: #f4f7f2;
  --muted: #aab4a9;
  --soft: #d6ddd1;
}

body[data-accent="cyan"] {
  --accent: #48c7d8;
  --accent-contrast: #061012;
}

body[data-accent="gold"] {
  --accent: #f4d35e;
  --accent-contrast: #111007;
}

body[data-accent="rose"] {
  --accent: #ff4f6d;
  --accent-contrast: #fff4f6;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  scrollbar-width: none;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(57, 217, 138, 0.08), transparent 360px),
    linear-gradient(180deg, rgba(72, 199, 216, 0.055), transparent 340px),
    linear-gradient(140deg, rgba(255, 79, 109, 0.035), transparent 520px),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  scrollbar-width: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
*::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.greeting-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at center, rgba(57, 217, 138, 0.18), transparent 260px),
    rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(8px);
  animation: overlayOut 1050ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.greeting-card {
  width: min(360px, 100%);
  padding: 24px;
  text-align: center;
  background: rgba(23, 26, 25, 0.76);
  border: 1px solid rgba(216, 209, 195, 0.14);
  border-radius: 8px;
  box-shadow: var(--shadow);
  animation: greetingIn 620ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.greeting-mark {
  display: inline-grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin-bottom: 12px;
  color: var(--accent-contrast);
  background: var(--accent);
  border-radius: 8px;
  font-weight: 860;
  animation: markPulse 620ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.greeting-card h2 {
  margin: 6px 0;
  font-size: 1.65rem;
}

.greeting-card p:last-child {
  margin: 0;
  color: var(--soft);
}

.auth-screen {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 520px);
  min-height: 100vh;
  background: var(--bg);
}

.auth-visual {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
}

.auth-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(16, 17, 17, 0.2), rgba(16, 17, 17, 0.78));
}

.auth-visual img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  filter: saturate(0.78) contrast(1.08) brightness(0.7);
}

.auth-card {
  align-self: center;
  width: min(100%, 460px);
  margin: 0 auto;
  padding: 34px;
  background: rgba(24, 26, 26, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  animation: cardIn 520ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.auth-card h1 {
  margin: 8px 0 0;
  font-size: 2.4rem;
  line-height: 1;
}

.domain-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  margin: 12px 0 0;
  padding: 0 10px;
  color: var(--accent-contrast);
  background: var(--accent);
  border-radius: 8px;
  font-weight: 780;
}

.auth-copy {
  margin: 14px 0 22px;
  color: var(--soft);
  line-height: 1.55;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.auth-tabs button {
  min-height: 42px;
  color: var(--muted);
  background: #121414;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 760;
}

.auth-tabs button.is-selected {
  color: var(--accent-contrast);
  background: var(--accent);
  border-color: var(--accent);
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-form label {
  display: grid;
  gap: 8px;
}

.auth-form span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 730;
}

.auth-message {
  min-height: 22px;
  margin: 0;
  color: #ffd5dc;
  line-height: 1.45;
}

button,
input,
textarea,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(210px, 260px) minmax(0, 1fr);
  min-height: 100vh;
}

.app-shell.welcome-enter .section-card,
.app-shell.welcome-enter .session-panel,
.app-shell.welcome-enter .history-panel {
  animation: cardIn 520ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 100vh;
  padding: 24px 18px;
  background: linear-gradient(180deg, rgba(16, 17, 17, 0.58), rgba(16, 17, 17, 0.22));
  border-right: 1px solid rgba(216, 209, 195, 0.08);
}

.brand {
  display: block;
  min-width: 0;
}

.brand h1,
.toolbar h2,
.drawer-header h2 {
  margin: 2px 0 0;
  line-height: 1.04;
}

.brand h1 {
  font-size: 1.56rem;
  letter-spacing: 0;
}

.toolbar h2,
.drawer-header h2 {
  font-size: 1.55rem;
}

.eyebrow {
  margin: 0;
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 760;
  text-transform: uppercase;
}

.workspace-menu,
.settings-panel,
.import-panel,
.stats-panel,
.study-tools,
.danger-menu {
  background: rgba(24, 27, 26, 0.54);
  border: 1px solid rgba(216, 209, 195, 0.1);
  border-radius: 8px;
}

.workspace-menu summary,
.settings-panel summary,
.import-panel summary,
.stats-panel summary,
.study-tools summary,
.danger-menu summary {
  cursor: pointer;
  list-style: none;
  font-weight: 780;
}

.workspace-menu summary::-webkit-details-marker,
.settings-panel summary::-webkit-details-marker,
.import-panel summary::-webkit-details-marker,
.stats-panel summary::-webkit-details-marker,
.study-tools summary::-webkit-details-marker,
.danger-menu summary::-webkit-details-marker {
  display: none;
}

.workspace-menu > summary {
  position: relative;
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 0 14px 0 46px;
}

.workspace-menu > summary::before {
  content: "";
  position: absolute;
  left: 14px;
  width: 18px;
  height: 12px;
  background:
    linear-gradient(var(--text), var(--text)) 0 0 / 18px 2px no-repeat,
    linear-gradient(var(--text), var(--text)) 0 5px / 18px 2px no-repeat,
    linear-gradient(var(--text), var(--text)) 0 10px / 18px 2px no-repeat;
}

.workspace-menu-content {
  display: grid;
  gap: 10px;
  padding: 0 10px 10px;
}

.stats-panel,
.study-tools {
  padding: 10px;
}

.stats-panel > summary,
.study-tools > summary,
.settings-panel > summary,
.import-panel > summary,
.danger-menu > summary {
  min-height: 34px;
  display: flex;
  align-items: center;
  color: var(--soft);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stats div {
  min-width: 0;
  padding: 12px 10px;
  background: rgba(12, 14, 14, 0.46);
  border-right: 1px solid var(--line);
}

.stats div:last-child {
  border-right: 0;
}

.stats span {
  display: block;
  font-size: 1.18rem;
  font-weight: 780;
}

.stats small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.76rem;
}

.actions,
.form-actions,
.drawer-actions {
  display: flex;
  gap: 10px;
}

.actions {
  flex-direction: column;
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button {
  min-height: 40px;
  border-radius: 8px;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, color 140ms ease, opacity 140ms ease;
}

.primary-button {
  border: 1px solid color-mix(in srgb, var(--accent), transparent 36%);
  color: var(--accent-contrast);
  background: var(--accent);
  font-weight: 760;
  padding: 0 16px;
}

.ghost-button,
.icon-button {
  border: 1px solid rgba(216, 209, 195, 0.12);
  color: var(--text);
  background: rgba(32, 37, 35, 0.62);
  padding: 0 16px;
}

.danger-button {
  border: 1px solid rgba(255, 79, 109, 0.52);
  color: #ffd5dc;
  background: rgba(255, 79, 109, 0.11);
  padding: 0 16px;
}

.primary-button:hover,
.ghost-button:hover,
.danger-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.64;
  transform: none !important;
}

.settings-panel {
  padding: 0 12px;
}

.settings-grid {
  display: grid;
  gap: 12px;
  padding-bottom: 12px;
}

.settings-grid label {
  display: grid;
  gap: 7px;
}

.settings-grid span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 730;
}

.toggle-setting {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.toggle-setting input {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

.account-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: rgba(18, 20, 20, 0.74);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.import-panel {
  padding: 0 12px;
}

.import-form {
  display: grid;
  gap: 10px;
  padding-bottom: 12px;
}

.import-form label {
  display: grid;
  gap: 7px;
}

.import-form span,
.small-message {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 730;
}

.small-message {
  min-height: 18px;
  margin: 0;
  line-height: 1.4;
}

.account-box span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 730;
}

.account-box strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.account-box .ghost-button {
  min-height: 36px;
}

.main-panel {
  min-width: 0;
  max-width: 1160px;
  width: 100%;
  justify-self: center;
  padding: 28px clamp(18px, 3vw, 42px);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.toolbar-heading h2 {
  font-size: clamp(1.5rem, 2.4vw, 2.2rem);
}

.toolbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.toolbar-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(120px, auto) minmax(124px, auto);
  gap: 8px;
  align-items: center;
  width: 100%;
}

.filter-strip {
  position: sticky;
  top: 16px;
  z-index: 4;
  margin-bottom: 18px;
  padding: 7px;
  background: rgba(23, 26, 25, 0.68);
  border: 1px solid rgba(216, 209, 195, 0.09);
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(14px);
}

.search-field,
.select-field,
.add-form label,
.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.search-field span,
.select-field span,
.add-form label span,
.label-with-info,
.field-title {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 730;
}

.label-with-info {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.info-popover {
  position: relative;
  display: inline-block;
}

.info-popover summary {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: var(--accent-contrast);
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 860;
  list-style: none;
}

.info-popover summary::-webkit-details-marker {
  display: none;
}

.info-popover[open] {
  z-index: 4;
}

.info-card {
  position: absolute;
  right: 0;
  width: min(320px, 76vw);
  margin: 8px 0 0;
  padding: 12px;
  color: var(--soft);
  background: #121414;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  line-height: 1.45;
}

.info-card p {
  margin: 0;
}

.info-card p + p {
  margin-top: 8px;
}

input,
textarea,
select {
  width: 100%;
  color: var(--text);
  background: rgba(18, 20, 20, 0.78);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 12px;
  line-height: 1.5;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(72, 199, 216, 0.13);
}

.search-field {
  width: 100%;
}

.select-field {
  width: 100%;
}

.filter-strip input,
.filter-strip select {
  min-height: 38px;
  border-color: rgba(216, 209, 195, 0.08);
  background: rgba(12, 14, 14, 0.42);
}

.filter-strip select {
  font-weight: 740;
}

.study-tools {
  background: rgba(24, 27, 26, 0.7);
}

.study-tools > summary {
  color: var(--muted);
}

.study-tools[open] > summary {
  margin-bottom: 12px;
}

.session-panel,
.history-panel {
  padding: 12px;
  background: rgba(18, 20, 20, 0.58);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.session-panel {
  display: grid;
  gap: 12px;
}

.session-copy h2,
.history-header h2 {
  margin: 4px 0 0;
  font-size: 1rem;
}

.session-copy p:last-child {
  margin: 8px 0 0;
  color: var(--soft);
  line-height: 1.45;
}

.session-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.session-stats div {
  padding: 10px;
  background: rgba(12, 14, 14, 0.58);
  border-right: 1px solid var(--line);
}

.session-stats div:last-child {
  border-right: 0;
}

.session-stats span {
  display: block;
  font-size: 1.05rem;
  font-weight: 780;
}

.session-stats small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.history-panel {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.history-grid {
  display: grid;
  gap: 8px;
}

.history-card,
.history-empty {
  margin: 0;
  padding: 10px;
  background: rgba(12, 14, 14, 0.58);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.history-card {
  display: grid;
  gap: 5px;
}

.history-card span,
.history-empty {
  color: var(--muted);
}

.add-panel {
  margin-bottom: 20px;
  padding: 16px;
  background: rgba(24, 27, 26, 0.72);
  border: 1px solid rgba(216, 209, 195, 0.11);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
}

.add-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 14px;
}

.preview-row {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
}

.preview-row strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
}

.section-list {
  display: grid;
  gap: 12px;
}

.section-card {
  background:
    linear-gradient(180deg, rgba(31, 36, 34, 0.58), rgba(19, 22, 21, 0.5));
  border: 1px solid rgba(216, 209, 195, 0.08);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.14);
}

.section-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 15px 16px 7px;
}

.section-title {
  min-width: 0;
}

.section-title h3 {
  margin: 4px 0 0;
  font-size: 1.12rem;
  overflow-wrap: anywhere;
}

.section-details {
  max-width: 760px;
  margin: 7px 0 0;
  color: var(--soft);
  line-height: 1.44;
  overflow-wrap: anywhere;
}

.section-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0 9px;
  color: var(--soft);
  background: rgba(12, 14, 14, 0.48);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.76rem;
  white-space: nowrap;
}

.category-pill {
  color: var(--accent-contrast);
  background: var(--accent);
  border-color: color-mix(in srgb, var(--accent), transparent 28%);
  font-weight: 760;
}

.session-pill {
  color: #07110b;
  background: var(--yellow);
  border-color: rgba(244, 211, 94, 0.72);
  font-weight: 760;
}

.section-controls {
  display: flex;
  gap: 8px;
  align-items: start;
  opacity: 0;
  transition: opacity 140ms ease;
}

.section-card:hover .section-controls,
.section-card:focus-within .section-controls {
  opacity: 0.78;
}

.section-controls button {
  min-height: 32px;
  padding: 0 10px;
  color: var(--muted);
  background: rgba(12, 14, 14, 0.52);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.problem-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--problem-size, 58px), 1fr));
  gap: 8px;
  padding: 10px 16px 15px;
}

.problem-button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--problem-height, 48px);
  color: var(--text);
  background: rgba(12, 14, 14, 0.42);
  border: 1px solid rgba(216, 209, 195, 0.09);
  border-radius: 8px;
  font-weight: 780;
  overflow: hidden;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

body[data-density="compact"] {
  --problem-size: 48px;
  --problem-height: 42px;
}

body[data-density="large"] {
  --problem-size: 72px;
  --problem-height: 58px;
}

.problem-button:hover {
  transform: translateY(-1px);
  border-color: rgba(216, 209, 195, 0.24);
}

.problem-button::after {
  content: "";
  position: absolute;
  inset: auto 7px 6px;
  height: 3px;
  background: var(--line);
  border-radius: 3px;
}

.problem-button[data-level="1"] {
  border-color: rgba(57, 217, 138, 0.62);
  background: rgba(57, 217, 138, 0.13);
}

.problem-button[data-level="1"]::after {
  background: var(--green);
}

.problem-button[data-level="2"] {
  border-color: rgba(184, 227, 95, 0.58);
  background: rgba(184, 227, 95, 0.12);
}

.problem-button[data-level="2"]::after {
  background: var(--lime);
}

.problem-button[data-level="3"] {
  border-color: rgba(244, 211, 94, 0.58);
  background: rgba(244, 211, 94, 0.12);
}

.problem-button[data-level="3"]::after {
  background: var(--yellow);
}

.problem-button[data-level="4"] {
  border-color: rgba(255, 138, 91, 0.62);
  background: rgba(255, 138, 91, 0.12);
}

.problem-button[data-level="4"]::after {
  background: var(--coral);
}

.problem-button[data-level="5"] {
  border-color: rgba(255, 79, 109, 0.66);
  background: rgba(255, 79, 109, 0.13);
}

.problem-button[data-level="5"]::after {
  background: var(--red);
}

.problem-button.is-session-rated {
  box-shadow: 0 0 0 2px rgba(72, 199, 216, 0.28);
}

.problem-button.is-just-rated {
  animation: ratingPop 760ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.comment-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  background: var(--cyan);
  border-radius: 50%;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 300px;
  padding: 36px 20px;
  text-align: center;
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.empty-state h3,
.empty-state p {
  margin: 0;
}

.empty-state p {
  max-width: 360px;
  color: var(--muted);
  line-height: 1.5;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(0, 0, 0, 0.5);
  animation: fadeIn 160ms ease both;
}

.problem-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 11;
  display: flex;
  flex-direction: column;
  gap: 22px;
  width: min(430px, 100%);
  height: 100vh;
  padding: 24px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: drawerIn 240ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.drawer-header {
  display: flex;
  gap: 16px;
  align-items: start;
  justify-content: space-between;
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 1.05rem;
}

.difficulty-options {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.difficulty-options button {
  min-height: 58px;
  color: var(--text);
  background: #121414;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 760;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.difficulty-options button:hover {
  transform: translateY(-2px);
}

.difficulty-options button[data-level="1"] {
  border-color: rgba(57, 217, 138, 0.66);
}

.difficulty-options button[data-level="2"] {
  border-color: rgba(184, 227, 95, 0.66);
}

.difficulty-options button[data-level="3"] {
  border-color: rgba(244, 211, 94, 0.66);
}

.difficulty-options button[data-level="4"] {
  border-color: rgba(255, 138, 91, 0.68);
}

.difficulty-options button[data-level="5"] {
  border-color: rgba(255, 79, 109, 0.7);
}

.difficulty-options .clear-difficulty {
  border-color: rgba(216, 209, 195, 0.42);
}

.difficulty-options button.is-selected {
  color: var(--accent-contrast);
  background: var(--accent);
  border-color: var(--accent);
  animation: ratingPop 360ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.difficulty-options .clear-difficulty.is-selected {
  color: var(--text);
  background: var(--panel-2);
  border-color: var(--soft);
}

.difficulty-options button.is-selected[data-level="2"] {
  background: var(--lime);
  border-color: var(--lime);
}

.difficulty-options button.is-selected[data-level="3"] {
  background: var(--yellow);
  border-color: var(--yellow);
}

.difficulty-options button.is-selected[data-level="4"] {
  background: var(--coral);
  border-color: var(--coral);
}

.difficulty-options button.is-selected[data-level="5"] {
  color: #fff4f6;
  background: var(--red);
  border-color: var(--red);
}

.drawer-actions {
  margin-top: auto;
  justify-content: space-between;
  align-items: end;
}

.drawer-save-actions {
  display: flex;
  gap: 10px;
  order: -1;
}

.danger-menu {
  position: relative;
  min-width: 92px;
  background: transparent;
}

.danger-menu summary {
  min-height: 42px;
  justify-content: center;
  padding: 0 12px;
  color: var(--muted);
  background: var(--panel-2);
  border-radius: 8px;
}

.danger-menu .danger-button {
  position: absolute;
  right: 0;
  bottom: 50px;
  width: 180px;
  z-index: 3;
  box-shadow: var(--shadow);
}

.is-hidden {
  display: none !important;
}

body[data-motion="off"] *,
body[data-motion="off"] *::before,
body[data-motion="off"] *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes greetingIn {
  0% {
    opacity: 0;
    filter: blur(10px);
    transform: translateY(12px) scale(0.94);
  }
  62% {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0) scale(1.03);
  }
  100% {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0) scale(1);
  }
}

@keyframes overlayOut {
  0%,
  64% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes markPulse {
  0% {
    transform: rotate(-8deg) scale(0.84);
  }
  55% {
    transform: rotate(2deg) scale(1.06);
  }
  100% {
    transform: rotate(0) scale(1);
  }
}

@keyframes ratingPop {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent), transparent 38%);
  }
  45% {
    transform: scale(1.08);
    box-shadow: 0 0 0 8px color-mix(in srgb, var(--accent), transparent 86%);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 transparent;
  }
}

@keyframes drawerIn {
  from {
    transform: translateX(22px);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (max-width: 920px) {
  .auth-screen {
    grid-template-columns: 1fr;
  }

  .auth-visual {
    display: none;
  }

  .auth-card {
    align-self: center;
    margin: 18px auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 16;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    min-height: auto;
    gap: 12px;
    border-right: 0;
    border-bottom: 1px solid rgba(216, 209, 195, 0.08);
    background: rgba(16, 17, 17, 0.78);
    backdrop-filter: blur(16px);
  }

  .brand {
    min-width: 0;
  }

  .brand h1 {
    font-size: 1.22rem;
    overflow-wrap: anywhere;
  }

  .workspace-menu {
    position: relative;
    justify-self: end;
    background: transparent;
    border: 0;
  }

  .workspace-menu > summary {
    width: 44px;
    min-height: 40px;
    padding: 0;
    font-size: 0;
    background: rgba(24, 27, 26, 0.78);
    border: 1px solid rgba(216, 209, 195, 0.13);
    border-radius: 8px;
  }

  .workspace-menu > summary::before {
    left: 50%;
    transform: translateX(-50%);
  }

  .workspace-menu-content {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: min(340px, calc(100vw - 28px));
    max-height: calc(100dvh - 78px);
    overflow: auto;
    padding: 10px;
    background: rgba(17, 19, 18, 0.96);
    border: 1px solid rgba(216, 209, 195, 0.13);
    border-radius: 8px;
    box-shadow: var(--shadow);
  }

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

  .toolbar-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .search-field {
    grid-column: 1 / -1;
  }

  .toolbar-actions {
    align-items: stretch;
  }

  .toolbar-actions button {
    width: 100%;
  }

  .search-field,
  .select-field {
    width: 100%;
  }

  .filter-strip {
    position: static;
    margin-bottom: 14px;
    padding: 6px;
    box-shadow: none;
  }

  .stats-panel {
    display: none;
  }
}

@media (max-width: 640px) {
  body {
    overflow-x: hidden;
  }

  .auth-screen {
    padding: 14px;
  }

  .auth-card {
    padding: 22px;
  }

  .auth-card h1 {
    font-size: 2rem;
  }

  .sidebar,
  .main-panel {
    padding: 14px;
  }

  .sidebar {
    padding: 12px 14px;
  }

  .brand .eyebrow {
    font-size: 0.68rem;
  }

  .brand h1 {
    font-size: 1.12rem;
  }

  .toolbar {
    gap: 10px;
    margin-bottom: 10px;
  }

  .toolbar-heading h2 {
    font-size: 1.62rem;
  }

  .toolbar-actions .primary-button,
  .toolbar-actions .ghost-button {
    min-height: 40px;
  }

  .toolbar-controls {
    gap: 6px;
  }

  .filter-strip input,
  .filter-strip select {
    min-height: 36px;
    padding: 0 10px;
    font-size: 0.9rem;
  }

  .form-grid,
  .section-header {
    grid-template-columns: 1fr;
  }

  .section-controls {
    justify-self: start;
    opacity: 0.72;
  }

  .session-stats,
  .stats {
    grid-template-columns: 1fr;
  }

  .session-stats div,
  .stats div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .session-stats div:last-child,
  .stats div:last-child {
    border-bottom: 0;
  }

  .preview-row,
  .form-actions,
  .drawer-actions,
  .drawer-save-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace-menu-content {
    padding: 10px;
  }

  .account-box {
    grid-template-columns: 1fr;
  }

  .problem-grid {
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 8px;
    padding: 8px 14px 14px;
  }

  .difficulty-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .problem-drawer {
    width: 100%;
    padding: 18px;
  }

  .danger-menu {
    width: 100%;
  }

  .danger-menu .danger-button {
    position: static;
    width: 100%;
    margin-top: 8px;
    box-shadow: none;
  }

  .info-card {
    right: -8px;
  }
}
