:root {
  color-scheme: light;
  --paper: #ffffff;
  --ink: #111111;
  --muted: #8d8d8d;
  --line: #dedede;
  --surface: #f6f6f6;
  --dream: #4fd5f4;
  --dream-soft: rgba(79, 213, 244, 0.34);
  --journal: #ff5fb2;
  --journal-soft: rgba(255, 95, 178, 0.32);
  --both: #c264f4;
  --both-soft: rgba(194, 100, 244, 0.32);
  --danger: #b42318;
  --focus: #2e6f95;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  background: #f3f3f3;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: #f3f3f3;
  color: var(--ink);
  letter-spacing: 0;
}

html.sheet-open,
body.sheet-open {
  overflow: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
  letter-spacing: 0;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  min-height: 100vh;
}

.device {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(100%, 430px);
  min-height: 100svh;
  margin: 0 auto;
  overflow: clip;
  background: var(--paper);
  transition: background-color 160ms ease;
}

.device.theme-dream {
  background:
    radial-gradient(circle at 4% 3%, var(--dream-soft), transparent 38%),
    radial-gradient(circle at 94% 84%, var(--dream-soft), transparent 34%),
    var(--paper);
}

.device.theme-journal {
  background:
    radial-gradient(circle at 4% 6%, var(--journal-soft), transparent 38%),
    radial-gradient(circle at 92% 68%, var(--journal-soft), transparent 36%),
    var(--paper);
}

.device.theme-both {
  background:
    radial-gradient(circle at 4% 6%, var(--both-soft), transparent 38%),
    radial-gradient(circle at 92% 72%, var(--both-soft), transparent 36%),
    var(--paper);
}

.device.theme-custom {
  background:
    radial-gradient(circle at 4% 6%, var(--custom-type-soft), transparent 38%),
    radial-gradient(circle at 92% 72%, var(--custom-type-soft), transparent 36%),
    var(--paper);
}

.view {
  flex: 1;
  min-width: 0;
  padding: max(24px, env(safe-area-inset-top)) 22px 28px;
}

