/* ============================================================
   ClassTrack — Responsive Stylesheet
   Mobile-first, scales to tablet and desktop
   ============================================================ */

:root {
  --bg: #f3efe5;
  --panel: #faf8f0;
  --line: #111;
  --yellow: #f5ea84;
  --teal: #8be0d7;
  --pink: #ff5b7a;
  --shadow: 4px 4px 0 #111;
  --shadow2: 8px 8px 0 #111;
  /* Responsive spacing scale */
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 22px;
  --space-xl: 32px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  background: var(--bg);
  color: #111;
  overflow-x: hidden;
  /* Prevent font inflation on mobile */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }
#app { min-height: 100vh; }
img { max-width: 100%; height: auto; }

/* ── Layout shell ── */
.main {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 1180px;
  margin: 0 auto;
  background: transparent;
}

/* ── Top bar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 2px solid var(--line);
  background: rgba(250, 248, 240, .95);
  backdrop-filter: saturate(120%) blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
  gap: 10px;
}
.topbar.compact { box-shadow: 0 1px 0 rgba(17,17,17,.05); }
@media (min-width: 600px) {
  .topbar { padding: 14px 18px; }
}

.brand { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.brand h1 { margin: 0; font-size: 20px; line-height: 1; font-weight: 900; letter-spacing: -.03em; }
@media (min-width: 480px) {
  .brand h1 { font-size: 24px; }
}

.beta {
  border: 2px solid var(--line);
  background: #ffe046;
  padding: 2px 7px;
  font-weight: 900;
  font-size: 11px;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}
/* Hide "Home" text link on very small screens */
@media (max-width: 399px) {
  .top-actions .link-btn { display: none; }
}

.topbar.compact .button { padding: 8px 10px; }
.topbar.compact .link-btn { padding: 6px 8px; }

