/* Focused responsive and study-log layer. Loaded after the Clay theme. */
.topbar {
  display: grid;
  grid-template-columns: minmax(150px, 180px) minmax(220px, 430px) minmax(0, 1fr);
  align-items: center;
}

.topbar-search { position: relative; min-width: 0; }
.topbar-search .search-box { width: 100%; }
.topbar-search .search-results { top: calc(100% + 8px); right: auto; left: 0; width: 100%; }
.topbar-actions { min-width: 0; }
.quick-log-button { white-space: nowrap; }

/* Keep expensive SVG effects out of the pointer-move paint path. */
.map-stage.is-dragging .map-viewport { will-change: transform; }
.map-stage.is-dragging .map-node rect,
.map-stage.is-dragging .node-toggle,
.map-stage.is-dragging .status-dot {
  filter: none !important;
  transition: none !important;
}

/* The dark theme previously kept a light mobile navigation surface. */
html[data-theme="dark"] .mobile-bottom-bar {
  background: rgb(48 41 66 / 96%);
  border-color: rgb(216 202 255 / 18%);
  box-shadow: 0 -8px 22px rgb(8 6 15 / 34%), inset 0 1px 0 rgb(216 202 255 / 8%);
}

html[data-theme="dark"] .mobile-bottom-bar button,
html[data-theme="dark"] .mobile-bottom-bar button small,
html[data-theme="dark"] .mobile-bottom-bar button strong { color: #f7f3ff; }

html[data-theme="dark"] .mobile-bottom-bar button.is-active {
  background: var(--clay-violet);
  color: #fff;
  box-shadow: var(--clay-button-shadow);
}

.study-log-dialog {
  width: min(760px, 100%);
  max-height: min(820px, 92vh);
  overflow: auto;
  background: rgb(255 255 255 / 90%);
  border: 1px solid rgb(255 255 255 / 92%);
  border-radius: 24px;
  box-shadow: 22px 22px 46px rgb(29 22 44 / 26%), -12px -12px 28px rgb(255 255 255 / 56%);
  color: var(--clay-ink);
  backdrop-filter: blur(24px);
}

.study-log-form { display: flex; min-height: 0; flex-direction: column; }
.study-log-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 22px 24px; }
.study-log-field { display: flex; min-width: 0; flex-direction: column; gap: 7px; color: var(--clay-muted); font-size: 11px; font-weight: 700; }
.study-log-field--wide { grid-column: 1 / -1; }

.study-log-field input,
.study-log-field select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  color: var(--clay-ink);
  background: var(--clay-recess);
  border: 1px solid rgb(255 255 255 / 84%);
  border-radius: 13px;
  outline: 0;
  box-shadow: var(--clay-recess-shadow);
}

.study-log-field input:focus,
.study-log-field select:focus {
  border-color: rgb(124 58 237 / 35%);
  box-shadow: var(--clay-recess-shadow), 0 0 0 3px rgb(124 58 237 / 10%);
}

.study-log-list-wrap { min-height: 0; padding: 0 24px 18px; border-top: 1px solid rgb(124 58 237 / 11%); }
.study-log-list-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 15px 0 8px; }
.study-log-list-heading small,
.study-log-empty,
.study-log-row small { color: var(--clay-muted); font-size: 10px; }
.study-log-list { max-height: 216px; overflow-y: auto; overscroll-behavior: contain; }

.study-log-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 51px; border-top: 1px solid rgb(124 58 237 / 9%); }
.study-log-row > div { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.study-log-row strong { overflow: hidden; color: var(--clay-ink); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.study-log-delete { width: 34px; min-width: 34px; height: 34px; padding: 0; border-radius: 11px; }
.study-log-empty { padding: 18px 0 10px; text-align: center; }

.study-log-footer {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 15px 24px max(15px, env(safe-area-inset-bottom));
  background: rgb(255 255 255 / 91%);
  border-top: 1px solid rgb(124 58 237 / 13%);
  box-shadow: 0 -8px 18px rgb(82 65 117 / 8%);
  backdrop-filter: blur(18px);
}

.study-log-progress { display: grid; grid-template-columns: auto minmax(80px, 1fr); align-items: center; gap: 12px; min-width: 0; }
.study-log-progress > div:first-child { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.study-log-progress strong { color: var(--clay-violet); font-family: "Nunito", "PingFang SC", sans-serif; font-size: 21px; line-height: 1; }
.study-log-progress small { max-width: 270px; overflow: hidden; color: var(--clay-muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.study-log-progress-track { height: 8px; overflow: hidden; background: var(--clay-recess); border-radius: 999px; box-shadow: var(--clay-recess-shadow); }
.study-log-progress-track span { display: block; width: 0; height: 100%; background: var(--clay-violet); border-radius: inherit; transition: width 220ms ease; }

html[data-theme="dark"] .study-log-dialog,
html[data-theme="dark"] .study-log-footer { background: rgb(53 46 72 / 94%); border-color: rgb(216 202 255 / 17%); }
html[data-theme="dark"] .study-log-field input,
html[data-theme="dark"] .study-log-field select { color: #f7f3ff; background: #302942; border-color: rgb(216 202 255 / 17%); }

@media (max-width: 980px) {
  .topbar { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto auto; gap: 8px; padding-top: max(8px, env(safe-area-inset-top)); }
  .brand { grid-column: 1; grid-row: 1; min-width: 0; }
  .topbar-search { grid-column: 2; grid-row: 1; }
  .mobile-nav-button { grid-column: 3; grid-row: 1; min-width: 0; }
  .topbar-actions { grid-column: 1 / -1; grid-row: 2; order: unset; flex-basis: auto; justify-content: flex-end; width: 100%; }
  .topbar-search .search-results { position: fixed; top: calc(100px + env(safe-area-inset-top)); right: 10px; left: 10px; width: auto; }
  .quick-log-button,
  #random-button,
  #theme-button { min-width: 48px; height: 36px; padding: 0 8px; }
  .study-log-dialog { max-height: 94dvh; border-radius: 22px 22px 0 0; border-bottom: 0; }
}

@media (max-width: 620px) {
  .study-log-fields { grid-template-columns: 1fr; padding: 18px 16px; }
  .study-log-field--wide { grid-column: auto; }
  .study-log-list-wrap { padding-right: 16px; padding-left: 16px; }
  .study-log-list { max-height: 25dvh; }
  .study-log-footer { grid-template-columns: 1fr; gap: 12px; padding-right: 16px; padding-left: 16px; }
  .study-log-footer .primary-button { width: 100%; }
  .study-log-progress { grid-template-columns: auto minmax(70px, 1fr); }
}