.device:not(.editor-active) .view {
  padding-top: 0;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

.screen {
  display: grid;
  gap: 22px;
  min-width: 0;
}

.device.auth-active {
  background: var(--paper);
}

.device.auth-active .view {
  display: flex;
  min-height: 100svh;
  padding: max(28px, env(safe-area-inset-top)) 24px max(28px, env(safe-area-inset-bottom));
}

.device.auth-active .bottom-nav {
  display: none;
}

.auth-screen {
  display: grid;
  flex: 1;
  place-items: center;
  width: 100%;
  min-width: 0;
}

.auth-panel {
  display: grid;
  width: min(100%, 320px);
  gap: 28px;
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.auth-brand img {
  width: 34px;
  height: auto;
}

.auth-heading {
  display: grid;
  gap: 8px;
  text-align: center;
}

.auth-heading h1,
.auth-heading p {
  margin: 0;
}

.auth-heading h1 {
  font-size: 1.55rem;
  font-weight: 560;
}

.auth-heading p {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.auth-form {
  display: grid;
  gap: 18px;
}

.auth-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
}

.auth-field input {
  width: 100%;
  height: 44px;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-size: 1rem;
}

.auth-field input[readonly] {
  color: #555555;
}

.auth-error {
  min-height: 20px;
  margin: -4px 0 0;
  color: var(--danger);
  font-size: 0.78rem;
  line-height: 1.45;
  text-align: center;
}

.auth-submit {
  width: 100%;
  min-height: 48px;
}

.auth-submit:disabled {
  cursor: wait;
  opacity: 0.58;
}

.auth-loading {
  justify-items: center;
  gap: 18px;
}

.auth-progress {
  width: 28px;
  height: 1px;
  overflow: hidden;
  background: var(--line);
}

.auth-progress::after {
  display: block;
  width: 50%;
  height: 100%;
  background: var(--ink);
  content: "";
  animation: auth-progress 900ms ease-in-out infinite alternate;
}

@keyframes auth-progress {
  from { transform: translateX(0); }
  to { transform: translateX(100%); }
}

.calendar-sticky {
  position: sticky;
  top: 0;
  z-index: 6;
  display: grid;
  gap: 14px;
  padding: max(32px, env(safe-area-inset-top)) 0 14px;
  background: var(--paper);
}

.screen-header {
  display: grid;
  gap: 5px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 44px;
  margin: 0;
  font-weight: 500;
}

.brand svg {
  width: 22px;
  height: 22px;
  color: #adadad;
}

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.title-row h1,
.title-row h2,
.editor-header h1,
.settings-title {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 3px;
}

.icon-button,
.nav-button,
.text-button,
.date-button,
.day-button,
.setting-button,
.month-option,
.editor-tool,
.image-option,
.entry-choice,
.editor-type-button,
.editor-code-date {
  border: 0;
  background: transparent;
  color: inherit;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
}

.icon-button svg {
  width: 23px;
  height: 23px;
}

[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 7px);
  z-index: 16;
  width: max-content;
  max-width: 180px;
  padding: 5px 7px;
  border-radius: 4px;
  background: var(--ink);
  color: var(--paper);
  content: attr(data-tooltip);
  font-size: 0.75rem;
  line-height: 1.2;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  visibility: hidden;
  transition:
    opacity 120ms ease,
    transform 120ms ease,
    visibility 0s linear 120ms;
  white-space: nowrap;
}

@media (hover: hover) {
  [data-tooltip]:hover::after {
    opacity: 1;
    transform: translate(-50%, 0);
    visibility: visible;
    transition-delay: 1.5s;
  }
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 8;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  width: min(calc(100% - 44px), 386px);
  min-height: 74px;
  margin: 0;
  padding: 10px 0 max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  transform: translateX(-50%);
}

.device.theme-dream .bottom-nav,
.device.theme-journal .bottom-nav,
.device.theme-both .bottom-nav,
.device.theme-custom .bottom-nav {
  background: rgba(255, 255, 255, 0.72);
}

.nav-button {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 5px;
  min-width: 0;
  min-height: 50px;
  padding: 0;
}

.nav-button svg {
  width: 25px;
  height: 25px;
}

.nav-marker {
  width: 18px;
  height: 2px;
  background: transparent;
}

.nav-button[aria-current="page"] .nav-marker {
  background: var(--ink);
}

.field-label {
  color: var(--muted);
}

.select-control {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
}

.entry-swatch,
.editor-code-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--entry-type-color, var(--muted));
  box-shadow: 0 0 9px 4px var(--entry-type-soft, rgba(141, 141, 141, 0.25));
}

.dream-dot {
  background: var(--dream);
  box-shadow: 0 0 9px 4px var(--dream-soft);
}

.journal-dot {
  background: var(--journal);
  box-shadow: 0 0 9px 4px var(--journal-soft);
}

.both-dot {
  background: var(--both);
  box-shadow: 0 0 9px 4px var(--both-soft);
}

.weekday-row,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekday-row {
  gap: 2px;
  color: var(--muted);
  font-size: 0.78rem;
}

.weekday-row span {
  text-align: center;
}

.calendar-stream {
  display: grid;
  gap: 34px;
  transform: translate3d(0, var(--calendar-future-pull, 0), 0);
}

.calendar-stream.is-pulling-future {
  will-change: transform;
}

.calendar-stream.is-rebounding-future {
  transition: transform 240ms cubic-bezier(0.22, 0.8, 0.32, 1);
}

.calendar-sentinel {
  height: 1px;
}

.month-section {
  display: grid;
  gap: 12px;
  scroll-margin-top: 150px;
}

.month-section h2 {
  margin: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 1.15rem;
  font-weight: 400;
}

.calendar-grid {
  gap: 7px 2px;
}

.day-button {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 44px;
  padding: 0;
  border-radius: 50%;
  font-variant-numeric: tabular-nums;
  touch-action: manipulation;
  user-select: none;
  -webkit-touch-callout: none;
}

.day-button:hover {
  background: rgba(0, 0, 0, 0.035);
}

.day-button[aria-pressed="true"] {
  box-shadow: inset 0 0 0 1px rgba(17, 17, 17, 0.45);
}

.day-button .date-glow {
  position: absolute;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  filter: blur(2px);
  transition: filter 120ms ease, transform 120ms ease;
}

.day-button .day-number {
  position: relative;
  z-index: 2;
}

