:root {
  color-scheme: light;
  --ink: #18201d;
  --muted: #6d756f;
  --paper: #f7f4ed;
  --panel: #fffdf8;
  --line: #ddd7c9;
  --accent: #236a62;
  --accent-2: #b4442f;
  --accent-3: #536c9d;
  --soft: #e8eee7;
  --shadow: 0 18px 55px rgba(37, 44, 40, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(35, 106, 98, 0.1), rgba(180, 68, 47, 0.06)),
    var(--paper);
}

button,
input,
textarea,
select {
  font: inherit;
  font-size: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 56px) 12px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-2);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 0;
  font-size: 1.25rem;
}

.date-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.78);
  box-shadow: var(--shadow);
}

.date-picker button,
.upload button,
.primary {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
}

.date-picker button {
  width: 40px;
  font-size: 1.5rem;
  line-height: 1;
}

.date-picker input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(340px, 0.92fr);
  gap: 18px;
  padding: 18px clamp(18px, 4vw, 56px) 44px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.9);
  box-shadow: var(--shadow);
}

.composer,
.memory-panel,
.explorer,
.import-panel {
  padding: 18px;
}

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

.primary {
  padding: 0 20px;
  font-weight: 800;
}

textarea {
  width: 100%;
  min-height: 280px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  color: var(--ink);
  background: #fff;
  line-height: 1.65;
}

input,
select {
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
}

.upload {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.upload input {
  flex: 1;
  padding-top: 9px;
}

.upload button {
  padding: 0 14px;
  font-weight: 800;
  white-space: nowrap;
}

.photo-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.photo-strip img,
.memory-photos img {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  object-fit: contain;
  border: 1px solid var(--line);
  background: #f0ede5;
  cursor: zoom-in;
}

.photo-strip img:focus-visible,
.memory-photos img:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.photo-viewer {
  width: min(96vw, 1400px);
  max-width: none;
  height: min(94vh, 1000px);
  max-height: none;
  margin: auto;
  padding: 46px 16px 16px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: rgba(18, 22, 20, 0.96);
}

.photo-viewer::backdrop {
  background: rgba(0, 0, 0, 0.78);
}

.photo-viewer[open] {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.photo-viewer img {
  display: block;
  max-width: 100%;
  min-height: 0;
  max-height: calc(100% - 30px);
  object-fit: contain;
}

.photo-viewer p {
  max-width: 100%;
  margin: 0;
  overflow: hidden;
  color: #e8e8e8;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-viewer-close {
  position: absolute;
  top: 8px;
  right: 12px;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  color: #fff;
  background: transparent;
  cursor: pointer;
  font-size: 2rem;
  line-height: 1;
}

.memories {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.memory {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.memory.current {
  border-color: rgba(35, 106, 98, 0.45);
  background: var(--soft);
}

.memory h3 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 1.05rem;
}

.memory time {
  color: var(--muted);
  font-size: 0.82rem;
}

.markdown {
  white-space: pre-wrap;
  line-height: 1.58;
}

.memory-photos {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: var(--ink);
  box-shadow: var(--shadow);
  font-weight: 700;
}

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

@media (max-width: 780px) {
  body {
    background: var(--paper);
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
    padding: 18px 14px 8px;
  }

  h1 {
    font-size: 2.25rem;
  }

  .date-picker {
    width: 100%;
    box-shadow: none;
  }

  .date-picker input {
    flex: 1;
    width: 100%;
  }

  .layout {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 14px 14px 32px;
  }

  .composer,
  .memory-panel {
    padding: 14px;
  }

  .panel {
    box-shadow: none;
  }

  .panel-head {
    align-items: center;
  }

  .primary,
  .upload button {
    min-width: 84px;
  }

  textarea {
    min-height: 220px;
    padding: 14px;
  }

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

  .upload input,
  .upload button {
    width: 100%;
  }

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

  .memory h3 {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

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

  .toast {
    right: 14px;
    bottom: 14px;
    max-width: calc(100vw - 28px);
  }
}

@media (max-width: 920px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .date-picker {
    width: 100%;
  }

  .date-picker input {
    flex: 1;
  }
}

@media (max-width: 560px) {
  .memory-photos {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .upload button,
  .upload input {
    width: 100%;
  }
}
