:root {
  color-scheme: light dark;
  --viewport-height: 100dvh;
  --page: #f7f7f3;
  --surface: #ffffff;
  --surface-soft: #f0f1ec;
  --outer: #e8ebe6;
  --ink: #2b2723;
  --ink-strong: #211e1b;
  --muted: #6c6b66;
  --faint: #96958e;
  --line: #deddd7;
  --line-strong: #c8c8c0;
  --accent: #587362;
  --accent-soft: #e4ebe6;
  --danger: #a94337;
  --danger-soft: #f4e4e0;
  --focus: #365c49;
  --backdrop: rgba(29, 28, 25, 0.42);
  --shadow-sheet: 0 -12px 40px rgba(32, 31, 28, 0.1);
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --font-serif: ui-serif, "Songti SC", STSong, "Noto Serif CJK SC", serif;
  --radius-small: 6px;
  --radius-panel: 8px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --page: #191918;
  --surface: #242422;
  --surface-soft: #2d2e2a;
  --outer: #111210;
  --ink: #f4f3ee;
  --ink-strong: #fbfaf6;
  --muted: #b8b6ae;
  --faint: #8e8c84;
  --line: #3d3c38;
  --line-strong: #53524d;
  --accent: #89aa95;
  --accent-soft: #2c3931;
  --danger: #d7786b;
  --danger-soft: #402b27;
  --focus: #a9cab6;
  --backdrop: rgba(0, 0, 0, 0.64);
  --shadow-sheet: 0 -12px 42px rgba(0, 0, 0, 0.34);
}

@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    color-scheme: dark;
    --page: #191918;
    --surface: #242422;
    --surface-soft: #2d2e2a;
    --outer: #111210;
    --ink: #f4f3ee;
    --ink-strong: #fbfaf6;
    --muted: #b8b6ae;
    --faint: #8e8c84;
    --line: #3d3c38;
    --line-strong: #53524d;
    --accent: #89aa95;
    --accent-soft: #2c3931;
    --danger: #d7786b;
    --danger-soft: #402b27;
    --focus: #a9cab6;
    --backdrop: rgba(0, 0, 0, 0.64);
    --shadow-sheet: 0 -12px 42px rgba(0, 0, 0, 0.34);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--outer);
  font-family: var(--font-sans);
  letter-spacing: 0;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: var(--viewport-height);
  margin: 0;
  overflow-x: hidden;
  background: var(--outer);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

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

button {
  -webkit-tap-highlight-color: transparent;
}

button:not(:disabled) {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.42;
}

img {
  display: block;
  max-width: 100%;
  -webkit-user-drag: none;
  user-select: none;
}

[hidden] {
  display: none !important;
}

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

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--ink);
  transform: translateY(-140%);
}