.day-button.is-today::after {
  position: absolute;
  z-index: 1;
  width: 30px;
  height: 30px;
  box-sizing: border-box;
  border: 1px solid rgba(17, 17, 17, 0.72);
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.day-button.is-pressing {
  background: var(--surface);
}

.day-button.is-pressing .date-glow {
  filter: blur(1px);
  transform: scale(1.08);
}

.day-button.has-mark .date-glow {
  background: var(--entry-type-soft);
  box-shadow: 0 0 12px 7px var(--entry-type-soft);
}

.today-button {
  position: fixed;
  left: max(18px, calc(50vw - 197px));
  bottom: calc(88px + env(safe-area-inset-bottom));
  z-index: 12;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.13);
  backdrop-filter: blur(10px);
}

.today-button svg {
  width: 21px;
  height: 21px;
}

.records-screen {
  position: relative;
  isolation: isolate;
  gap: 26px;
}

.overview-backdrop {
  position: fixed;
  top: 0;
  bottom: calc(74px + env(safe-area-inset-bottom));
  left: 50%;
  z-index: 0;
  width: min(100%, 430px);
  overflow: hidden;
  pointer-events: none;
  transform: translateX(-50%);
}

.overview-color-block {
  position: absolute;
  top: var(--block-top);
  left: var(--block-left);
  display: block;
  width: var(--block-width);
  aspect-ratio: var(--block-ratio);
  border-radius: 50%;
  filter: blur(24px);
  opacity: 0.6;
}

.block-dream { background: var(--dream-soft); }
.block-journal { background: var(--journal-soft); }
.block-both { background: var(--both-soft); }

.records-screen > .screen-header,
.record-stream {
  position: relative;
  z-index: 1;
}

.records-screen > .records-sticky {
  position: sticky;
  top: 0;
  z-index: 6;
  margin-inline: -22px;
  padding: max(32px, env(safe-area-inset-top)) 22px 15px;
  background: transparent;
}

.records-sticky .brand-bubble {
  display: block;
  width: 40px;
  height: auto;
  object-fit: contain;
}

.records-selection-toggle {
  opacity: 0.58;
}

.records-selection-toggle[aria-pressed="true"] {
  opacity: 1;
}

.records-selection-toggle svg {
  width: 21px !important;
  height: 21px !important;
}

.records-sticky .title-row {
  gap: 8px;
  margin-top: 2px;
}

.records-sticky .header-actions {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(4, 36px);
  gap: 3px;
}

.records-sticky .header-actions .icon-button {
  width: 36px;
  height: 40px;
}

.records-sticky .icon-button svg {
  width: 25px;
  height: 25px;
}

.records-sticky .records-expand-button {
  opacity: 0.58;
}

.records-sticky .records-expand-button svg {
  width: 19px;
  height: 19px;
}

.records-screen.is-selecting .records-primary-actions .icon-button:not(.records-selection-toggle) {
  visibility: hidden;
}

.record-stream {
  display: grid;
  gap: 0;
  padding: 6px 0 0;
  transform: translate3d(0, var(--record-pull, 0), 0);
}

.record-stream.is-pulling {
  will-change: transform;
}

.record-stream.is-rebounding {
  transition: transform 240ms cubic-bezier(0.22, 0.8, 0.32, 1);
}

.record-month {
  display: grid;
  gap: 24px;
  min-height: 200px;
  padding: 6px 0 42px;
  scroll-margin-top: 112px;
}

.record-month-empty {
  display: grid;
  min-height: 156px;
  place-items: center;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.record-piece {
  position: relative;
  display: grid;
  align-content: start;
  gap: 18px;
  min-height: 148px;
  padding: 19px 22px 22px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(10px);
  cursor: pointer;
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0,
    transparent var(--record-header-cutoff, 0px),
    #000 var(--record-header-fade-end, 0px),
    #000 100%
  );
  mask-image: linear-gradient(
    to bottom,
    transparent 0,
    transparent var(--record-header-cutoff, 0px),
    #000 var(--record-header-fade-end, 0px),
    #000 100%
  );
  transition: background-color 140ms ease, box-shadow 140ms ease;
}

.record-piece.is-behind-records-header {
  pointer-events: none;
}

