:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-soft: #f0f4f3;
  --ink: #18211f;
  --muted: #66706d;
  --line: #dfe5e2;
  --line-strong: #c8d1cd;
  --accent: #0f766e;
  --accent-deep: #0b4f4a;
  --accent-soft: #e4f4f1;
  --warm: #a9432b;
  --warm-soft: #f9e9e3;
  --shadow: 0 18px 45px rgba(24, 33, 31, 0.1);
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

button {
  border: 0;
}

.signin-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.signin-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 30px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}

.signin-card h1,
.signin-card p {
  margin: 0;
}

.signin-card h1 {
  font-size: 28px;
  line-height: 1.15;
}

.signin-card > p {
  color: var(--muted);
}

.auth-error {
  min-height: 20px;
  color: var(--warm);
  font-size: 13px;
  font-weight: 700;
}

.auth-hint {
  color: var(--muted);
  font-size: 12px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 12px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-family: Georgia, serif;
  font-size: 22px;
  font-weight: 700;
}

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

.brand h1 {
  font-size: 18px;
  font-weight: 700;
}

.brand p {
  color: var(--muted);
  font-size: 12px;
}

.categories {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.categories button {
  width: 100%;
  min-height: 58px;
  border-radius: 8px;
  background: transparent;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 10px;
  align-items: center;
}

.categories button:hover {
  background: var(--panel-soft);
}

.categories button.active {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.categories button strong {
  font-size: 14px;
  font-weight: 700;
}

.categories button span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
}

.nav-count {
  min-width: 26px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.categories button.active .nav-count {
  border-color: transparent;
  background: #fff;
  color: var(--accent-deep);
}

.user-panel {
  border-bottom: 1px solid var(--line);
  padding: 0 8px 16px;
  display: grid;
  gap: 10px;
}

.user-panel strong,
.user-panel p {
  margin: 0;
}

.user-panel strong {
  font-size: 13px;
}

.user-panel p {
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

.profile-btn {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.profile-btn span {
  font-weight: 800;
}

.profile-btn small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.profile-btn.warning {
  border-color: #f6c76d;
  background: #fff8e8;
}

.profile-btn.warning small {
  color: #9a5b00;
}

.content {
  width: min(1180px, 100%);
  padding: 32px 36px 64px;
}

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

.content-head h2,
.content-head p {
  margin: 0;
}

.content-head h2 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.1;
  font-weight: 800;
}

.content-head p {
  margin-top: 6px;
  color: var(--muted);
}

.add-btn,
.ghost-btn,
.detail-actions button,
.form-actions button {
  min-height: 40px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.add-btn {
  background: var(--accent);
  color: #fff;
  padding: 0 18px;
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.18);
}

.add-btn:hover {
  background: var(--accent-deep);
}

.drive-warning {
  border: 1px solid #f6c76d;
  border-radius: 8px;
  background: #fff8e8;
  color: #744200;
  padding: 10px 12px;
  margin-bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 13px;
}

.drive-warning[hidden] {
  display: none;
}

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

.summary-grid[hidden],
.toolbar[hidden],
.results-row[hidden],
.add-btn[hidden] {
  display: none;
}

.summary-tile {
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.summary-tile span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.summary-tile strong {
  font-size: 30px;
  line-height: 1;
}

.toolbar {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.toolbar label,
.form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#bolsField {
  position: relative;
}

.bol-mark-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-start;
}

.inline-tool {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--accent-deep);
  padding: 3px 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.inline-tool:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.inline-tool.danger-tool {
  color: var(--warm);
}

.inline-tool.danger-tool:hover {
  border-color: var(--warm);
  background: var(--warm-soft);
}

.toolbar label {
  min-width: 150px;
  flex: 0 1 180px;
}

.toolbar .search-box {
  min-width: min(100%, 240px);
  flex: 1 1 260px;
}

.toolbar label[hidden] {
  display: none;
}

.toolbar label > span,
.form label > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.toolbar input,
.toolbar select,
.form input,
.form textarea,
.form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  outline: none;
}

.toolbar input,
.toolbar select {
  height: 42px;
  padding: 0 12px;
}

.toolbar input:focus,
.toolbar select:focus,
.form input:focus,
.form textarea:focus,
.form select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.ghost-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  padding: 0 14px;
}

.ghost-btn:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.results-row {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.results-row p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}

.card {
  min-height: 250px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-media-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: flex-end;
}

.media-badge {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 800;
}

.media-badge.video {
  background: #dbeafe;
  color: #1d4ed8;
}

.media-badge.padhant {
  background: #fce7f3;
  color: #be185d;
}

.card-cat {
  color: var(--accent-deep);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.card-title {
  min-height: 48px;
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
  font-weight: 800;
}

.card-bols,
.detail-bols {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  white-space: pre-wrap;
}

.card-bols {
  max-height: 98px;
  overflow: hidden;
  padding: 10px;
  color: #273431;
  font-size: 13px;
}

.card-written-bols {
  max-height: 112px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.card-written-bols .written-bol-preview {
  border: 0;
  border-radius: 0;
  background:
    repeating-linear-gradient(
      to bottom,
      #fff 0,
      #fff 21px,
      rgba(169, 67, 43, 0.16) 22px,
      #fff 23px,
      #fff 26px
    );
  padding: 0 8px 6px;
  gap: 0;
  overflow: hidden;
}

.card-written-bols .written-bol-section {
  gap: 0;
}

.card-written-bols .written-bol-row {
  grid-template-columns: 10px minmax(0, 1fr);
  min-height: 26px;
  overflow: hidden;
}

.card-written-bols .written-marker {
  font-size: 10px;
  padding-bottom: 3px;
}

.card-written-bols .written-bol-group {
  font-size: 13px;
  line-height: 1.15;
  max-width: 100%;
  word-spacing: 4px;
}

.card-written-bols .written-bol-inline-row,
.card-written-bols .written-bol-line {
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.card-written-bols .written-bol-inline-row {
  flex-wrap: nowrap;
}

.card-written-bols .written-vibhag {
  border-bottom-width: 2px;
  padding: 0 9px 4px;
}

.card-written-bols .written-vibhag::before,
.card-written-bols .written-vibhag::after {
  bottom: -2px;
  height: calc(100% + 2px);
  width: 2px;
}

.bol-highlight {
  border-radius: 4px;
  background: #fff2a8;
  color: #2f2a12;
  padding: 1px 3px;
}

.bol-note {
  color: var(--muted);
  font-style: italic;
}

.bol-rhythm-mark,
.bol-vibhag-mark {
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 1px 2px;
  padding: 1px 5px;
}

.bol-rhythm-mark small {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.bol-vibhag-mark {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
}

.bol-rhythm-mark .bol-vibhag-mark {
  color: var(--ink);
}

.bol-rhythm-mark.bol-sam .bol-vibhag-mark {
  border-color: rgba(255, 255, 255, 0.45);
}

.bol-rhythm-mark.bol-tali .bol-vibhag-mark,
.bol-rhythm-mark.bol-khali .bol-vibhag-mark {
  border-color: var(--line-strong);
}

.bol-rhythm-mark.bol-sam {
  background: var(--accent-deep);
  color: #fff;
}

.bol-rhythm-mark.bol-tali {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.bol-rhythm-mark.bol-khali {
  background: #f3f4f6;
  color: var(--muted);
}

.card-notes {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.card-class-meta {
  margin: -4px 0 0;
  color: var(--accent-deep);
  font-size: 12px;
  font-weight: 800;
}

.reference-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.reference-chip {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfb;
  color: var(--ink);
  padding: 7px 9px;
  cursor: pointer;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  text-align: left;
}

.reference-chip span {
  font-size: 12px;
  font-weight: 800;
}

.reference-chip small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.reference-chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.card-references {
  margin-top: 2px;
}

.card-meta,
.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.card-meta {
  margin-top: auto;
  padding-top: 4px;
}

.tag {
  max-width: 100%;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
}

.tag.gharana {
  border: 1px solid var(--line-strong);
  background: #eef2f5;
  color: #334155;
}

.tag.gharana-jaipur {
  border-color: #c7d2fe;
  background: #eef2ff;
  color: #3730a3;
}

.tag.gharana-lucknow {
  border-color: #bbf7d0;
  background: #ecfdf3;
  color: #166534;
}

.tag.gharana-general {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #9a3412;
}

.tag.taal {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
}

.empty {
  grid-column: 1 / -1;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.65);
  padding: 56px 20px;
  text-align: center;
}

.empty h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.empty p {
  margin: 0;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(24, 33, 31, 0.48);
  padding: 20px;
}

.modal[hidden] {
  display: none;
}

.modal-card {
  position: relative;
  width: min(620px, 100%);
  max-height: 90vh;
  overflow: auto;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(10, 18, 16, 0.28);
  padding: 28px;
}

.modal-card.detail-card {
  width: min(1180px, 100%);
}

.modal-card.editor-card {
  width: min(920px, 100%);
}

.modal-card.profile-card {
  width: min(620px, 100%);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.modal-close:hover {
  background: var(--panel-soft);
  color: var(--ink);
}

.modal-card h3 {
  margin: 0 42px 20px 0;
  font-size: 22px;
}

.profile-section {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 16px;
  display: grid;
  gap: 10px;
}

.profile-section h4,
.profile-section p {
  margin: 0;
}

.profile-section h4 {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.drive-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: end;
}

.drive-actions label {
  grid-column: 1 / -1;
  display: grid;
  gap: 5px;
}

.drive-actions label > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.drive-actions input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 9px 10px;
  outline: none;
}

.drive-actions input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.detail-cat {
  color: var(--accent-deep);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-title {
  margin: 0;
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1.15;
}

.detail-heading {
  margin: 6px 42px 6px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.detail-heading button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent-deep);
  cursor: pointer;
  font-weight: 800;
  padding: 0 14px;
}

.detail-heading button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.detail-sub {
  color: var(--muted);
  font-size: 14px;
}

.detail-section {
  margin-top: 22px;
}

.detail-section h4 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-bols {
  padding: 14px;
  font-size: 14px;
  line-height: 1.65;
}

.metronome-toggle {
  min-height: 36px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  padding: 0 14px;
}

.metronome-toggle:hover {
  background: var(--accent-deep);
}

.bol-preview-practice {
  display: grid;
  gap: 10px;
}

.bol-preview-metronome {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.bol-preview-metronome label {
  display: grid;
  gap: 4px;
}

.bol-preview-metronome label span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.bol-preview-metronome input {
  width: 88px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 10px;
}

.bol-preview-metronome strong {
  min-height: 36px;
  color: var(--accent-deep);
  display: inline-flex;
  align-items: center;
  font-size: 13px;
}


.detail-notes {
  margin: 0;
  white-space: pre-wrap;
}

.detail-video iframe,
.detail-video video {
  width: 100%;
  border: 0;
  border-radius: 8px;
  display: block;
}

.detail-video iframe {
  aspect-ratio: 16 / 9;
}

.detail-video a {
  color: var(--accent);
  word-break: break-all;
}

.riyaz-video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.riyaz-video-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
  display: grid;
}

.riyaz-video-frame iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  display: block;
}

.riyaz-video-frame a {
  color: var(--accent);
  display: block;
  padding: 14px;
  word-break: break-all;
}

.riyaz-video-copy {
  padding: 14px;
  display: grid;
  gap: 10px;
}

.riyaz-video-copy h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.25;
}

.riyaz-log-view {
  grid-column: 1 / -1;
  display: grid;
  gap: 16px;
}

.riyaz-calendar {
  display: grid;
  grid-template-columns: minmax(0, 0.86fr) minmax(280px, 1.28fr) minmax(0, 0.86fr);
  gap: 12px;
  align-items: stretch;
}

.riyaz-day-card,
.riyaz-summary-panel,
.riyaz-month-panel,
.riyaz-video-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.riyaz-day-card {
  min-height: 250px;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.riyaz-day-card.is-today {
  min-height: 318px;
  border-color: rgba(15, 118, 110, 0.35);
  box-shadow: 0 18px 45px rgba(15, 118, 110, 0.12);
  padding: 18px;
}

.riyaz-day-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.riyaz-day-head span,
.riyaz-metrics span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.riyaz-day-head strong {
  font-size: 14px;
  text-align: right;
}

.riyaz-day-metric {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.riyaz-day-metric strong {
  font-size: 42px;
  line-height: 1;
}

.riyaz-day-card.is-today .riyaz-day-metric strong {
  font-size: 58px;
}

.riyaz-day-metric span,
.muted-entry {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.riyaz-entry-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.riyaz-entry-list li {
  border-top: 1px solid var(--line);
  padding-top: 6px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.riyaz-entry-list strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.riyaz-entry-list span {
  color: var(--accent-deep);
  font-size: 12px;
  font-weight: 900;
}

.riyaz-entry-list button {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.riyaz-entry-list button:hover {
  background: var(--warm-soft);
  color: var(--warm);
}

.riyaz-summary-panel,
.riyaz-month-panel,
.riyaz-video-section {
  padding: 16px;
  display: grid;
  gap: 14px;
}

.riyaz-month-panel {
  overflow-x: auto;
}

.riyaz-panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.riyaz-panel-head h3,
.riyaz-panel-head p {
  margin: 0;
}

.riyaz-panel-head h3 {
  font-size: 18px;
}

.riyaz-panel-head p {
  color: var(--muted);
  font-size: 13px;
}

.riyaz-range {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 3px;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.riyaz-range button {
  min-height: 32px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  padding: 0 10px;
}

.riyaz-range button.active,
.riyaz-range button:hover {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.month-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
}

.month-controls strong {
  min-width: 150px;
  text-align: center;
  font-size: 15px;
}

.month-controls button {
  min-width: 34px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--accent-deep);
  cursor: pointer;
  font-weight: 900;
  padding: 0 10px;
}

.month-controls button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.month-weekdays,
.riyaz-month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  min-width: 720px;
}

.month-weekdays {
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: #fbfcfc;
}

.month-weekdays span {
  min-height: 34px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.riyaz-month-grid {
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.riyaz-month-day {
  min-height: 128px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
  padding: 8px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 6px;
  cursor: pointer;
}

.riyaz-month-day:hover {
  background: #fbfcfc;
}

.riyaz-month-day.is-outside {
  background: #f5f7f7;
  color: var(--muted);
}

.riyaz-month-day.is-current-day {
  box-shadow: inset 0 0 0 2px rgba(15, 118, 110, 0.45);
}

.riyaz-month-day.is-selected-day {
  background: #f0f7f6;
}

.riyaz-month-day.is-current-day.is-selected-day {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.month-day-number {
  display: flex;
  justify-content: flex-end;
}

.month-day-number span {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 900;
}

.riyaz-month-day.is-current-day .month-day-number span {
  background: var(--accent);
  color: #fff;
}

.month-day-events {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.calendar-chip {
  width: 100%;
  min-height: 26px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
  overflow: hidden;
  padding: 4px 7px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-chip.class-chip {
  background: #eef2ff;
  color: #3730a3;
}

.calendar-chip.riyaz-chip {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.calendar-chip:hover {
  filter: brightness(0.97);
}

.month-day-events small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-agenda {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  padding: 12px;
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
  min-width: 720px;
}

.calendar-agenda > div:first-child {
  display: grid;
  align-content: start;
  gap: 4px;
}

.calendar-agenda span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.calendar-agenda strong {
  font-size: 14px;
}

.agenda-list {
  display: grid;
  gap: 8px;
}

.agenda-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  text-align: left;
  display: grid;
  gap: 3px;
}

button.agenda-item {
  cursor: pointer;
}

button.agenda-item:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.agenda-item small,
.agenda-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.agenda-kind {
  width: fit-content;
  border-radius: 999px;
  padding: 2px 7px;
}

.agenda-kind.class-kind {
  background: #eef2ff;
  color: #3730a3;
}

.agenda-kind.riyaz-kind {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.calendar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.calendar-legend i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.class-dot {
  background: #6366f1;
}

.riyaz-dot {
  background: var(--accent);
}

.riyaz-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.riyaz-metrics div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  padding: 12px;
  display: grid;
  gap: 2px;
}

.riyaz-metrics strong {
  font-size: 30px;
  line-height: 1;
}

.riyaz-metrics small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.riyaz-form {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  display: grid;
  grid-template-columns: 150px minmax(220px, 1fr) 120px auto;
  gap: 10px;
  align-items: start;
}

.riyaz-form input,
.riyaz-minutes-field {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  outline: none;
}

.riyaz-form input {
  padding: 10px 12px;
}

.riyaz-minutes-field {
  height: 44px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  overflow: hidden;
}

.riyaz-minutes-field input {
  height: 100%;
  border: 0;
  border-radius: 0;
  min-width: 0;
  padding-right: 4px;
}

.riyaz-minutes-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  padding: 0 12px 0 4px;
  text-transform: uppercase;
}

.riyaz-form > input:focus,
.riyaz-minutes-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.detail-actions {
  display: flex;
  gap: 8px;
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.bol-editor-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  padding: 12px;
  display: grid;
  gap: 14px;
}

.bol-editor-preview[hidden] {
  display: none;
}

.bol-preview-section h4 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.written-bol-preview {
  border: 0;
  border-radius: 8px;
  background:
    repeating-linear-gradient(
      to bottom,
      #fff 0,
      #fff 35px,
      rgba(169, 67, 43, 0.16) 36px,
      #fff 37px,
      #fff 42px
    );
  padding: 0 22px 10px;
  display: grid;
  gap: 0;
}

.written-bol-section {
  display: grid;
  gap: 0;
}

.written-bol-section h5 {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.written-bol-row {
  min-height: 42px;
  display: grid;
  grid-template-columns: 26px minmax(0, max-content);
  gap: 12px;
  align-items: end;
  overflow-x: auto;
  overflow-y: hidden;
}

.written-marker {
  color: var(--ink);
  font-family: "Comic Sans MS", "Segoe Print", "Bradley Hand ITC", cursive;
  font-size: 18px;
  line-height: 1;
  min-height: 18px;
  padding-bottom: 5px;
  text-align: center;
}

.written-bol-group {
  color: #202423;
  font-family: "Segoe Print", "Comic Sans MS", "Bradley Hand ITC", cursive;
  font-size: 20px;
  font-style: italic;
  line-height: 1.2;
  word-spacing: 11px;
  display: inline-block;
}

.written-bol-segment {
  display: inline-flex;
  align-items: flex-end;
}

.written-inline-marker {
  position: absolute;
  left: 0;
  bottom: 1px;
  color: var(--ink);
  font-family: "Comic Sans MS", "Segoe Print", "Bradley Hand ITC", cursive;
  font-size: 15px;
  line-height: 1;
  text-align: center;
  width: 18px;
}

.written-bol-group.has-written-marker {
  position: relative;
  padding-left: 16px;
}

.written-bol-note {
  color: var(--muted);
  font-size: 16px;
  font-style: italic;
  word-spacing: 4px;
}

.written-vibhag.has-written-marker .written-inline-marker {
  left: 18px;
}

.written-vibhag.has-written-marker {
  padding-left: 34px;
}

.written-bol-inline-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 16px;
  align-items: flex-end;
  width: max-content;
}

.written-bol-line {
  display: block;
  width: max-content;
}

.written-bol-part {
  display: inline-block;
}

.written-bol-word {
  border-radius: 6px;
}

.written-bol-word.is-current-written-bol {
  background: #fff2a8;
  box-shadow: inset 0 0 0 2px #d9a900;
  color: #2f2a12;
}

.written-vibhag.is-current-written-vibhag {
  background: #fff2a8;
  box-shadow: inset 0 0 0 2px #d9a900;
  color: #2f2a12;
}

.written-bol-highlight {
  border-radius: 6px;
  background: rgba(255, 224, 105, 0.7);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  padding: 0 5px 2px;
}

.written-vibhag {
  padding: 0 18px 7px;
  position: relative;
}

.written-vibhag {
  border-bottom: 2px solid #202423;
}

.written-vibhag::before,
.written-vibhag::after {
  background: #202423;
  bottom: -2px;
  content: "";
  height: calc(100% + 2px);
  position: absolute;
  width: 2px;
}

.written-vibhag::before {
  left: 0;
}

.written-vibhag::after {
  right: 0;
}

.written-vibhag.bracket-start::after,
.written-vibhag.bracket-middle::before,
.written-vibhag.bracket-middle::after,
.written-vibhag.bracket-end::before {
  display: none;
}

.detail-actions button {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 0 16px;
}

.detail-actions button:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
}

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

.class-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.class-references-field {
  grid-column: 1 / -1;
}

.class-fields[hidden] {
  display: none;
}

.form input,
.form textarea,
.form select {
  padding: 10px 12px;
}

.form input[type="file"] {
  border-style: dashed;
  color: var(--muted);
  font-size: 13px;
}

.reference-picker {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.reference-picker-bar {
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
}

.reference-picker-bar input {
  min-height: 36px;
}

.reference-picker-bar span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.reference-checkboxes {
  max-height: 142px;
  overflow: auto;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
}

.reference-checkboxes.is-empty::before {
  color: var(--muted);
  content: attr(data-empty-message);
  font-size: 12px;
  font-weight: 700;
  grid-column: 1 / -1;
  padding: 10px 8px;
}

.reference-checkbox {
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 6px 7px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 7px;
  align-items: center;
  cursor: pointer;
  min-width: 0;
}

.reference-checkbox:hover {
  background: var(--panel-soft);
}

.reference-checkbox.is-filtered-out {
  display: none;
}

.reference-checkbox:has(input:checked) {
  background: #f0f7f1;
  border-color: #9fc9aa;
}

.reference-checkbox input {
  width: 16px;
  height: 16px;
}

.reference-checkbox span {
  font-size: 13px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-checkbox small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.form textarea {
  min-height: 90px;
  resize: vertical;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
}

#bolsField textarea {
  min-height: 320px;
  line-height: 1.55;
  tab-size: 4;
}

.form label > span em {
  font-style: normal;
  font-weight: 500;
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 6px;
}

.form-actions button {
  background: var(--accent);
  color: #fff;
  padding: 0 18px;
}

.form-actions button:hover {
  background: var(--accent-deep);
}

.form-actions button.danger {
  margin-right: auto;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--warm);
}

.form-actions button.danger:hover {
  border-color: var(--warm);
  background: var(--warm-soft);
}

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

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 16px;
  }

  .brand {
    padding: 0 0 12px;
  }

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

  .content {
    padding: 22px 16px 48px;
  }

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

  .drive-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .drive-actions label {
    grid-column: auto;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .riyaz-calendar,
  .riyaz-metrics,
  .riyaz-form {
    grid-template-columns: 1fr;
  }

  .riyaz-panel-head {
    display: grid;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .class-fields {
    grid-template-columns: 1fr;
  }

  .reference-checkboxes {
    grid-template-columns: 1fr;
  }

}

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

  .cards {
    grid-template-columns: 1fr;
  }

  .modal {
    padding: 10px;
  }

  .modal-card {
    padding: 22px 18px;
  }

  .reference-picker-bar {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .reference-picker-bar span {
    white-space: normal;
  }
}