.skip-link:focus-visible {
  transform: translateY(0);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.app-shell {
  position: relative;
  width: min(100%, 520px);
  min-height: 100vh;
  min-height: var(--viewport-height);
  margin: 0 auto;
  background: var(--page);
  isolation: isolate;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: calc(60px + env(safe-area-inset-top));
  align-items: flex-end;
  justify-content: space-between;
  padding: calc(8px + env(safe-area-inset-top)) 20px 6px;
  background: var(--page);
  border-bottom: 1px solid transparent;
}

.topbar__date {
  align-self: center;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar__actions {
  display: flex;
  min-width: 48px;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
}

.icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon--inline {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.icon-button {
  display: inline-grid;
  width: 48px;
  min-width: 48px;
  height: 48px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
}

.icon-button:hover,
.icon-button:active {
  background: var(--surface-soft);
}

.icon-button--small {
  width: 40px;
  min-width: 40px;
  height: 40px;
}

.text-button {
  min-height: 48px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

.topbar__cancel {
  color: var(--muted);
}

.inline-notice {
  margin: 4px 20px 0;
  padding: 10px 12px;
  border-left: 3px solid #c99422;
  background: color-mix(in srgb, #c99422 10%, var(--page));
  color: var(--ink);
  font-size: 13px;
  line-height: 1.55;
}

.main-content {
  min-height: calc(var(--viewport-height) - 60px);
  padding: 0 20px calc(96px + env(safe-area-inset-bottom));
}

.view {
  width: 100%;
  animation: view-in 160ms ease-out both;
}

@keyframes view-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.today-state {
  display: flex;
  min-height: calc(var(--viewport-height) - 156px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  flex-direction: column;
  align-items: stretch;
}

.today-heading {
  padding-top: 12px;
}

.today-heading h1,
.today-state--complete h1 {
  margin: 0;
  color: var(--ink-strong);
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 600;
  line-height: 1.27;
  letter-spacing: 0;
}

.character-stage {
  position: relative;
  display: grid;
  place-items: center;
  margin-inline: auto;
}

.character-stage picture,
.character-stage img {
  width: 100%;
  height: 100%;
}

.character-stage img {
  object-fit: contain;
}

.character-stage--hero {
  width: 216px;
  height: 216px;
  margin-top: 14px;
  margin-bottom: 12px;
}

.character-stage--hero.is-changing picture {
  animation: character-change 200ms ease-out;
}

@keyframes character-change {
  0% { opacity: 0.3; transform: translateY(4px); }
  100% { opacity: 1; transform: translateY(0); }
}

.day-change-notice {
  margin-top: 12px;
  padding: 9px 12px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.55;
}

.picker-section {
  width: 100%;
}

.mood-picker {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
}

.mood-option {
  --mood-color: var(--accent);
  --mood-soft: var(--accent-soft);
  display: grid;
  min-width: 0;
  min-height: 96px;
  grid-template-rows: 64px auto;
  align-items: center;
  justify-items: center;
  padding: 4px 2px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  background: transparent;
  color: var(--muted);
}

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

.mood-option[aria-pressed="true"] {
  border-color: var(--mood-color);
  background: var(--mood-soft);
  color: var(--ink);
  font-weight: 600;
}

.mood-option__image {
  position: relative;
  width: 60px;
  height: 60px;
  overflow: hidden;
}

.mood-option__image picture,
.mood-option__image img {
  width: 100%;
  height: 100%;
}

.mood-option__image img {
  object-fit: contain;
}

.mood-option__label {
  max-width: 100%;
  font-size: 13px;
  line-height: 1.55;
  text-align: center;
  overflow-wrap: anywhere;
}

.intensity-section {
  margin-top: 26px;
  scroll-margin-top: calc(72px + env(safe-area-inset-top));
  animation: intensity-in 180ms ease-out both;
}

@keyframes intensity-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.intensity-section h2 {
  margin: 0 0 12px;
  color: var(--ink-strong);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.55;
}

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

.intensity-option {
  --mood-color: var(--accent);
  --mood-soft: var(--accent-soft);
  display: grid;
  min-width: 0;
  min-height: 166px;
  grid-template-rows: 106px auto 18px;
  align-items: center;
  justify-items: center;
  padding: 8px 4px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--ink);
}

.intensity-option:hover,
.intensity-option[aria-pressed="true"] {
  border-color: var(--mood-color);
  background: var(--mood-soft);
}

.intensity-option img {
  width: 106px;
  height: 106px;
  object-fit: contain;
}

.intensity-option__label {
  max-width: 100%;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
  text-align: center;
  overflow-wrap: anywhere;
}

.intensity-dots {
  display: flex;
  height: 18px;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.intensity-dots i {
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--line-strong);
}

.intensity-dots i.is-filled {
  background: var(--mood-color);
}

.save-state {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.save-state.is-error {
  color: var(--danger);
}

.local-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: auto 0 4px;
  padding-top: 24px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
  text-align: center;
}

.today-state--complete {
  min-height: calc(var(--viewport-height) - 156px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  align-items: center;
  justify-content: center;
  padding-bottom: 8vh;
  text-align: center;
}

.character-stage--complete {
  width: 252px;
  height: 252px;
  margin: 0 auto 20px;
}

.character-stage--complete.is-just-saved {
  animation: saved-nod 260ms ease-out;
}

.character-stage--complete.is-angry-three {
  animation: angry-shift 240ms ease-out;
}

.character-stage--complete.is-sad-three {
  animation: sad-settle 250ms ease-out;
}

.character-stage--complete.is-joy-three {
  animation: joy-lift 250ms ease-out;
}

@keyframes saved-nod {
  0%, 100% { transform: translateY(0); }
  45% { transform: translateY(4px); }
}

@keyframes angry-shift {
  0%, 100% { transform: translateX(0); }
  35% { transform: translateX(-3px); }
  70% { transform: translateX(3px); }
}

@keyframes sad-settle {
  0% { transform: translateY(-3px); }
  100% { transform: translateY(3px); }
}

@keyframes joy-lift {
  0% { transform: translateY(3px); }
  65% { transform: translateY(-4px); }
  100% { transform: translateY(0); }
}

.today-state--complete h1 {
  font-size: 25px;
  line-height: 1.36;
}

.quiet-action {
  min-width: 88px;
  min-height: 48px;
  margin-top: 16px;
  padding: 0 12px;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  background: transparent;
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
}

.bottom-nav {
  position: fixed;
  z-index: 30;
  right: max(0px, calc((100vw - 520px) / 2));
  bottom: 0;
  left: max(0px, calc((100vw - 520px) / 2));
  display: grid;
  height: auto;
  min-height: calc(72px + env(safe-area-inset-bottom));
  grid-template-columns: 1fr 1fr;
  padding: 4px 52px env(safe-area-inset-bottom);
  border-top: 1px solid var(--line);
  background: var(--page);
}

.bottom-nav button {
  position: relative;
  display: grid;
  min-width: 72px;
  min-height: 64px;
  place-content: center;
  justify-items: center;
  gap: 2px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.bottom-nav button::after {
  position: absolute;
  right: 24%;
  bottom: 4px;
  left: 24%;
  height: 2px;
  background: transparent;
  content: "";
}

.bottom-nav button[aria-current="page"] {
  color: var(--accent);
  font-weight: 600;
}

.bottom-nav button[aria-current="page"]::after {
  background: var(--accent);
}

.review-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 0 24px;
}

.review-heading h1,
.settings-header h1 {
  margin: 0;
  color: var(--ink-strong);
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 600;
  line-height: 1.27;
}

.segmented {
  display: grid;
  min-width: 172px;
  min-height: 50px;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--surface-soft);
}

.segmented button {
  min-width: 0;
  min-height: 44px;
  padding: 6px 12px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  white-space: nowrap;
}

.segmented button[aria-selected="true"],
.segmented button[aria-pressed="true"],
.segmented button[aria-checked="true"] {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(32, 31, 28, 0.08);
}

.segmented--small {
  width: 100%;
  min-width: 0;
}

.month-controls {
  display: grid;
  min-height: 54px;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  margin-bottom: 8px;
}

.month-controls h2 {
  margin: 0;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
}

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

.weekdays span {
  display: grid;
  height: 32px;
  place-items: center;
  color: var(--faint);
  font-size: 12px;
  line-height: 1.35;
}

.calendar-grid {
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.calendar-day {
  position: relative;
  display: grid;
  min-width: 0;
  height: 72px;
  grid-template-rows: 20px 34px 12px;
  align-items: center;
  justify-items: center;
  padding: 3px 1px 2px;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}

.calendar-day:not(:disabled):hover {
  background: var(--surface-soft);
}

.calendar-day.is-outside {
  color: var(--faint);
  opacity: 0.45;
}

.calendar-day.is-today::after {
  position: absolute;
  inset: 2px;
  border: 1px solid var(--accent);
  content: "";
  pointer-events: none;
}

.calendar-day__number {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}

.calendar-avatar {
  width: 32px;
  height: 32px;
  overflow: hidden;
}

.calendar-avatar picture,
.calendar-avatar img {
  width: 100%;
  height: 100%;
}

.calendar-avatar img {
  object-fit: contain;
  transform: scale(1.32);
}

.calendar-day .intensity-dots {
  height: 12px;
  gap: 3px;
}

.calendar-day .intensity-dots i {
  width: 3px;
  height: 3px;
}

.trend-content {
  padding-top: 22px;
}

.trend-empty {
  display: grid;
  min-height: 320px;
  place-content: center;
  color: var(--muted);
  text-align: center;
}

.trend-empty strong {
  color: var(--ink);
  font-size: 18px;
  font-weight: 600;
}

.trend-empty p {
  margin: 8px 0 0;
  font-size: 14px;
  line-height: 1.6;
}

.trend-section {
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}

.trend-section:first-child {
  padding-top: 0;
}

.trend-section:last-child {
  border-bottom: 0;
}

.trend-section h2,
.trend-section h3 {
  margin: 0 0 14px;
  color: var(--ink-strong);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.55;
}

.trend-summary {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 20px;
  line-height: 1.55;
}

.mood-bars {
  display: grid;
  gap: 13px;
}

.mood-bar {
  --mood-color: var(--accent);
  display: grid;
  grid-template-columns: 46px 1fr 42px;
  align-items: center;
  gap: 9px;
  font-size: 13px;
}

.mood-bar__track {
  height: 8px;
  overflow: hidden;
  background: var(--surface-soft);
}

.mood-bar__fill {
  display: block;
  height: 100%;
  background: var(--mood-color);
}

.mood-bar__value {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.trend-matrix {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}

.trend-day {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface);
}

.trend-day img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.trend-day.is-empty::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 1px;
  background: var(--line-strong);
  content: "";
  transform: translate(-50%, -50%);
}

.intensity-breakdown {
  display: grid;
  gap: 16px;
}

.intensity-row {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 10px;
}

.intensity-row > strong {
  font-size: 14px;
  line-height: 1.6;
}

.intensity-row__values {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.fact-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.fact-list li {
  position: relative;
  padding-left: 15px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.fact-list li::before {
  position: absolute;
  top: 9px;
  left: 1px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  content: "";
}

.overlay {
  position: fixed;
  z-index: 60;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 max(0px, calc((100vw - 520px) / 2));
}

.overlay__scrim {
  position: absolute;
  z-index: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: var(--backdrop);
}

.bottom-sheet {
  position: relative;
  z-index: 1;
  width: 100%;
  max-height: min(88vh, calc(var(--viewport-height) - 40px));
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: var(--radius-panel) var(--radius-panel) 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-sheet);
  animation: sheet-in 190ms ease-out both;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}

@keyframes sheet-in {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-header {
  position: sticky;
  z-index: 2;
  top: 0;
  display: grid;
  min-height: 64px;
  grid-template-columns: minmax(84px, 1fr) minmax(0, 2fr) minmax(84px, 1fr);
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.sheet-header h2 {
  margin: 0;
  overflow: hidden;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.55;
  text-align: center;
  overflow-wrap: anywhere;
}

.sheet-header > :first-child {
  justify-self: start;
  margin-left: 8px;
}

.sheet-header > :last-child {
  justify-self: end;
  margin-right: 8px;
}

.note-editor {
  margin: 20px 20px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--page);
}

.note-editor textarea {
  display: block;
  width: 100%;
  min-height: 150px;
  resize: vertical;
  padding: 16px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.65;
  -webkit-touch-callout: default;
  -webkit-user-select: text;
  user-select: text;
}

.note-editor textarea::placeholder {
  color: var(--faint);
}

.note-count {
  min-height: 24px;
  margin: 0;
  padding: 0 12px 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
  text-align: right;
}

.tag-picker {
  margin: 22px 20px 0;
  padding: 0;
  border: 0;
}

.tag-picker legend {
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.6;
}

.tag-picker legend span {
  margin-left: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-option {
  min-height: 48px;
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-small);
  background: transparent;
  color: var(--muted);
  font-size: 14px;
}

.tag-option[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
  font-weight: 600;
}

.sheet-error {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 12px 20px 0;
  color: var(--danger);
  font-size: 13px;
}

.sheet-menu {
  position: absolute;
  z-index: 4;
  top: 56px;
  right: 12px;
  min-width: 168px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(32, 31, 28, 0.14);
}

.sheet-menu button {
  display: flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
}

.sheet-menu button:last-child {
  border-bottom: 0;
}

.sheet-menu button:hover {
  background: var(--surface-soft);
}

.danger-text {
  color: var(--danger);
}

.detail-content {
  min-height: 240px;
  padding: 20px;
}

.detail-record {
  display: grid;
  justify-items: center;
  text-align: center;
}

.detail-character {
  width: 190px;
  height: 190px;
}

.detail-character picture,
.detail-character img {
  width: 100%;
  height: 100%;
}

.detail-character img {
  object-fit: contain;
}

.detail-mood {
  margin: 4px 0 0;
  color: var(--ink-strong);
  font-family: var(--font-serif);
  font-size: 23px;
  font-weight: 600;
  line-height: 1.4;
}

.detail-note {
  width: 100%;
  margin: 22px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.75;
  text-align: left;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.detail-tags {
  display: flex;
  width: 100%;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.detail-tags span {
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  color: var(--accent);
  font-size: 12px;
}

.detail-note-action {
  min-height: 48px;
  margin-top: 18px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 600;
}

.empty-day {
  display: grid;
  min-height: 250px;
  place-content: center;
  color: var(--muted);
  font-size: 16px;
  text-align: center;
}

.history-editor {
  padding: 4px 0 12px;
}

.history-editor h3 {
  margin: 18px 0 10px;
  font-size: 16px;
  line-height: 1.6;
}

.history-editor .mood-picker {
  gap: 3px;
}

.history-editor .mood-option {
  min-height: 88px;
}

.history-editor .intensity-picker {
  margin-top: 8px;
}

.history-editor-status {
  min-height: 32px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  text-align: center;
}

.overlay--page {
  z-index: 70;
  display: block;
  padding: 0;
  background: var(--outer);
}

.settings-page {
  width: min(100%, 520px);
  min-height: var(--viewport-height);
  max-height: var(--viewport-height);
  margin: 0 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--page);
  animation: page-in 180ms ease-out both;
}

@keyframes page-in {
  from { opacity: 0; transform: translateX(8px); }
  to { opacity: 1; transform: translateX(0); }
}

.settings-header {
  position: sticky;
  z-index: 3;
  top: 0;
  display: grid;
  min-height: calc(64px + env(safe-area-inset-top));
  grid-template-columns: 64px 1fr 64px;
  align-items: end;
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--line);
  background: var(--page);
}

.settings-header h1 {
  padding-bottom: 12px;
  font-size: 23px;
  line-height: 1.55;
  text-align: center;
}

.settings-header .icon-button {
  align-self: end;
  margin: 0 0 6px 8px;
}

.settings-content {
  padding: 8px 20px calc(32px + env(safe-area-inset-bottom));
}

.settings-section {
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
}

.settings-section:last-child {
  border-bottom: 0;
}

.settings-section h2 {
  margin: 0 0 10px;
  color: var(--ink-strong);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.6;
}

.settings-section p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.72;
}

.settings-section .segmented {
  width: 100%;
}

#appearancePicker button {
  padding-right: 3px;
  padding-left: 3px;
  overflow-wrap: anywhere;
  white-space: normal;
}

.checkbox-row {
  display: flex;
  min-height: 52px;
  align-items: center;
  gap: 11px;
  margin: 10px 0;
  cursor: pointer;
}

.checkbox-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.checkbox-mark {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
}

.checkbox-mark .icon {
  width: 17px;
  height: 17px;
  opacity: 0;
}

.checkbox-row input:checked + .checkbox-mark {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--surface);
}

.checkbox-row input:checked + .checkbox-mark .icon {
  opacity: 1;
}

.checkbox-row input:focus-visible + .checkbox-mark {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.primary-action,
.secondary-action,
.danger-action {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: var(--radius-small);
  font-size: 15px;
  font-weight: 600;
}

.primary-action {
  width: 100%;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.secondary-action {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

.danger-action {
  border: 1px solid var(--danger);
  background: transparent;
  color: var(--danger);
}

.settings-status {
  min-height: 22px;
  margin: 10px 0 0 !important;
  color: var(--muted);
  font-size: 13px !important;
  line-height: 1.65 !important;
}

.settings-section--about p {
  margin-bottom: 10px;
}

.version-text {
  color: var(--faint) !important;
  font-variant-numeric: tabular-nums;
}

.overlay--center {
  z-index: 80;
  align-items: center;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
}

.confirm-dialog,
.preview-dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 420px);
  max-height: calc(var(--viewport-height) - 40px);
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
  box-shadow: 0 18px 54px rgba(20, 20, 18, 0.18);
}

.confirm-dialog {
  padding: 22px;
}

.confirm-dialog h2 {
  margin: 0 0 10px;
  font-size: 20px;
  line-height: 1.45;
}

.confirm-dialog p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.72;
  white-space: pre-wrap;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 22px;
}

.confirm-actions .danger-action {
  background: var(--danger);
  color: #ffffff;
}

.preview-dialog {
  padding-bottom: 18px;
}

.preview-dialog .sheet-header {
  grid-template-columns: minmax(84px, 1fr) minmax(0, 2fr) minmax(84px, 1fr);
}

.preview-dialog .sheet-header h2 {
  grid-column: 2;
}

.preview-dialog .sheet-header .icon-button {
  grid-column: 3;
}

.preview-pages {
  display: flex;
  gap: 12px;
  padding: 18px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
}

.preview-pages img {
  width: 100%;
  min-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  scroll-snap-align: center;
}

.preview-page {
  display: grid;
  flex: 0 0 100%;
  gap: 12px;
  scroll-snap-align: center;
}

.preview-page img {
  min-width: 0;
}

.preview-dialog .preview-download {
  width: 100%;
  margin: 0 !important;
  text-decoration: none;
}

.preview-download::before {
  content: "↓";
  font-size: 20px;
  font-weight: 400;
  line-height: 1;
}

.preview-dialog .settings-status,
.preview-dialog .primary-action {
  width: calc(100% - 36px);
  margin-right: 18px !important;
  margin-left: 18px !important;
}

.toast {
  position: fixed;
  z-index: 100;
  right: max(20px, calc((100vw - 480px) / 2));
  bottom: calc(88px + env(safe-area-inset-bottom));
  left: max(20px, calc((100vw - 480px) / 2));
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-small);
  background: var(--ink-strong);
  color: var(--page);
  box-shadow: 0 10px 30px rgba(20, 20, 18, 0.2);
  font-size: 14px;
  line-height: 1.6;
}

.toast .text-button {
  color: #d4e4d8;
}

@media (max-width: 374px) {
  .topbar,
  .main-content,
  .settings-content {
    padding-right: 16px;
    padding-left: 16px;
  }

  .inline-notice {
    margin-right: 16px;
    margin-left: 16px;
  }

  .today-heading h1 {
    font-size: 28px;
    line-height: 1.32;
  }

  .character-stage--hero {
    width: 198px;
    height: 198px;
  }

  .mood-picker {
    gap: 2px;
  }

  .mood-option__image {
    width: 54px;
    height: 54px;
  }

  .intensity-option {
    min-height: 154px;
    grid-template-rows: 96px auto 18px;
  }

  .intensity-option img {
    width: 94px;
    height: 94px;
  }

  .review-heading {
    display: grid;
    gap: 14px;
  }

  .calendar-day {
    height: 68px;
  }
}

@media (min-width: 768px) {
  .app-shell,
  .settings-page {
    border-right: 1px solid var(--line);
    border-left: 1px solid var(--line);
  }

  .topbar,
  .main-content,
  .settings-content {
    padding-right: 24px;
    padding-left: 24px;
  }

  .inline-notice {
    margin-right: 24px;
    margin-left: 24px;
  }
}

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