.record-piece:hover {
  background: rgba(255, 255, 255, 0.68);
}

.record-piece:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.record-piece.is-selected {
  background: rgba(255, 255, 255, 0.78);
  box-shadow: inset 0 0 0 1px rgba(17, 17, 17, 0.3);
}

.record-piece.is-date-index-target {
  animation: record-date-target-breathe 680ms ease-in-out 2;
}

@keyframes record-date-target-breathe {
  0%,
  100% {
    background-color: rgba(255, 255, 255, 0.6);
    box-shadow: 0 0 0 rgba(255, 255, 255, 0);
  }

  50% {
    background-color: rgba(255, 255, 255, 0.9);
    box-shadow: 0 5px 22px rgba(255, 255, 255, 0.72);
  }
}

.record-select-indicator {
  position: absolute;
  top: 17px;
  left: 18px;
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 1px solid rgba(17, 17, 17, 0.34);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.56);
  opacity: 0;
  pointer-events: none;
  transform: scale(0.84);
  transition: opacity 140ms ease, transform 140ms ease, background-color 140ms ease;
}

.record-select-indicator svg {
  width: 13px;
  height: 13px;
  opacity: 0;
}

.records-screen.is-selecting .record-select-indicator {
  opacity: 1;
  transform: scale(1);
}

.records-screen.is-selecting .record-piece.is-selected .record-select-indicator {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.records-screen.is-selecting .record-piece.is-selected .record-select-indicator svg {
  opacity: 1;
}

.record-meta {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 7px;
  min-height: 20px;
}

.record-lock-icon {
  width: 14px;
  height: 14px;
  color: #6f6f6f;
}

.record-date {
  justify-self: end;
  padding: 0;
  font-size: 0.88rem;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 1px;
}

.record-piece .record-date { text-decoration-color: var(--entry-type-color); }

.record-selection-toolbar {
  position: fixed;
  left: 50%;
  bottom: calc(82px + env(safe-area-inset-bottom));
  z-index: 12;
  display: grid;
  grid-template-columns: minmax(34px, auto) repeat(4, 42px);
  align-items: center;
  justify-content: end;
  gap: 3px;
  width: min(calc(100% - 44px), 386px);
  min-height: 54px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 5px 20px rgba(17, 17, 17, 0.12);
  backdrop-filter: blur(16px);
  transform: translateX(-50%);
}

.record-selection-count {
  min-width: 34px;
  padding-inline: 8px;
  color: #666666;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  text-align: left;
}

.record-selection-toolbar .icon-button {
  width: 42px;
  height: 42px;
  border-radius: 6px;
}

.record-selection-toolbar .icon-button:hover {
  background: rgba(17, 17, 17, 0.05);
}

.record-selection-toolbar .icon-button:disabled {
  cursor: default;
  opacity: 0.24;
}

.record-selection-delete {
  color: var(--danger);
}

.record-title {
  display: block;
  min-width: 0;
  overflow: hidden;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-preview {
  display: grid;
  min-width: 0;
  overflow: hidden;
  line-height: 1.55;
}

.record-body {
  display: block;
  min-width: 0;
  max-height: 3.1em;
  overflow: hidden;
  white-space: pre-wrap;
}

.record-title + .record-body {
  max-height: 1.55em;
}

@media (prefers-reduced-motion: reduce) {
  .record-stream.is-rebounding {
    transition-duration: 1ms;
  }

  .record-piece.is-date-index-target {
    animation-duration: 1ms;
    animation-iteration-count: 1;
  }
}

.record-stream.is-expanded .record-preview,
.record-stream.is-expanded .record-title,
.record-stream.is-expanded .record-body {
  display: block;
  max-height: none;
  overflow: visible;
  text-overflow: clip;
  white-space: pre-wrap;
}

.settings-screen {
  gap: 30px;
}

.settings-screen > .screen-header {
  position: sticky;
  top: 0;
  z-index: 6;
  padding: max(32px, env(safe-area-inset-top)) 0 15px;
  background: var(--paper);
}

.settings-title {
  margin: 0;
}

.settings-section {
  display: grid;
  gap: 8px;
}

.settings-section h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
}

.setting-row,
.setting-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 4px 0;
}

