:root {
  color-scheme: light;
  --ink: #27323a;
  --muted: #66727a;
  --steel: #dce6eb;
  --steel-dark: #aebfc8;
  --accent: #d84c62;
  --shadow: 0 18px 45px rgba(20, 35, 45, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: #dce8ec;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  color: #fff;
  background: #27323a;
  cursor: pointer;
}

button:hover {
  background: #101820;
}

.fridge-page {
  min-height: 100vh;
  padding: 18px clamp(10px, 3vw, 32px);
}

.fridge {
  position: relative;
  width: min(1180px, 100%);
  min-height: calc(100vh - 36px);
  margin: 0 auto;
  overflow: visible;
  border: 1px solid rgba(39, 50, 58, 0.16);
  border-radius: 18px 18px 10px 10px;
  background:
    repeating-linear-gradient(98deg, rgba(42,61,70,0.045) 0 1px, transparent 1px 46px),
    repeating-linear-gradient(8deg, transparent 0 34px, rgba(255,255,255,0.16) 34px 35px, transparent 35px 92px),
    linear-gradient(135deg, rgba(255,255,255,0.09) 0 1px, transparent 1px 28px),
    linear-gradient(45deg, rgba(40,58,68,0.045) 0 1px, transparent 1px 34px),
    linear-gradient(90deg, rgba(255,255,255,0.34), rgba(255,255,255,0) 16%, rgba(0,0,0,0.07) 84%, rgba(255,255,255,0.26)),
    linear-gradient(180deg, #eaf1f3 0, #dce8ec 52%, #cbd9df 100%);
  box-shadow: 0 20px 50px rgba(20, 35, 45, 0.22), inset 0 1px 0 rgba(255,255,255,0.64), inset 0 -24px 50px rgba(58,78,88,0.05);
}

.fridge::before {
  content: "";
  position: sticky;
  top: 0;
  display: block;
  height: 100vh;
  pointer-events: none;
  background:
    repeating-linear-gradient(172deg, transparent 0 72px, rgba(52,71,80,0.06) 72px 73px, transparent 73px 145px),
    repeating-linear-gradient(88deg, rgba(255,255,255,0.05) 0 1px, transparent 1px 18px),
    linear-gradient(180deg, rgba(255,255,255,0.58), rgba(255,255,255,0) 24%),
    radial-gradient(circle at 18% 16%, rgba(255,255,255,0.68), transparent 24%),
    linear-gradient(90deg, transparent, rgba(70,90,100,0.1) 50%, transparent);
  border-radius: inherit;
  opacity: 0.86;
}

.fridge::after {
  content: "";
  position: absolute;
  top: 28px;
  right: 22px;
  width: 24px;
  height: calc(100% - 56px);
  min-height: 75vh;
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.28), transparent 18%, rgba(0,0,0,0.26) 74%, rgba(255,255,255,0.1)),
    linear-gradient(180deg, #5b6870 0%, #26343d 18%, #1b2730 52%, #34434c 100%);
  box-shadow:
    inset 3px 0 4px rgba(255,255,255,0.18),
    inset -5px 0 8px rgba(0,0,0,0.34),
    -16px 0 22px rgba(19,35,45,0.18),
    0 10px 18px rgba(19,35,45,0.18);
  opacity: 0.94;
}

.fridge-header {
  position: absolute;
  z-index: 4;
  top: 34px;
  left: 28px;
  right: 44px;
  text-align: center;
  pointer-events: none;
}

.fridge-header h1 {
  margin: 0;
  font-size: clamp(34px, 7vw, 72px);
  line-height: 1;
  letter-spacing: 0;
  color: #2a363b;
  text-shadow: 0 2px 0 rgba(255,255,255,0.9), 0 12px 26px rgba(55,76,86,0.18);
}

.title-font-classic {
  font-family: Arial, Helvetica, sans-serif;
}

.title-font-hand {
  font-family: "Segoe Print", "Comic Sans MS", cursive;
}

.title-font-strict {
  font-family: Georgia, "Times New Roman", serif;
}

.title-image {
  max-width: min(520px, 86%);
  max-height: 140px;
  object-fit: contain;
}

.drop-hint {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 8;
  transform: translateX(-50%);
  max-width: calc(100% - 28px);
  padding: 11px 15px;
  border: 1px solid rgba(255,255,255,0.7);
  border-radius: 999px;
  color: #30404a;
  background: rgba(255,255,255,0.82);
  box-shadow: 0 8px 24px rgba(20, 35, 45, 0.14);
  backdrop-filter: blur(12px);
  white-space: nowrap;
}

.drop-hint.active {
  color: #fff;
  background: #d84c62;
}

.mobile-upload {
  position: fixed;
  left: 50%;
  bottom: 72px;
  z-index: 9;
  transform: translateX(-50%);
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  display: none;
}

.mobile-upload button {
  min-height: 44px;
  border: 1px solid rgba(255,255,255,0.76);
  border-radius: 999px;
  padding: 11px 18px;
  color: #fff;
  background: #27323a;
  box-shadow: 0 10px 26px rgba(20, 35, 45, 0.22);
}

.mobile-upload.placing button {
  background: #d84c62;
}

.fridge.placing {
  cursor: crosshair;
}

.magnets {
  position: absolute;
  inset: 0;
  z-index: 5;
}

.magnet {
  position: absolute;
  display: block;
  width: var(--w);
  min-width: 80px;
  transform: rotate(var(--r));
  border: 8px solid var(--frame-color, #fff);
  border-bottom-width: 18px;
  border-radius: 7px;
  background: var(--frame-color, #fff);
  box-shadow: 0 16px 28px rgba(17, 31, 39, 0.34), 0 5px 9px rgba(17, 31, 39, 0.24);
}

.magnet-media {
  position: relative;
  overflow: hidden;
  border-radius: 3px;
  background: #f4f7f8;
}

.magnet-holder {
  position: absolute;
  left: 50%;
  top: max(-34px, calc(var(--w) * -0.18));
  z-index: 3;
  width: clamp(56px, calc(var(--w) * 0.52), 112px);
  height: auto;
  max-height: none;
  pointer-events: none;
  transform: translateX(-50%) rotate(calc(var(--r) * -0.3));
  filter: drop-shadow(0 7px 8px rgba(17, 31, 39, 0.28));
  user-select: none;
}

.magnet-media::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 34%, rgba(255,255,255,0.62) 47%, rgba(255,255,255,0.24) 52%, transparent 64%);
  border-radius: inherit;
  opacity: 0;
  transform: translateX(-110%) skewX(-16deg);
  transition: opacity 0.18s ease, transform 0.62s ease;
}

.magnet:hover .magnet-media::after {
  opacity: 1;
  transform: translateX(110%) skewX(-16deg);
}

.magnet.frame-mini:hover .magnet-media::after {
  opacity: 0;
}

.frame-color-white {
  --frame-color: #fff;
}

.frame-color-red {
  --frame-color: #ff8a7a;
}

.frame-color-orange {
  --frame-color: #ff9b32;
}

.frame-color-yellow {
  --frame-color: #ffe35a;
}

.frame-color-green {
  --frame-color: #54c46f;
}

.frame-color-blue {
  --frame-color: #4fc3f7;
}

.magnet.moving {
  z-index: 20;
  outline: 3px solid #1656b8;
}

.magnet.editable {
  z-index: 30;
  cursor: grab;
  outline: 3px dashed rgba(22, 86, 184, 0.72);
  outline-offset: 4px;
}

.magnet.editable.moving {
  cursor: grabbing;
}

.edit-delete {
  position: absolute;
  right: -16px;
  top: -16px;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #c93d4b;
  color: #fff;
  box-shadow: 0 8px 16px rgba(17, 31, 39, 0.24);
  font-size: 24px;
  line-height: 1;
}

.edit-delete:hover {
  background: #a92c38;
}

.magnet.frame-circle {
  border-width: 7px;
  border-radius: 999px;
  aspect-ratio: 1;
  overflow: visible;
}

.magnet.frame-circle .magnet-media {
  border-radius: 999px;
}

.magnet.frame-circle .magnet-holder {
  top: max(-28px, calc(var(--w) * -0.13));
  width: clamp(50px, calc(var(--w) * 0.44), 96px);
}

.magnet.frame-circle img {
  height: var(--w);
  max-height: none;
  object-fit: cover;
}

.magnet.frame-circle .caption {
  position: absolute;
  left: 50%;
  bottom: -30px;
  z-index: 2;
  width: max-content;
  max-width: 128%;
  min-width: 72px;
  margin: 0;
  padding: 5px 10px 6px;
  transform: translateX(-50%);
  border: 2px solid rgba(22, 86, 184, 0.18);
  border-radius: 6px;
  background: #fffdf3;
  box-shadow: 0 5px 12px rgba(17, 31, 39, 0.16);
}

.magnet.frame-circle .like {
  right: -4px;
  bottom: 10px;
}

.magnet.frame-mini {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.magnet.frame-mini .magnet-media {
  border-radius: 5px;
  background: transparent;
}

.magnet.frame-mini img {
  max-height: none;
}

.magnet.pending {
  opacity: 0.58;
  outline: 3px dashed #d84c62;
}

.magnet img {
  display: block;
  width: 100%;
  height: auto;
  max-height: var(--h);
  object-fit: contain;
}

.magnet img.magnet-holder {
  width: clamp(56px, calc(var(--w) * 0.52), 112px);
  max-height: none;
}

.caption {
  margin: 8px -2px -10px;
  overflow-wrap: anywhere;
  color: #1656b8;
  font-family: "Segoe Print", "Comic Sans MS", cursive;
  font-size: var(--caption-size, 18px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0;
  text-align: center;
  text-shadow: 0 1px 0 rgba(255,255,255,0.9);
}

.magnet:not(.frame-circle):not(.frame-mini) .caption {
  box-sizing: border-box;
  width: calc(100% - max(42px, var(--like-size, 38px)));
  margin-right: max(34px, calc(var(--like-size, 38px) * 0.75));
}

.like {
  position: absolute;
  right: -12px;
  bottom: -18px;
  z-index: 4;
  display: inline-grid;
  min-width: var(--like-size, 38px);
  height: max(30px, calc(var(--like-size, 38px) * 0.9));
  place-items: center;
  border: 2px solid #fff;
  border-radius: 999px;
  padding: 0 8px;
  color: #fff;
  background: var(--accent);
  font-size: 14px;
  line-height: 1;
  box-shadow: 0 5px 14px rgba(160, 31, 52, 0.28);
}

.like::before {
  content: "♥ ";
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 76px;
  z-index: 30;
  transform: translateX(-50%);
  max-width: min(520px, calc(100% - 28px));
  padding: 12px 16px;
  border-radius: 8px;
  color: #fff;
  background: rgba(27, 38, 46, 0.94);
  box-shadow: 0 12px 35px rgba(0,0,0,0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.toast.show {
  opacity: 1;
}

.upload-dialog {
  width: min(420px, calc(100% - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 24px 80px rgba(20, 35, 45, 0.35);
}

.upload-dialog::backdrop {
  background: rgba(25, 38, 46, 0.46);
}

.upload-dialog form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.dialog-top,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-top h2 {
  margin: 0;
  font-size: 22px;
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.upload-preview {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border: 10px solid var(--frame-color, #fff);
  border-bottom-width: 22px;
  border-radius: 8px;
  background: #edf3f5;
  box-shadow: 0 8px 20px rgba(17, 31, 39, 0.16);
}

.upload-preview.preview-circle {
  aspect-ratio: 1;
  border-width: 8px;
  border-radius: 999px;
  object-fit: cover;
}

.upload-dialog label {
  display: grid;
  gap: 7px;
  color: var(--muted);
}

.upload-dialog input,
.upload-dialog select {
  min-height: 42px;
  border: 1px solid #cad5da;
  border-radius: 8px;
  padding: 9px 11px;
  background: #fff;
}

.image-dialog {
  width: min(1120px, calc(100% - 24px));
  max-height: calc(100vh - 24px);
  border: 0;
  border-radius: 8px;
  padding: 18px;
  color: #fff;
  background: rgba(18, 27, 34, 0.96);
  box-shadow: 0 24px 90px rgba(0,0,0,0.46);
}

.image-dialog::backdrop {
  background: rgba(8, 13, 17, 0.72);
}

.image-dialog img {
  display: block;
  width: 100%;
  max-height: calc(100vh - 120px);
  object-fit: contain;
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
}

.image-dialog p {
  margin: 12px 42px 0;
  overflow-wrap: anywhere;
  color: #9fc3ff;
  font-family: "Segoe Print", "Comic Sans MS", cursive;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0;
  text-align: center;
}

.comment-toggle {
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: inline-grid;
  min-width: 46px;
  height: 40px;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 999px;
  padding: 0 10px;
  color: #fff;
  background: #1656b8;
  box-shadow: 0 5px 14px rgba(22, 86, 184, 0.34);
}

.comments-panel {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding-right: 58px;
}

.comments-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
}

.comment-row {
  display: grid;
  gap: 4px;
  padding: 9px 11px;
  border-radius: 8px;
  color: #26343d;
  background: #f5f8fa;
}

.comment-row p {
  margin: 0;
  color: #26343d;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  font-weight: 400;
  text-align: left;
}

.comment-row time {
  color: #66727a;
  font-size: 12px;
}

.comment-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.comment-form input {
  min-height: 40px;
  border: 1px solid #cad5da;
  border-radius: 8px;
  padding: 9px 11px;
}

.image-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  background: rgba(255,255,255,0.16);
}

.image-close:hover {
  background: rgba(255,255,255,0.25);
}

.frame-choice {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.frame-choice button {
  min-height: 42px;
  padding: 9px 8px;
  color: #24313a;
  background: #dfe8ec;
}

.frame-choice button.active {
  color: #fff;
  background: #27323a;
}

.color-choice {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
}

.color-choice button {
  width: 100%;
  aspect-ratio: 1;
  min-height: 34px;
  border: 2px solid rgba(36, 49, 58, 0.18);
  border-radius: 999px;
  padding: 0;
  background: var(--frame-color, #fff);
}

.color-choice button[data-frame-color="white"] {
  --frame-color: #fff;
}

.color-choice button[data-frame-color="red"] {
  --frame-color: #ff8a7a;
}

.color-choice button[data-frame-color="orange"] {
  --frame-color: #ff9b32;
}

.color-choice button[data-frame-color="yellow"] {
  --frame-color: #ffe35a;
}

.color-choice button[data-frame-color="green"] {
  --frame-color: #54c46f;
}

.color-choice button[data-frame-color="blue"] {
  --frame-color: #4fc3f7;
}

.color-choice button.active {
  border-color: #27323a;
  box-shadow: 0 0 0 3px rgba(39, 50, 58, 0.12);
}

.admin-body {
  background: #f5f7f8;
}

.admin-shell {
  width: min(1100px, calc(100% - 28px));
  margin: 28px auto;
}

.admin-panel {
  padding: 22px;
  border: 1px solid #dfe6e9;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(30, 50, 60, 0.08);
}

.admin-section {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 2px dashed rgba(16, 24, 32, 0.42);
}

.admin-section:first-of-type {
  border-top-style: solid;
}

.admin-section > h2 {
  margin: 0 0 16px;
}

.admin-top,
.admin-subhead,
.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-identity span {
  font-weight: 700;
}

.profile-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0 24px;
  padding: 14px;
  border: 1px solid #dfe6e9;
  border-radius: 8px;
  background: #fbfcfc;
}

.profile-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
}

.profile-form input {
  min-height: 42px;
  border: 1px solid #cad5da;
  border-radius: 8px;
  padding: 9px 11px;
}

.profile-form button {
  align-self: end;
}

.storage-panel,
.backup-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid #dfe6e9;
  border-radius: 8px;
  background: #fbfcfc;
}

.storage-panel.warning {
  border-color: rgba(184, 50, 66, 0.38);
  background: #fff6f7;
}

.storage-panel h3,
.backup-panel h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.storage-heading {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 6px;
}

.storage-heading h3 {
  margin: 0;
}

.fridge-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid rgba(29, 132, 74, 0.42);
  border-radius: 999px;
  color: #1d844a;
  background: #effaf3;
  font-size: 13px;
  font-weight: 800;
}

.fridge-status.closed {
  border-color: rgba(184, 50, 66, 0.48);
  color: #b83242;
  background: #fff0f2;
}

.storage-panel p,
.backup-panel p {
  margin: 0;
  color: var(--muted);
}

.storage-actions,
.backup-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.backup-actions select {
  min-height: 42px;
  max-width: 360px;
  border: 1px solid #cad5da;
  border-radius: 8px;
  padding: 9px 11px;
}

.admin-top h1,
.admin-subhead h2,
.admin-panel h1 {
  margin: 0 0 18px;
}

.admin-top h1,
.admin-subhead h2 {
  margin-bottom: 0;
}

.form-row input,
.settings-grid input:not([type="checkbox"]),
.settings-grid select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cad5da;
  border-radius: 8px;
  padding: 9px 11px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.settings-grid label {
  display: grid;
  gap: 7px;
  color: var(--muted);
}

.settings-grid button {
  align-self: end;
}

.checkbox-row {
  display: flex !important;
  align-items: center;
  gap: 10px !important;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
}

.admin-magnets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.filter-row button {
  color: #24313a;
  background: #dfe8ec;
}

.filter-row button.active {
  color: #fff;
  background: #27323a;
}

.logs-actions {
  display: flex;
  gap: 8px;
}

.admin-card {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid #dfe6e9;
  border-radius: 8px;
  background: #fbfcfc;
}

.admin-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 6px;
  background: #edf3f5;
}

.admin-card .meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.admin-caption {
  min-height: 20px;
  overflow-wrap: anywhere;
  color: #1656b8;
  font-family: "Segoe Print", "Comic Sans MS", cursive;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0;
}

.admin-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
  padding: 16px;
  border: 1px solid rgba(184, 50, 66, 0.28);
  border-radius: 8px;
  background: #fff6f7;
}

.danger-zone h2 {
  margin: 0 0 6px;
  font-size: 18px;
}

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

.logs-head {
  margin-top: 26px;
}

.admin-logs {
  display: grid;
  gap: 7px;
  max-height: 320px;
  overflow: auto;
  margin-top: 14px;
  padding: 10px;
  border: 1px solid #dfe6e9;
  border-radius: 8px;
  background: #fbfcfc;
}

.log-row {
  overflow-wrap: anywhere;
  color: #53636d;
  font-size: 13px;
}

.danger {
  background: #b83242;
}

.secondary {
  color: #24313a;
  background: #dfe8ec;
}

@media (max-width: 720px) {
  .fridge-page {
    padding: 8px;
  }

  .fridge {
    min-height: calc(100vh - 16px);
    border-radius: 14px 14px 8px 8px;
  }

  .like {
    min-width: 46px;
    height: 42px;
    right: -14px;
    bottom: -22px;
    font-size: 16px;
  }

  .fridge-header {
    top: 24px;
    left: 18px;
    right: 32px;
  }

  .mobile-upload {
    display: flex;
  }

  .drop-hint {
    display: none;
  }

  .settings-grid,
  .admin-actions,
  .profile-form {
    grid-template-columns: 1fr;
  }

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

  .storage-panel,
  .backup-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .storage-actions,
  .backup-actions {
    flex-direction: column;
  }

  .backup-actions select {
    max-width: none;
    width: 100%;
  }

  .admin-top,
  .admin-subhead,
  .form-row {
    align-items: stretch;
    flex-direction: column;
  }

  .logs-actions {
    flex-direction: column;
  }
}

@media (pointer: coarse) {
  .mobile-upload {
    display: flex;
  }

  .drop-hint {
    display: none;
  }
}
