.memory-canvas {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 21px 0;
  overflow: hidden;
}

.memory-canvas::-webkit-scrollbar {
  display: none;
}

html.desktop-scene-canvas .memory-canvas,
html.desktop-app-canvas .memory-canvas {
  overflow: hidden;
}

html.desktop-scene-canvas #memoryView.modal-view.active,
html.desktop-app-canvas #memoryView.modal-view.active {
  background: var(--memory-bg, #e5ece5);
}

.memory-canvas.reading-expanded,
.memory-canvas.composing {
  align-items: center;
}

html.desktop-scene-canvas .memory-canvas.reading-expanded,
html.desktop-scene-canvas .memory-canvas.composing,
html.desktop-app-canvas .memory-canvas.reading-expanded,
html.desktop-app-canvas .memory-canvas.composing {
  align-items: center;
}

.memory-card {
  flex: 0 0 auto;
  height: auto;
  max-height: calc(100% - 42px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
  touch-action: pan-y;
}

.memory-card::-webkit-scrollbar {
  display: none;
}

.memory-card.dragging {
  cursor: grabbing;
  user-select: none;
}

.memory-card button {
  cursor: pointer;
}

.memory-card textarea {
  cursor: text;
}

.memory-card.expanded,
.memory-card.composing {
  max-height: calc(100% - 42px);
  overflow-x: hidden;
  overflow-y: auto;
}

.memory-story-scroll {
  position: relative;
  flex: 0 1 auto;
  max-height: calc(100dvh - 248px);
  padding: 0 4px;
  overflow: hidden;
}

html.desktop-scene-canvas .memory-story-scroll,
html.desktop-app-canvas .memory-story-scroll {
  max-height: 601px;
}

html.desktop-scene-canvas .memory-card.expanded .memory-story-scroll,
html.desktop-app-canvas .memory-card.expanded .memory-story-scroll {
  max-height: none;
}

.memory-card.expanded .memory-story-scroll {
  flex: 0 0 auto;
  max-height: none;
  overflow: visible;
}

.memory-card .memory-text {
  flex: none;
  min-height: 72px;
  overflow: visible;
}

.toggle-memory-story {
  flex: 0 0 auto;
  align-self: center;
  margin: 7px auto 10px;
  padding: 5px 11px;
  border: 0;
  background: linear-gradient(90deg,transparent,#fffdf8 18%,#fffdf8 82%,transparent);
  color: #918475;
  font: 11px "Noto Serif SC", serif;
  cursor: pointer;
}

.toggle-memory-story::before,
.toggle-memory-story::after {
  content: "";
  display: inline-block;
  width: 34px;
  height: 1px;
  margin: 0 9px 3px;
  background: #e5dacd;
}

.memory-echo-section {
  margin: 8px 0 4px;
  text-align: left;
}

.memory-echo-section h2 {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 5px 0 20px;
  color: #9b8d7c;
  font: 400 12px "Noto Serif SC", serif;
  letter-spacing: .18em;
}

.memory-echo-section h2::before,
.memory-echo-section h2::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e7ded2;
}

.memory-echo-list {
  position: relative;
  margin-left: 5px;
  padding-left: 18px;
}

.memory-echo-list::before {
  content: "";
  position: absolute;
  top: 7px;
  bottom: 9px;
  left: 3px;
  width: 1px;
  background: #ddd2c4;
}

.memory-echo {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  margin-bottom: 22px;
}

.memory-echo-dot {
  position: absolute;
  top: 5px;
  left: -19px;
  width: 9px;
  height: 9px;
  border: 2px solid #fffdf8;
  border-radius: 50%;
  background: #b8a994;
  box-shadow: 0 0 0 1px #d8cbbb;
}

.memory-echo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 20px;
}

.memory-echo-head time {
  color: #9a948a;
  font: 10px "DM Mono", monospace;
}

.memory-echo-menu {
  min-width: 28px;
  border: 0;
  background: transparent;
  color: #a79e92;
  font: 15px/1 sans-serif;
  cursor: pointer;
}

.memory-echo-body > p {
  margin: 7px 0 0;
  color: #5d625d;
  font-size: 13px;
  line-height: 1.85;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.memory-echo-actions {
  display: none;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 5px;
}

.memory-echo.actions-open .memory-echo-actions {
  display: flex;
}

.memory-echo-actions button {
  padding: 2px;
  border: 0;
  background: transparent;
  color: #9b8f80;
  font: 10px "Noto Serif SC", serif;
  cursor: pointer;
}

.echo-composer-wrap {
  flex: 0 0 auto;
  padding-top: 10px;
  border-top: 1px solid #eee6dc;
}

.open-echo-composer {
  border: 0;
  background: transparent;
  color: #718078;
  padding: 7px 3px;
  font: 13px "Noto Serif SC", serif;
  cursor: pointer;
}

.open-echo-composer::before {
  content: "＋";
  margin-right: 6px;
  color: #b09576;
}

.echo-form {
  text-align: left;
}

.echo-form label {
  display: block;
  margin-bottom: 6px;
  color: #766d62;
  font-size: 12px;
}

.echo-form .echo-textarea {
  height: 54px;
  min-height: 54px;
  max-height: none;
  margin: 0;
  padding: 8px 2px;
  border-bottom-color: #ded4c7;
  overflow-y: hidden;
  resize: none;
  font-size: 13px;
  line-height: 26px;
  background: transparent;
  transition: height .16s ease;
}

.echo-form-meta,
.echo-form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.echo-form-meta {
  margin-top: 6px;
  color: #aaa297;
  font: 9px "DM Mono", monospace;
}

.echo-form-actions {
  position: relative;
  justify-content: center;
  min-height: 36px;
  margin-top: 12px;
}

.echo-form-actions button {
  padding: 7px 12px;
  border: 1px solid #ded4c7;
  border-radius: 99px;
  background: #fffdf8;
  color: #7b7166;
  font: 11px "Noto Serif SC", serif;
  cursor: pointer;
}

.echo-form-actions #saveEcho {
  min-width: 84px;
  border-color: #7d9984;
  background: #7d9984;
  color: white;
}

.echo-form-actions #cancelEcho {
  position: absolute;
  left: 0;
  border-color: transparent;
  background: transparent;
}

.memory-card > .quiet-button {
  flex: 0 0 auto;
  align-self: center;
  margin-top: 9px;
}

@media (max-width: 600px) {
  .memory-canvas {
    padding: 12px 0;
  }

  .memory-card {
    padding: 36px 24px 22px;
    max-height: calc(100% - 24px);
  }

  .memory-card.expanded,
  .memory-card.composing {
    max-height: calc(100% - 24px);
  }

  .memory-story-scroll {
    max-height: calc(100dvh - 226px);
    padding: 0 2px;
  }

  .memory-card.expanded .memory-story-scroll {
    max-height: none;
  }

  .memory-echo-body > p {
    font-size: 13px;
  }
}