.setting-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.setting-label svg,
.setting-button > svg {
  width: 19px;
  height: 19px;
}

.setting-button {
  width: 100%;
  text-align: left;
}

.color-input {
  width: 38px;
  height: 38px;
  padding: 3px;
  border: 0;
  border-radius: 50%;
  background: transparent;
}

.color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-input::-webkit-color-swatch {
  border: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(17, 17, 17, 0.08);
}

.color-input::-moz-color-swatch {
  border: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(17, 17, 17, 0.08);
}

.custom-type-list {
  display: grid;
  gap: 4px;
}

.custom-type-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 8px;
  min-height: 48px;
}

.custom-type-name {
  min-width: 0;
  height: 40px;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
}

.custom-type-name:focus,
.custom-type-name:focus-visible {
  border-bottom-color: rgba(17, 17, 17, 0.42);
  outline: 0;
}

.custom-type-delete {
  color: var(--danger);
}

.settings-empty {
  margin: 6px 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.switch {
  position: relative;
  width: 42px;
  height: 24px;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  background: #cfcfcf;
  transition: background-color 140ms ease;
}

.switch-track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  content: "";
  transition: transform 140ms ease;
}

.switch input:checked + .switch-track {
  background: var(--ink);
}

.switch input:checked + .switch-track::after {
  transform: translateX(18px);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.editor-screen {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: calc(100svh - 52px);
  gap: 22px;
}

.editor-entry-backdrop {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 50%;
  z-index: 0;
  width: min(100%, 430px);
  overflow: hidden;
  pointer-events: none;
  transform: translateX(-50%);
}

.editor-entry-spot {
  position: absolute;
  top: var(--spot-top);
  left: var(--spot-left);
  width: var(--spot-size);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--spot-color);
  filter: blur(var(--spot-blur));
  opacity: var(--spot-opacity);
  transform: translate(-50%, -50%);
}

.device.editor-active .bottom-nav {
  display: none;
}

.editor-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
}

.editor-header h1 {
  min-width: 0;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.editor-header .icon-button {
  width: 28px;
  height: 40px;
  justify-content: start;
}

.editor-header .text-button {
  min-height: 40px;
  padding: 0;
}

.editor-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.editor-header-actions .icon-button {
  justify-content: center;
  width: 32px;
}

.editor-header-actions .icon-button svg {
  width: 20px;
  height: 20px;
}

.editor-lock-status {
  display: inline-grid;
  width: 32px;
  height: 40px;
  place-items: center;
  color: #6f6f6f;
}

.editor-lock-status svg {
  width: 18px;
  height: 18px;
}

.editor-code-line {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
  color: #4f4f4f;
  font-size: 0.83rem;
}

.editor-type-button,
.editor-type-static {
  display: grid;
  place-items: center;
  width: 32px;
  height: 40px;
  padding: 0;
}

.editor-type-static {
  flex: 0 0 32px;
}

.editor-code-date {
  min-height: 40px;
  padding: 0;
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: var(--entry-type-color, currentColor);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.editor-code-dot.type-dream { background: var(--dream); box-shadow: 0 0 9px 4px var(--dream-soft); }
.editor-code-dot.type-journal { background: var(--journal); box-shadow: 0 0 9px 4px var(--journal-soft); }
.editor-code-dot.type-both { background: var(--both); box-shadow: 0 0 9px 4px var(--both-soft); }

.editor-surface {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 16px;
  min-height: calc(100svh - 126px);
  padding: 18px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.4);
}

.editor-form {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 7px;
}

.editor-title,
.editor-content {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
}

.editor-title {
  min-height: 34px;
  padding: 5px;
  border-radius: 4px;
  font-weight: 500;
  outline: 1px solid rgba(17, 17, 17, 0.06);
  outline-offset: 0;
}

.editor-content {
  flex: 1;
  min-height: 240px;
  padding: 5px;
  border-radius: 4px;
  outline: 1px solid rgba(17, 17, 17, 0.06);
  outline-offset: 0;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.editor-title:focus,
.editor-title:focus-visible,
.editor-content:focus {
  outline: 1px solid rgba(17, 17, 17, 0.1);
  outline-offset: 0;
}

.editor-content:empty::before {
  color: var(--muted);
  content: attr(data-placeholder);
  pointer-events: none;
}

.editor-screen.is-readonly .editor-content {
  outline: 0;
  cursor: default;
  user-select: text;
}

.editor-screen.is-readonly .editor-title {
  outline: 0;
  cursor: default;
}

.editor-screen.is-readonly .entry-image-frame {
  cursor: default;
}

.editor-screen.is-readonly .entry-image-frame:hover {
  box-shadow: none;
}

.entry-image-frame {
  --image-crop-x: 50%;
  --image-crop-y: 50%;
  --image-crop-zoom: 1;
  position: relative;
  overflow: hidden;
  margin: 12px 0;
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}

.entry-image-frame:hover {
  box-shadow: 0 0 0 1px rgba(17, 17, 17, 0.16);
}

.entry-image-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--image-crop-x) var(--image-crop-y);
  transform: scale(var(--image-crop-zoom));
  transform-origin: var(--image-crop-x) var(--image-crop-y);
}