/* ── Buttons ── */
.link-btn {
  border: 0;
  background: transparent;
  padding: 8px 10px;
  border-radius: 999px;
}
.button {
  border: 2px solid var(--line);
  background: #fff;
  padding: 10px 12px;
  font-weight: 800;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
  transform: translateY(0);
  /* Minimum touch target */
  min-height: 44px;
  white-space: nowrap;
}
@media (min-width: 600px) {
  .button { padding: 11px 14px; gap: 8px; }
}
@media (hover: hover) {
  .button:hover { transform: translateY(-1px); }
}
.button:active { transform: translateY(1px); box-shadow: 2px 2px 0 #111; }
.button:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: var(--shadow); }
.button.yellow { background: #ffe46b; }
.button.teal   { background: var(--teal); }
.button.black  { background: #111; color: #fff; }
.button.pink   { background: #ffd1d8; }
/* Icon-only buttons: keep square */
.button[style*="padding:8px 10px"] { min-height: 40px; min-width: 40px; padding: 8px 10px !important; }

/* ── Brand button ── */
.brand-btn {
  border: 0; background: transparent; padding: 0;
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; text-align: left;
  /* Ensure touch target */
  min-height: 44px;
}
@media (hover: hover) {
  .brand-btn:hover { transform: translateY(-1px); }
}
.brand-btn:active { transform: translateY(1px); }

/* ── Content area ── */
.content {
  padding: 14px;
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
}
.content.compact { padding: 12px 14px 28px; }
@media (min-width: 600px) {
  .content, .content.compact { padding: 18px; }
}
@media (min-width: 900px) {
  .content { padding: 24px 22px 32px; }
  .content.compact { padding: 20px 22px 36px; }
}

/* ── Typography ── */
.title {
  font-size: clamp(26px, 6vw, 46px);
  font-weight: 900;
  letter-spacing: -.04em;
  margin: 0 0 6px;
  line-height: 1.1;
}
.subtitle { margin: 0; color: #444; font-size: 14px; max-width: 60ch; }
@media (min-width: 600px) {
  .subtitle { font-size: 15px; }
}

/* ── Search box ── */
.search-box {
  margin-top: 22px;
  display: flex;
  border: 2px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow);
}
@media (min-width: 600px) {
  .search-box { margin-top: 28px; }
}
.search-ico {
  width: 48px;
  display: grid;
  place-items: center;
  background: #ffe46b;
  border-right: 2px solid var(--line);
  font-size: 18px;
  flex-shrink: 0;
}
@media (min-width: 600px) {
  .search-ico { width: 56px; font-size: 20px; }
}
.search-box input {
  border: 0;
  flex: 1;
  padding: 14px 12px;
  font-size: 15px;
  background: transparent;
  outline: none;
  /* Prevent zoom on iOS */
  font-size: max(16px, 1em);
  min-width: 0;
}
.hotkey { display: none; align-items: center; padding: 0 14px; color: #666; font-size: 12px; }
@media (min-width: 900px) { .hotkey { display: flex; } }

/* ── Filter panel ── */
.filter-panel {
  margin-top: 18px;
  border: 2px solid var(--line);
  background: #f7f4eb;
  box-shadow: var(--shadow);
  padding: 14px;
}
@media (min-width: 600px) {
  .filter-panel { margin-top: 22px; padding: 16px; }
}

.filter-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.row { display: grid; gap: 14px; }
@media (min-width: 980px) { .row { grid-template-columns: 1.1fr 1.9fr; } }

/* grid2 stacks on mobile, goes 2-col on sm+ */
.grid2 { display: grid; gap: 12px; }
@media (min-width: 480px) { .grid2 { grid-template-columns: 1fr 1fr; } }

.label { font-size: 14px; font-weight: 800; margin-bottom: 6px; display: block; }

.input, .select, .textarea {
  width: 100%;
  border: 2px solid var(--line);
  background: #faf8f0;
  padding: 12px 14px;
  outline: none;
  transition: background .15s ease;
  /* Prevent zoom on iOS (inputs must be ≥16px) */
  font-size: max(16px, 1em);
}
.input:focus, .select:focus, .textarea:focus { background: #fff; }

.sep {
  height: 1px;
  background: repeating-linear-gradient(90deg, #111 0 4px, transparent 4px 8px);
  margin: 14px 0 12px;
  opacity: .25;
}

/* ── Pill filters ── */
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
@media (min-width: 600px) { .pills { gap: 10px; } }
.pill {
  border: 2px solid var(--line);
  background: #fff;
  padding: 9px 11px;
  font-weight: 700;
  font-size: 13px;
  box-shadow: 3px 3px 0 #111;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.pill.active  { background: #111; color: #fff; }
.pill.subject { padding-inline: 13px; }
.pill.type    { gap: 7px; }
.dot { width: 10px; height: 10px; border: 1px solid #111; display: inline-block; flex-shrink: 0; }
.dot.rose   { background: #ff476f; }
.dot.teal   { background: #14c7c0; }
.dot.yellow { background: #ffe046; }
.dot.black  { background: #111; }

/* ── Toolbar ── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.muted { color: #616161; font-size: 14px; font-weight: 700; }

/* ── Day cards grid ── */
.cards { display: grid; gap: 14px; margin-top: 16px; }
@media (min-width: 600px)  { .cards { gap: 16px; } }
@media (min-width: 860px)  { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; } }

/* ── Card ── */
.card {
  border: 2px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 14px;
  text-align: left;
  transition: transform .15s ease;
  transform: translateY(0);
  position: relative;
}
@media (hover: hover) {
  .card:hover { transform: translateY(-4px); }
}

.card-button {
  cursor: pointer;
  display: block;
  width: 100%;
  text-align: left;
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #faf8f0 0%, #f7f3e9 100%);
}
.card-button::before {
  content: "";
  position: absolute;
  left: 0; top: 0;
  width: 100%; height: 5px;
  background: linear-gradient(90deg, #ffe46b, #ff5b7a, #8be0d7);
  border-bottom: 2px solid var(--line);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  margin-top: 6px;
}

.card-date-block { display: flex; align-items: flex-start; gap: 10px; }
@media (min-width: 400px) { .card-date-block { gap: 12px; } }

.cal {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1px;
  width: 48px; height: 48px;
  border: 2px solid var(--line);
  background: #ffe46b;
  box-shadow: 3px 3px 0 #111;
  font-weight: 900;
  line-height: 1;
  font-size: 14px;
  flex-shrink: 0;
}
@media (min-width: 480px) {
  .cal { width: 56px; height: 56px; font-size: 16px; }
}
.cal small  { font-size: 10px; display: block; }
.cal span   { font-size: 18px; display: block; font-weight: 900; line-height: 1; }
@media (min-width: 480px) { .cal span { font-size: 20px; } }

.card-date { font-weight: 800; font-size: 13px; }
@media (min-width: 480px) { .card-date { font-size: 14px; } }
.card-meta { font-size: 12px; color: #555; }
@media (min-width: 480px) { .card-meta { font-size: 13px; } }

.arrow {
  width: 38px; height: 38px;
  border: 2px solid var(--line);
  background: var(--teal);
  box-shadow: 3px 3px 0 #111;
  display: grid;
  place-items: center;
  font-weight: 900;
  flex-shrink: 0;
}
@media (min-width: 480px) { .arrow { width: 40px; height: 40px; } }

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 12px; }
@media (min-width: 480px) { .tag-row { gap: 8px; margin: 6px 0 14px; } }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 2px solid var(--line);
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 800;
  box-shadow: 2px 2px 0 #111;
  background: #fff;
  white-space: nowrap;
}
@media (min-width: 480px) { .tag { font-size: 12px; padding: 8px 10px; gap: 6px; } }
.tag.rose   { background: #ffd1d8; }
.tag.teal   { background: var(--teal); }
.tag.yellow { background: #ffe46b; }
.tag.black  { background: #111; color: #fff; }

.entry { display: flex; align-items: center; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
@media (min-width: 480px) { .entry { gap: 10px; margin: 10px 0; } }
.entry-title { font-size: 13px; line-height: 1.3; }
@media (min-width: 480px) { .entry-title { font-size: 14px; } }

.more { font-weight: 800; font-size: 13px; margin-top: 4px; }
.card-footer {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed rgba(17,17,17,.35);
  font-size: 12px;
  color: #555;
}
@media (min-width: 480px) { .card-footer { font-size: 13px; } }

/* ── Animations ── */
.page { animation: pageIn .25s ease both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn .2s ease both; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.pop { animation: pop .18s ease both; }
@keyframes pop { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: scale(1); } }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .page, .fade-in, .pop, .toast { animation: none; }
}

/* ── Back button ── */
.back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  font-weight: 800;
  padding: 8px 0;
  min-height: 44px;
  font-size: 14px;
}

/* ── Day hero ── */
.day-hero {
  border: 2px solid var(--line);
  background: #f5ea84;
  box-shadow: 5px 5px 0 #111;
  padding: 14px;
}
@media (min-width: 600px) { .day-hero { padding: 16px; } }

.day-hero-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.day-title {
  font-size: clamp(22px, 5vw, 44px);
  font-weight: 900;
  letter-spacing: -.04em;
  margin: 0;
  line-height: 1.1;
}
.day-sub { margin-top: 4px; color: #444; font-size: 14px; }

.day-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
@media (min-width: 600px) { .day-actions { gap: 12px; } }
/* On narrow screens, stack day-actions below title */
@media (max-width: 599px) {
  .day-hero-row { flex-direction: column; }
  .day-actions { width: 100%; }
  .day-actions .button { flex: 1 1 auto; justify-content: center; min-width: calc(50% - 4px); }
}

/* ── Day tabs ── */
.day-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 14px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
@media (min-width: 600px) { .day-tabs { gap: 8px; margin: 18px 0; } }
.day-tab {
  border: 2px solid var(--line);
  background: #fff;
  padding: 9px 12px;
  font-weight: 800;
  font-size: 13px;
  box-shadow: 3px 3px 0 #111;
  white-space: nowrap;
  min-height: 40px;
}
@media (min-width: 600px) { .day-tab { padding: 10px 14px; font-size: 14px; } }
.day-tab.active { background: #111; color: #fff; }

/* ── Subject / entry boxes ── */
.subject-box {
  border: 2px solid var(--line);
  background: var(--panel);
  box-shadow: 5px 5px 0 #111;
  overflow: hidden;
  margin-top: 12px;
}
@media (min-width: 600px) { .subject-box { margin-top: 14px; } }

.subject-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px 12px;
  background: var(--teal);
  border-bottom: 2px solid var(--line);
  font-weight: 900;
  gap: 8px;
  flex-wrap: wrap;
}
@media (min-width: 600px) { .subject-head { padding: 12px 14px; align-items: center; } }

.subject-body { padding: 14px; }
@media (min-width: 600px) { .subject-body { padding: 16px; } }

.entry-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }

.title-lg { font-size: 18px; font-weight: 900; margin: 0; line-height: 1.2; }
@media (min-width: 600px) { .title-lg { font-size: 22px; } }

.desc { margin: 10px 0 0; line-height: 1.75; color: #222; font-size: 14px; }
@media (min-width: 600px) { .desc { margin: 12px 0 0; } }

.hl-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
@media (min-width: 480px) { .hl-row { gap: 8px; margin-top: 12px; } }
.hl {
  border: 2px solid var(--line);
  background: #ffe46b;
  box-shadow: 2px 2px 0 #111;
  padding: 5px 7px;
  font-size: 11px;
  font-weight: 800;
}
@media (min-width: 480px) { .hl { padding: 6px 8px; font-size: 12px; } }

/* ── Entry card (day view) ── */
.entry-card .subject-head { flex-wrap: wrap; gap: 8px; }

.entry-tools {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}
/* Hide edit/delete labels on small screens, keep icons */
@media (max-width: 479px) {
  .entry-tools .button { padding: 7px 8px !important; min-width: 36px; min-height: 36px; }
}

/* Entry card body */
.card-body { padding-top: 0; }
.card-body-grid { display: grid; gap: 14px; }
@media (min-width: 920px) {
  .card-body-grid { grid-template-columns: 1.4fr .9fr; align-items: start; }
}

/* ── Card gallery ── */
.card-gallery { display: grid; gap: 8px; }
@media (min-width: 480px) { .card-gallery { gap: 10px; } }
.card-gallery.has-images { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: stretch; }

.card-photo {
  border: 2px solid var(--line);
  background: #ddd center/cover no-repeat;
  min-height: 76px;
  aspect-ratio: 1/1;
  box-shadow: 3px 3px 0 #111;
  padding: 0;
  transition: transform .15s ease;
  display: block;
  width: 100%;
  overflow: hidden;
}
@media (min-width: 480px) { .card-photo { min-height: 92px; } }
.card-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
@media (hover: hover) { .card-photo:hover { transform: translateY(-2px); } }

.card-gallery-empty {
  min-height: 120px;
  border: 2px dashed var(--line);
  background: linear-gradient(135deg, #fff 0%, #f5ea84 100%);
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  text-align: left;
  padding: 14px;
  box-shadow: 3px 3px 0 #111;
}
@media (min-width: 920px) { .card-gallery-empty { min-height: 160px; } }
.card-gallery-badge {
  width: 44px; height: 44px;
  border: 2px solid var(--line);
  background: #fff;
  display: grid;
  place-items: center;
  box-shadow: 3px 3px 0 #111;
  flex-shrink: 0;
}
.card-mini-info {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
  color: #444;
  font-size: 13px;
  font-weight: 700;
}
@media (min-width: 480px) { .card-mini-info { gap: 14px; font-size: 14px; } }

/* ── Modal ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12px;
  z-index: 50;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
@media (min-width: 480px) { .modal-backdrop { padding: 18px; } }

.modal {
  width: 100%;
  max-width: 980px;
  background: var(--panel);
  border: 2px solid var(--line);
  box-shadow: 8px 8px 0 #111;
  padding: 16px;
  animation: modalIn .18s ease both;
  /* Prevent modal from being taller than viewport */
  margin: auto;
}
@media (min-width: 480px) { .modal { padding: 22px; } }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}
.modal-title { font-size: 22px; font-weight: 900; margin: 0; }
@media (min-width: 480px) { .modal-title { font-size: 28px; } }

/* Modal grids: always single column on mobile */
.modal-grid { display: grid; gap: 14px; }
@media (min-width: 600px) {
  .modal-grid.two  { grid-template-columns: 1fr 1fr; }
  .modal-grid.four { grid-template-columns: repeat(4, 1fr); }
}

.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
@media (min-width: 480px) { .modal-actions { gap: 10px; margin-top: 18px; } }
/* Full-width buttons in modal actions on tiny screens */
@media (max-width: 399px) {
  .modal-actions .button { flex: 1 1 100%; justify-content: center; }
}

.helper { font-size: 12px; color: #666; margin-top: 5px; }

/* ── Auth box ── */
.auth-box {
  width: min(100%, 420px);
  margin: auto;
  border: 2px solid var(--line);
  background: var(--panel);
  box-shadow: 8px 8px 0 #111;
  padding: 18px;
}
@media (min-width: 480px) { .auth-box { padding: 22px; } }
.auth-ico {
  width: 60px; height: 60px;
  margin: 0 auto 12px;
  border: 2px solid var(--line);
  background: #ffe46b;
  box-shadow: 4px 4px 0 #111;
  display: grid;
  place-items: center;
  font-size: 28px;
  font-weight: 900;
}
@media (min-width: 480px) { .auth-ico { width: 68px; height: 68px; } }
.center { text-align: center; }
.small  { font-size: 13px; color: #555; }
.divider {
  height: 1px;
  border-top: 2px dashed rgba(17,17,17,.25);
  margin: 16px 0;
}

/* ── Fixed overlays: admin status & toast ── */
.status {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 40;
  border: 2px solid var(--line);
  background: #fff;
  box-shadow: 5px 5px 0 #111;
  padding: 10px 12px;
  font-weight: 800;
  font-size: 12px;
  display: flex;
  gap: 7px;
  align-items: center;
}
@media (min-width: 480px) {
  .status { right: 16px; bottom: 16px; padding: 12px 14px; font-size: 13px; }
}

.toast {
  position: fixed;
  /* Sits above status badge */
  bottom: 72px;
  right: 12px;
  z-index: 100;
  border: 2px solid var(--line);
  box-shadow: 4px 4px 0 #111;
  padding: 11px 16px;
  font-weight: 800;
  font-size: 13px;
  animation: toastIn .2s ease both;
  max-width: calc(100vw - 24px);
}
@media (min-width: 480px) {
  .toast { bottom: 80px; right: 16px; padding: 12px 18px; font-size: 14px; max-width: 340px; }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* When admin badge is not showing, toast drops lower */
.toast:only-child { bottom: 12px; }

/* ── Loader ── */
.loader {
  width: 14px; height: 14px;
  border-radius: 999px;
  border: 2px solid #111;
  border-top-color: transparent;
  animation: spin .8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Date editor ── */
.date-editor { display: flex; flex-direction: column; gap: 10px; }
.date-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.date-chip {
  border: 2px solid var(--line);
  background: #fef1a8;
  box-shadow: 2px 2px 0 #111;
  padding: 8px 10px;
  font-weight: 900;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  min-height: 40px;
}
@media (hover: hover) { .date-chip:hover { transform: translateY(-1px); } }

/* Date range in filter */
.date-range { display: grid; gap: 10px; }
@media (min-width: 600px) { .date-range { grid-template-columns: 1fr 1fr; } }

.date-field {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 2px solid var(--line);
  background: #fff;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  min-height: 64px;
  transition: transform .15s ease;
}
@media (min-width: 480px) { .date-field { min-height: 74px; gap: 12px; } }
@media (hover: hover) { .date-field:hover { transform: translateY(-1px); } }

.date-ico {
  width: 38px; height: 38px;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  background: var(--yellow);
  box-shadow: 2px 2px 0 #111;
  flex-shrink: 0;
}
@media (min-width: 480px) { .date-ico { width: 42px; height: 42px; } }

.date-field-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-weight: 900;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  min-width: 0;
}
.date-input {
  border: 0;
  outline: none;
  background: transparent;
  padding: 0;
  font-weight: 900;
  font-size: 14px;
  letter-spacing: .01em;
  min-width: 0;
  width: 100%;
}
@media (min-width: 480px) { .date-input { font-size: 15px; } }
.date-input::-webkit-calendar-picker-indicator { cursor: pointer; }

/* ── Photo panel ── */
.photo-panel {
  border: 2px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow);
  padding: 14px;
}
.photo-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.photo-grid { display: grid; gap: 8px; }
@media (min-width: 480px) { .photo-grid { gap: 10px; } }
.photo-grid.has-items { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
@media (min-width: 480px) { .photo-grid.has-items { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); } }
.photo-item {
  position: relative;
  border: 2px solid var(--line);
  background: #f7f4eb;
  box-shadow: 3px 3px 0 #111;
  overflow: hidden;
  min-height: 100px;
}
@media (min-width: 480px) { .photo-item { min-height: 120px; } }
.photo-item img { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo-remove {
  position: absolute;
  top: 6px; right: 6px;
  width: 32px; height: 32px;
  border: 2px solid var(--line);
  background: #fff;
  font-weight: 900;
  box-shadow: 2px 2px 0 #111;
  /* ensure touch target */
  min-width: 32px;
}
.photo-empty {
  min-height: 100px;
  border: 2px dashed var(--line);
  display: grid;
  place-items: center;
  background: #faf8f0;
  font-weight: 800;
  text-align: center;
  padding: 14px;
  font-size: 13px;
}
@media (min-width: 480px) { .photo-empty { min-height: 120px; } }

/* ── Memo history ── */
.memo-history {
  margin-top: 14px;
  border: 2px solid var(--line);
  background: #fff;
  box-shadow: 5px 5px 0 #111;
  padding: 14px;
}
@media (min-width: 600px) { .memo-history { margin-top: 18px; } }
.memo-history-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.memo-count {
  border: 2px solid var(--line);
  background: #ffe46b;
  box-shadow: 3px 3px 0 #111;
  padding: 7px 10px;
  font-weight: 900;
  font-size: 13px;
}
.memo-history-list { display: grid; gap: 10px; }
@media (min-width: 600px) { .memo-history-list { gap: 12px; } }
.memo-history-item {
  border: 2px solid var(--line);
  background: linear-gradient(180deg, #faf8f0 0%, #f5fbfa 100%);
  box-shadow: 3px 3px 0 #111;
  padding: 12px;
}
@media (min-width: 480px) { .memo-history-item { padding: 14px; } }
.memo-history-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.memo-history-label {
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #555;
}
.memo-role {
  border: 2px solid var(--line);
  background: #8be0d7;
  box-shadow: 2px 2px 0 #111;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 900;
}
.memo-title    { margin-top: 2px; }
.memo-text     { white-space: pre-wrap; }
.entry-card .memo-history-head { margin-top: 2px; }
.entry-card .memo-role { background: #ffe46b; }

/* ── YouTube preview ── */
.youtube-preview {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  border: 2px solid var(--line);
  background: #fff;
  padding: 8px 12px;
  font-weight: 800;
  font-size: 13px;
  text-decoration: none;
  box-shadow: 3px 3px 0 #111;
  color: #111;
}
@media (hover: hover) { .youtube-preview:hover { transform: translateY(-1px); } }
.youtube-preview svg { flex-shrink: 0; }

/* ── Utility ── */
.entry-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-preview-list { margin-top: 10px; }

/* ── Safe area insets (iPhone notch / Dynamic Island / home bar) ── */
@supports (padding: env(safe-area-inset-top)) {
  .topbar {
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }
  .content, .content.compact {
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }
  .status {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
  }
  .toast {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(72px, calc(env(safe-area-inset-bottom) + 60px));
  }
  .modal-backdrop {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
}

/* ── Transactions page ── */
.link-btn.active {
  text-decoration: underline;
  font-weight: 900;
}

.transactions-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  align-items: flex-start;
  margin-bottom: 16px;
}

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

.transaction-hero {
  margin-top: 18px;
  border: 2px solid var(--line);
  background: linear-gradient(135deg, #ffe46b 0%, #8be0d7 100%);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.transaction-stat {
  font-size: clamp(22px, 5vw, 34px);
  font-weight: 900;
  letter-spacing: -.04em;
  line-height: 1.1;
  margin-top: 4px;
}

.name-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.name-chip {
  border: 2px solid var(--line);
  background: #fff;
  box-shadow: 3px 3px 0 #111;
  padding: 8px 10px;
  font-weight: 800;
  font-size: 13px;
}

.transaction-form-card {
  margin-top: 18px;
  border: 2px solid var(--line);
  background: #faf8f0;
  box-shadow: var(--shadow);
  padding: 14px;
}

.transaction-list {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.transaction-card {
  border: 2px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow);
  padding: 14px;
}

.transaction-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.transaction-date {
  font-size: 12px;
  font-weight: 800;
  color: #555;
  margin-bottom: 4px;
}

.transaction-amount {
  border: 2px solid var(--line);
  background: #ffe46b;
  box-shadow: 3px 3px 0 #111;
  padding: 8px 10px;
  font-weight: 900;
  min-width: 90px;
  text-align: center;
}

.transaction-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

@media (max-width: 700px) {
  .transactions-head,
  .transactions-actions,
  .transaction-hero,
  .transaction-card-head {
    flex-direction: column;
  }
  .transaction-amount {
    width: fit-content;
  }
}
