/* ---------- Basics ---------- */
:root {
  --ground: #FBF7F0;
  --card: #FFFFFF;
  --line: #EADFD3;
  --line-soft: #F0E6DA;
  --field: #CDBFB0;
  --ink: #2B2622;
  --muted: #6B625A;
  --accent: #C2410C;
  --accent-dark: #9A3412;
  --accent-soft: #FDE7DC;
  --fridge: #EAF2EF;
  --fridge-line: #CFDDD8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: Nunito, system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.4;
}

h1, h2, h3 { font-family: Fredoka, Nunito, sans-serif; font-weight: 600; margin: 0; }
h1 { font-size: 40px; }
h2 { font-size: 22px; }

a { color: var(--accent-dark); }
a:hover { color: #7C2D12; }

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

.loading { padding: 64px; text-align: center; color: var(--muted); }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

:focus-visible { outline: 3px solid #2563EB; outline-offset: 2px; }

/* ---------- Buttons and fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px;
  border: 1px solid var(--field); border-radius: 14px;
  background: var(--card); color: var(--ink);
  font-weight: 800; font-size: 17px; text-decoration: none; cursor: pointer;
}
.btn:hover { background: #F7F1E8; color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }
.btn-primary:hover { background: var(--accent-dark); color: #FFFFFF; }
.btn-danger { color: #B91C1C; border-color: #FCA5A5; }
.btn-danger:hover { background: #FEF2F2; color: #991B1B; }
.btn-small { min-height: 44px; padding: 0 14px; font-size: 16px; }
.btn-round { width: 48px; padding: 0; }
.btn[disabled] { opacity: 0.6; cursor: wait; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-weight: 700; font-size: 16px; }
.input {
  min-height: 50px; padding: 10px 14px; width: 100%;
  border: 1px solid var(--field); border-radius: 12px; background: #FFFFFF;
  font-size: 17px;
}
textarea.input { resize: vertical; min-height: 90px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 700; min-height: 44px; }
.check input { width: 22px; height: 22px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 22px;
}
.card h2 { margin-bottom: 12px; }
.hint { color: var(--muted); font-size: 16px; margin: 0; }
.muted { color: var(--muted); }

/* ---------- Header ---------- */
.site-header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px;
  padding: 16px 28px; background: #FFFFFF; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--ink); }
.brand-mark {
  width: 44px; height: 44px; border-radius: 12px; background: var(--accent);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.brand-name { font-family: Fredoka, sans-serif; font-size: 24px; font-weight: 600; }
.main-nav { display: flex; flex-wrap: wrap; gap: 6px; }
.main-nav a {
  padding: 12px 20px; border-radius: 999px; color: var(--ink);
  font-weight: 700; text-decoration: none;
}
.main-nav a:hover { background: #F7F1E8; }
.main-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-dark); font-weight: 800; }
.who-am-i { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; color: #FFFFFF; flex: none;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 800;
}
.link-button {
  background: none; border: none; padding: 8px; min-height: 44px; cursor: pointer;
  color: var(--accent-dark); text-decoration: underline; font-weight: 700; font-size: 16px;
}

/* ---------- Page layout ---------- */
.page { max-width: 1260px; margin: 0 auto; padding: 28px; }
.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 22px;
}
.page-head p { margin: 6px 0 0; color: var(--muted); }
.two-col { display: flex; flex-wrap: wrap; gap: 26px; align-items: flex-start; }
.two-col > .wide { flex: 999 1 560px; min-width: 0; }
.two-col > .side { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }

/* ---------- Sign in ---------- */
.signin-wrap {
  min-height: 100vh; padding: 40px 20px; background: var(--fridge);
  display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden;
}
.signin-card {
  position: relative; width: 100%; max-width: 460px; background: #FFFFFF; border-radius: 28px;
  padding: 36px; box-shadow: 0 20px 50px rgba(43, 38, 34, 0.12);
  display: flex; flex-direction: column; gap: 18px;
}
.signin-card h1 { font-size: 34px; }
.signin-card p { margin: 0; color: var(--muted); line-height: 1.5; }
.deco { position: absolute; pointer-events: none; }

/* ---------- Fridge door ---------- */
.fridge {
  position: relative; height: 700px; background: var(--fridge);
  border: 2px solid var(--fridge-line); border-radius: 28px; overflow: hidden;
  box-shadow: inset 0 -6px 0 #D8E5E0, 0 10px 30px rgba(43, 38, 34, 0.08);
}
.fridge-handle {
  position: absolute; left: 20px; top: 60px; width: 14px; height: 220px;
  border-radius: 8px; background: #B8C9C3;
}
.fridge-seam { position: absolute; left: 0; right: 0; top: 330px; height: 2px; background: var(--fridge-line); }
.fridge-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 40px; text-align: center; color: #4A5A55; font-weight: 700;
}
.fridge-item {
  position: absolute; touch-action: none; cursor: grab; user-select: none;
}
.fridge-item.dragging { cursor: grabbing; z-index: 50; }
.fridge-item.sticker { filter: drop-shadow(0 3px 4px rgba(43, 38, 34, 0.25)); }
.fridge-item.sticker svg { display: block; width: 76px; height: 76px; }
.note {
  width: 200px; padding: 30px 18px 16px;
  box-shadow: 0 6px 14px rgba(43, 38, 34, 0.15);
}
.magnet {
  position: absolute; top: 8px; left: calc(50% - 8px); width: 16px; height: 16px;
  border-radius: 50%; box-shadow: 0 2px 3px rgba(0, 0, 0, 0.25);
}
.note-text {
  margin: 0; font-family: Caveat, cursive; font-size: 26px; line-height: 1.15;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.note-by {
  margin: 8px 0 0; font-family: Caveat, cursive; font-size: 21px; font-weight: 700;
  color: #4A423B; text-align: right;
}
.remove {
  position: absolute; top: -12px; right: -12px; width: 34px; height: 34px;
  border-radius: 50%; border: 2px solid #FFFFFF; background: #2B2622; color: #FFFFFF;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  opacity: 0; transition: opacity 0.15s;
}
.fridge-item:hover .remove, .fridge-item:focus-within .remove { opacity: 1; }
@media (hover: none) { .remove { opacity: 0.85; } }

.sticker-tray { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.sticker-btn {
  height: 58px; border: 1px solid var(--line); border-radius: 14px; background: var(--ground);
  cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0;
}
.sticker-btn:hover { background: #F4ECE0; }
.sticker-btn svg { width: 38px; height: 38px; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { position: relative; }
.swatch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.swatch span {
  display: block; width: 44px; height: 44px; border-radius: 10px; border: 2px solid var(--field); cursor: pointer;
}
.swatch input:checked + span { border: 3px solid var(--ink); }
.swatch input:focus-visible + span { outline: 3px solid #2563EB; outline-offset: 2px; }

.mini-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.mini-list li { display: flex; gap: 12px; align-items: flex-start; }
.date-pill {
  min-width: 60px; text-align: center; padding: 6px 4px; border-radius: 10px;
  font-weight: 800; font-size: 15px; flex: none;
}

/* ---------- Calendar ---------- */
.cal-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filters { display: flex; flex-direction: column; gap: 12px; margin-bottom: 22px; }
.filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.filter-row + .filter-row { border-top: 1px solid var(--line-soft); padding-top: 12px; }
.filter-label { font-weight: 800; min-width: 60px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px 0 6px;
  border-radius: 999px; border: 1px solid var(--field); background: #FFFFFF;
  font-weight: 700; font-size: 17px; cursor: pointer;
}
.chip.plain { padding: 0 18px; font-weight: 800; }
.chip[aria-pressed="true"] { border-width: 2px; }
.dot {
  width: 32px; height: 32px; border-radius: 50%; color: #FFFFFF; flex: none;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px;
}
.dot.small { width: 20px; height: 20px; font-size: 11px; }

.month { overflow-x: auto; padding: 14px; }
.month-inner { min-width: 660px; }
.week-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.week-row + .week-row { margin-top: 6px; }
.weekday {
  padding: 6px 8px; font-weight: 800; font-size: 15px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.day {
  min-height: 120px; padding: 6px; border-radius: 12px; background: var(--ground);
  border: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 4px;
}
.day.blank { background: transparent; border-color: transparent; }
.day.today { border: 2px solid var(--accent); background: #FFF7F2; }
.day-num {
  align-self: flex-start; min-width: 34px; height: 34px; padding: 0 6px;
  border: none; border-radius: 999px; background: transparent; cursor: pointer;
  font-weight: 700; font-size: 17px;
}
.day-num:hover { background: #F0E6DA; }
.day.today .day-num { background: var(--accent); color: #FFFFFF; font-weight: 800; }
.ev {
  display: flex; align-items: flex-start; gap: 6px; width: 100%; text-align: left;
  padding: 5px 7px; border-radius: 9px; border: none; cursor: pointer;
  font-size: 14px; font-weight: 700; line-height: 1.25;
}
.ev.selected { outline: 2px solid var(--ink); }
.ev > span:last-child { min-width: 0; overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

/* ---------- Photos ---------- */
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; margin-bottom: 36px; }
.album-card {
  display: block; text-decoration: none; color: var(--ink); background: #FFFFFF;
  border: 1px solid var(--line); border-radius: 20px; overflow: hidden;
}
.album-card:hover { color: var(--ink); box-shadow: 0 8px 22px rgba(43, 38, 34, 0.1); }
.album-cover {
  height: 180px; background: var(--accent-soft); color: var(--accent-dark);
  display: flex; align-items: center; justify-content: center;
}
.album-cover img, .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-info { padding: 14px 16px 16px; }
.album-info strong { display: block; font-size: 20px; }
.album-info span { display: block; color: var(--muted); font-size: 15px; margin-top: 2px; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.photo-card {
  display: block; text-decoration: none; color: var(--ink); background: #FFFFFF;
  border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
}
.photo-card:hover { color: var(--ink); box-shadow: 0 8px 22px rgba(43, 38, 34, 0.1); }
.thumb {
  aspect-ratio: 1 / 1; background: #F0E6DA; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
}
.photo-meta { display: flex; justify-content: space-between; gap: 8px; padding: 8px 12px 10px; font-size: 15px; }
.photo-meta .cap { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hearts { display: inline-flex; align-items: center; gap: 4px; color: #B91C1C; font-weight: 800; flex: none; }

.viewer {
  position: relative; background: #1F1B18; border-radius: 24px; overflow: hidden;
  display: flex; align-items: center; justify-content: center; min-height: 360px; max-height: 75vh;
}
.viewer img { max-width: 100%; max-height: 75vh; display: block; }
.viewer .nav-btn {
  position: absolute; top: calc(50% - 26px); width: 52px; height: 52px; border-radius: 50%;
  border: none; background: #FFFFFF; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  display: flex; align-items: center; justify-content: center; cursor: pointer; text-decoration: none;
}
.viewer .prev { left: 14px; }
.viewer .next { right: 14px; }
.comment { margin: 0; padding: 10px 12px; border-radius: 12px; background: var(--ground); font-size: 16px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 14px 22px; border-radius: 14px;
  background: #2B2622; color: #FFFFFF; font-weight: 700;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); opacity: 0; pointer-events: none;
  transition: opacity 0.2s; z-index: 100;
}
.toast.show { opacity: 1; }
.toast.has-action { pointer-events: auto; display: flex; align-items: center; gap: 14px; }
.toast-undo {
  min-height: 40px; padding: 0 16px; border: 2px solid #FFFFFF; border-radius: 10px;
  background: transparent; color: #FFFFFF; font-weight: 800; font-size: 16px; cursor: pointer;
}
.toast-undo:hover { background: rgba(255, 255, 255, 0.15); }

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
  body { font-size: 17px; }
  h1 { font-size: 32px; }
  .page { padding: 18px; }
  .site-header { padding: 12px 16px; }
  .brand-name { font-size: 20px; }
  .fridge { height: 560px; }
  .fridge-seam { top: 260px; }
  .note { width: 160px; padding: 26px 12px 12px; }
  .note-text { font-size: 22px; }
  .fridge-item.sticker svg { width: 60px; height: 60px; }
}