.entry-image-frame.image-size-small { width: min(42%, 120px); }
.entry-image-frame.image-size-medium { width: min(68%, 210px); }
.entry-image-frame.image-size-large { width: 100%; }

.entry-image-frame[data-ratio="1:1"],
.image-crop-preview[data-ratio="1:1"] { aspect-ratio: 1 / 1; }
.entry-image-frame[data-ratio="3:4"],
.image-crop-preview[data-ratio="3:4"] { aspect-ratio: 3 / 4; }
.entry-image-frame[data-ratio="4:3"],
.image-crop-preview[data-ratio="4:3"] { aspect-ratio: 4 / 3; }
.entry-image-frame[data-ratio="1:2"],
.image-crop-preview[data-ratio="1:2"] { aspect-ratio: 1 / 2; }
.entry-image-frame[data-ratio="2:1"],
.image-crop-preview[data-ratio="2:1"] { aspect-ratio: 2 / 1; }

.editor-toolbar {
  position: sticky;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 7;
  display: flex;
  align-items: center;
  align-self: flex-end;
  gap: 2px;
  max-width: 100%;
  padding: 5px;
  overflow-x: auto;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  scrollbar-width: none;
}

.editor-toolbar::-webkit-scrollbar {
  display: none;
}

.device.keyboard-visible .editor-surface {
  padding-bottom: 68px;
}

.device.keyboard-visible .editor-screen {
  padding-bottom: 60vh;
}

.device.keyboard-visible .editor-toolbar {
  position: fixed;
  top: var(--editor-toolbar-top, auto);
  right: max(22px, calc((100vw - 430px) / 2 + 22px));
  bottom: auto;
  z-index: 18;
}

.editor-tool {
  display: inline-grid;
  flex: 0 0 36px;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 4px;
}

.editor-tool svg {
  width: 19px;
  height: 19px;
}

.editor-tool:hover,
.editor-tool[aria-pressed="true"] {
  background: var(--surface);
}

.editor-tool:disabled {
  opacity: 0.45;
}

.editor-tool-separator {
  flex: 0 0 1px;
  width: 1px;
  height: 20px;
  margin: 0 3px;
  background: var(--line);
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  background: rgba(0, 0, 0, 0.25);
}

.sheet {
  display: grid;
  gap: 16px;
  width: min(100%, 430px);
  padding: 12px 22px max(22px, env(safe-area-inset-bottom));
  border-radius: 8px 8px 0 0;
  background: var(--paper);
}

.sheet:focus {
  outline: none;
}

.sheet h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 500;
}

#entry-sheet {
  align-items: center;
  padding: 22px;
}

#entry-date-sheet {
  align-items: center;
  padding: 22px;
}

#records-date-index-sheet {
  align-items: center;
  padding: 22px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

#records-delete-sheet {
  align-items: center;
  padding: 22px;
}

#entry-share-sheet {
  align-items: center;
  padding: 22px;
  background: rgba(17, 17, 17, 0.14);
}

.entry-picker-sheet {
  width: min(100%, 386px);
  gap: 10px;
  padding: 16px 20px;
  border-radius: 8px;
}

.entry-picker-sheet .sheet-cancel {
  margin-top: 2px;
}

.entry-date-sheet {
  width: min(100%, 386px);
  padding: 20px;
  border-radius: 8px;
}

