:root {
  color-scheme: light;
  --bg: #fbfaf6;
  --ink: #131313;
  --muted: #79756d;
  --line: #e7e2d8;
  --surface: #ffffff;
  --field: #f2efe7;
  --accent: #151515;
  --shadow: 0 18px 64px rgba(20, 20, 20, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(180deg, #fbfaf6 0%, #f4f0e7 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea {
  font: inherit;
}

.screen {
  width: min(100%, 760px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(26px, env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0 14px;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(18px);
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1;
  letter-spacing: 0;
}

.iconButton,
.plusButton {
  width: 48px;
  height: 48px;
  min-width: 48px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fffdf8;
  text-decoration: none;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(19, 19, 19, 0.14);
}

.iconButton span {
  display: block;
}

.iconButton.loading span {
  animation: spin 900ms linear infinite;
}

.memoryStack {
  padding: 10px 0 96px;
}

.memories {
  display: grid;
  gap: 10px;
}

.memory,
.emptyState {
  border: 1px solid rgba(19, 19, 19, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.memory {
  padding: 17px 16px 14px;
}

.memory p {
  margin: 0;
  color: var(--ink);
  font-size: clamp(19px, 5.4vw, 30px);
  line-height: 1.16;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.memoryMeta {
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

.emptyState {
  min-height: 42svh;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
}

.emptyState strong {
  font-size: 20px;
}

.emptyState span {
  color: var(--muted);
}

.plusButton {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  width: 58px;
  height: 58px;
  min-width: 58px;
  font-size: 36px;
  padding-bottom: 4px;
}

.noteScreen {
  width: 100%;
  max-width: none;
  padding: 0;
  background: var(--bg);
}

.noteForm {
  position: relative;
  min-height: 100svh;
}

textarea {
  width: 100%;
  min-height: 100svh;
  display: block;
  resize: none;
  border: 0;
  outline: 0;
  padding: max(22px, env(safe-area-inset-top)) 18px 112px;
  background: transparent;
  color: var(--ink);
  font-size: clamp(28px, 8vw, 52px);
  line-height: 1.08;
  letter-spacing: 0;
}

.noteActions {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
}

.ghost {
  background: rgba(21, 21, 21, 0.08);
  color: var(--ink);
  box-shadow: none;
}

.saveStatus {
  position: fixed;
  left: 18px;
  right: 130px;
  bottom: max(28px, calc(env(safe-area-inset-bottom) + 12px));
  margin: 0;
  color: #9b3321;
  font-size: 14px;
}

button:disabled {
  opacity: 0.48;
}

[hidden] {
  display: none !important;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (min-width: 720px) {
  .screen {
    padding-left: 24px;
    padding-right: 24px;
  }

  h1 {
    font-size: 32px;
  }

  .plusButton {
    right: calc(50vw - 356px);
  }
}