.records-date-index-sheet {
  width: min(100%, 386px);
  max-height: min(72svh, 620px);
  padding: 24px 20px;
  border: 1px solid rgba(17, 17, 17, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 36px rgba(17, 17, 17, 0.1);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.records-date-index-content {
  display: grid;
  gap: 24px;
}

.records-date-index-month {
  display: grid;
  gap: 12px;
}

.records-date-index-month h2 {
  margin: 0;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line);
  color: #626262;
  font-size: 1.08rem;
  font-weight: 400;
}

.records-date-index-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px 8px;
}

.records-date-index-day {
  position: relative;
  z-index: 0;
  display: flex;
  min-width: 0;
  min-height: 40px;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  padding: 3px 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.records-date-index-day::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  border-radius: inherit;
  background: var(--entry-type-color);
  content: "";
  opacity: 0.4;
}

.records-date-index-day:hover {
  filter: saturate(1.08);
}

.records-date-index-number {
  font-size: 1.2rem;
}

.records-date-index-weekday {
  min-width: 0;
  overflow: hidden;
  color: #777777;
  font-size: 0.7rem;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.records-date-index-empty {
  margin: 0;
  padding: 42px 0;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

.records-delete-sheet {
  width: min(100%, 386px);
  gap: 14px;
  padding: 20px;
  border-radius: 8px;
}

.records-delete-sheet p {
  margin: 0;
  color: #626262;
  font-size: 0.9rem;
  line-height: 1.55;
}

.records-delete-sheet .text-button,
.records-delete-sheet .primary-button {
  min-width: 84px;
  min-height: 42px;
}

.danger-button {
  background: var(--danger);
}

.entry-share-sheet {
  position: relative;
  width: min(100%, 344px);
  padding: 18px 14px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 36px rgba(17, 17, 17, 0.12);
  backdrop-filter: blur(18px);
}

.share-sheet-close {
  position: absolute;
  top: 7px;
  right: 7px;
  z-index: 1;
  width: 36px;
  height: 36px;
  color: #6f6f6f;
}

.share-sheet-close svg {
  width: 18px;
  height: 18px;
}

.entry-share-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding-top: 25px;
}

.share-choice {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  min-width: 0;
  min-height: 84px;
  padding: 8px 4px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
}

.share-choice svg {
  width: 24px;
  height: 24px;
}

.share-choice span {
  color: #5f5f5f;
  font-size: 0.78rem;
  white-space: nowrap;
}

.share-choice:hover,
.share-choice:focus-visible,
.share-sheet-close:hover {
  background: rgba(17, 17, 17, 0.055);
}

.entry-share-sheet [data-entry-share]:disabled {
  opacity: 0.45;
}

.date-control {
  width: 100%;
  min-height: 46px;
  padding: 0 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.entry-date-sheet .sheet-confirm-actions .text-button,
.entry-date-sheet .sheet-confirm-actions .primary-button {
  min-width: 84px;
  min-height: 42px;
}

.month-picker-sheet {
  gap: 18px;
}

.month-picker-year {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 8px;
}

.month-picker-year .icon-button {
  width: 44px;
  height: 44px;
}

.month-year-input {
  min-width: 0;
  height: 44px;
  padding: 0 8px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.month-picker-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px 6px;
}

.month-option {
  min-width: 0;
  min-height: 48px;
  padding: 0 4px;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
}

.month-option:hover {
  background: var(--surface);
}

.month-option[aria-current="date"] {
  background: var(--ink);
  color: var(--paper);
}

.month-option:disabled {
  cursor: default;
  opacity: 0.22;
}

.image-options-sheet {
  max-height: calc(100svh - 18px);
  overflow-y: auto;
}

.image-preview-stage {
  display: grid;
  place-items: center;
  gap: 14px;
  min-height: 220px;
}

.image-crop-preview {
  --image-crop-x: 50%;
  --image-crop-y: 50%;
  --image-crop-zoom: 1;
  position: relative;
  width: min(100%, 280px);
  max-height: 330px;
  overflow: hidden;
  border-radius: 6px;
  background: #ededed;
  box-shadow: 0 0 0 1px rgba(17, 17, 17, 0.12);
  cursor: grab;
  touch-action: none;
  transition: aspect-ratio 140ms ease;
  user-select: none;
}

.image-crop-preview::after {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255, 255, 255, 0.72);
  content: "";
  pointer-events: none;
}

.image-crop-preview.is-dragging {
  cursor: grabbing;
}

.image-crop-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--image-crop-x) var(--image-crop-y);
  pointer-events: none;
  transform: scale(var(--image-crop-zoom));
  transform-origin: var(--image-crop-x) var(--image-crop-y);
  will-change: transform;
}

.image-zoom-control {
  width: min(100%, 280px);
  height: 28px;
  margin: 0;
  accent-color: var(--ink);
}

.image-option-group {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  border: 0;
}

.image-option-group legend {
  padding: 0;
  font-size: 0.88rem;
  font-weight: 500;
}

.image-option-grid {
  display: grid;
  gap: 6px;
}

.ratio-options {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.size-options {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.image-option {
  min-width: 0;
  min-height: 42px;
  padding: 0 4px;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
}

.image-option:hover,
.image-option[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

.sheet-command-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sheet-confirm-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.sheet-command-row .text-button,
.sheet-command-row .primary-button {
  min-width: 84px;
  min-height: 42px;
}

.image-delete-button {
  color: var(--danger);
}

.sheet-handle {
  justify-self: center;
  width: 36px;
  height: 4px;
  border-radius: 4px;
  background: #cfcfcf;
}

.sheet-actions {
  display: grid;
  gap: 6px;
}

.entry-choice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 50px;
  padding: 6px 0;
  text-align: left;
}

.entry-choice svg {
  width: 18px;
  height: 18px;
}

.entry-share-document {
  position: fixed;
  top: 0;
  left: -10000px;
  width: 720px;
  min-height: 960px;
  padding: 62px 66px 72px;
  background:
    radial-gradient(circle at 4% 6%, var(--entry-type-soft, rgba(194, 100, 244, 0.32)), transparent 39%),
    radial-gradient(circle at 96% 86%, var(--entry-type-soft, rgba(194, 100, 244, 0.32)), transparent 37%),
    #ffffff;
  color: #111111;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 24px;
  letter-spacing: 0;
  line-height: 1.65;
}

.entry-share-document-item {
  padding: 42px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.6);
}

.entry-share-document-item:only-child {
  min-height: 826px;
}

.entry-share-document-item + .entry-share-document-item {
  margin-top: 34px;
}

.entry-share-document-header {
  display: grid;
  gap: 12px;
  padding-bottom: 24px;
  margin-bottom: 42px;
  border-bottom: 1px solid #e7e7e7;
}

.entry-share-document-date {
  margin: 0;
  font-size: 30px;
  font-weight: 500;
  white-space: nowrap;
}

.entry-share-document-type {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 10px;
  color: #595959;
  font-size: 20px;
  white-space: nowrap;
}

.entry-share-document-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--entry-type-color, #111111);
  box-shadow: 0 0 12px 4px var(--entry-type-soft, rgba(17, 17, 17, 0.12));
}

.entry-share-document-title {
  margin: 0 0 22px;
  font-size: 32px;
  font-weight: 600;
  line-height: 1.35;
}

.entry-share-document-body {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.entry-share-document-body .entry-image-frame {
  break-inside: avoid;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
}

.primary-button svg {
  width: 18px;
  height: 18px;
}

.sheet-cancel {
  min-height: 42px;
  padding: 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  z-index: 30;
  max-width: calc(100% - 32px);
  padding: 9px 14px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
  transform: translateX(-50%);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 600px) {
  .device {
    min-height: 900px;
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.08);
  }
}

@media (max-width: 360px) {
  .view {
    padding-inline: 16px;
  }

  .bottom-nav {
    width: calc(100% - 32px);
  }

  .record-selection-toolbar {
    grid-template-columns: minmax(28px, auto) repeat(4, 40px);
    width: calc(100% - 32px);
    padding-inline: 6px;
  }

  .record-selection-toolbar .icon-button {
    width: 40px;
  }

  .weekday-row {
    font-size: 0.7rem;
  }

  .calendar-grid {
    gap-inline: 0;
  }

  .editor-header {
    gap: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
