:root {
  --bg: #f3ede2;
  --bg-soft: #f8f3eb;
  --surface: rgba(255, 251, 246, 0.82);
  --surface-strong: rgba(255, 251, 246, 0.96);
  --ink: #2e312e;
  --muted: #6a7068;
  --line: rgba(79, 92, 78, 0.12);
  --sage: #7e9581;
  --sage-deep: #4f6551;
  --rose: #d98c77;
  --rose-soft: #f4d6c8;
  --gold: #b39a63;
  --sky: #c9d8df;
  --danger: #b85c5c;
  --shadow: 0 20px 45px rgba(78, 97, 78, 0.12);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --content-width: min(100vw, 520px);
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia,
    serif;
  --sans: "Aptos", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(233, 201, 170, 0.45), transparent 40%),
    radial-gradient(circle at bottom right, rgba(177, 198, 177, 0.34), transparent 36%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
}

body {
  position: relative;
  overflow-x: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
}

img {
  display: block;
  max-width: 100%;
}

.ambient {
  position: fixed;
  inset: auto;
  pointer-events: none;
  filter: blur(50px);
  opacity: 0.45;
  z-index: 0;
}

.ambient-one {
  top: 5%;
  right: -3rem;
  width: 12rem;
  height: 12rem;
  border-radius: 50%;
  background: rgba(217, 140, 119, 0.34);
}

.ambient-two {
  bottom: 18%;
  left: -4rem;
  width: 14rem;
  height: 14rem;
  border-radius: 50%;
  background: rgba(126, 149, 129, 0.28);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: var(--content-width);
  min-height: 100vh;
  margin: 0 auto;
  padding: env(safe-area-inset-top, 0) 1rem
    calc(5.5rem + env(safe-area-inset-bottom, 0));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 0 0.9rem;
  backdrop-filter: blur(22px);
}

.topbar-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.topbar-subtitle {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.icon-button,
.ghost-button,
.primary-button,
.chip,
.nav-item,
.secondary-button {
  appearance: none;
  border: 0;
  cursor: pointer;
  transition:
    transform 160ms ease,
    background 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease;
}

.icon-button,
.ghost-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.75rem;
  padding: 0 1rem;
  border-radius: 999px;
  background: rgba(255, 251, 246, 0.72);
  border: 1px solid var(--line);
  color: var(--ink);
  box-shadow: 0 12px 24px rgba(68, 84, 68, 0.08);
}

.icon-button {
  min-width: 2.75rem;
  padding: 0;
}

.ghost-button {
  background: rgba(255, 251, 246, 0.58);
}

.secondary-button {
  background: rgba(126, 149, 129, 0.12);
  color: var(--sage-deep);
}

.ghost-button.danger,
.secondary-button.danger {
  color: var(--danger);
  border-color: rgba(184, 92, 92, 0.22);
  background: rgba(184, 92, 92, 0.06);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 3rem;
  padding: 0.78rem 1.25rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--sage-deep), #68806c);
  color: #fffdf9;
  box-shadow: 0 18px 32px rgba(79, 101, 81, 0.25);
}

.icon-button:hover,
.ghost-button:hover,
.secondary-button:hover,
.nav-item:hover,
.chip:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

.icon-button:disabled,
.ghost-button:disabled,
.secondary-button:disabled,
.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
  box-shadow: none;
}

.app-main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-bottom: 2rem;
}

.screen {
  animation: rise 420ms ease both;
}

.hero-card,
.panel,
.entry-card,
.calendar-card,
.companion-card,
.empty-card,
.auth-card {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-card,
.auth-card,
.panel,
.calendar-card,
.companion-card,
.empty-card {
  padding: 1.2rem;
}

.hero-card {
  overflow: hidden;
  background:
    linear-gradient(160deg, rgba(255, 250, 246, 0.94), rgba(247, 240, 230, 0.78)),
    radial-gradient(circle at top right, rgba(217, 140, 119, 0.16), transparent 35%);
}

.hero-card h2,
.panel h2,
.empty-card h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.65rem;
  line-height: 1.2;
}

.hero-card p,
.panel p,
.empty-card p,
.auth-card p,
.entry-meta,
.helper-text {
  color: var(--muted);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1rem;
  align-items: end;
}

.hero-mark {
  position: relative;
  min-height: 10rem;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(217, 140, 119, 0.18), rgba(126, 149, 129, 0.08)),
    rgba(255, 251, 246, 0.62);
  overflow: hidden;
}

.hero-mark::before,
.hero-mark::after {
  content: "";
  position: absolute;
  border-radius: 999px;
}

.hero-mark::before {
  inset: auto auto 18% 16%;
  width: 5rem;
  height: 5rem;
  background: rgba(126, 149, 129, 0.28);
}

.hero-mark::after {
  inset: 14% 14% auto auto;
  width: 3.6rem;
  height: 7.8rem;
  background: rgba(217, 140, 119, 0.34);
  transform: rotate(16deg);
}

.hero-pill-row,
.chip-row,
.filter-row,
.meta-row,
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.hero-pill,
.emotion-pill,
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border-radius: 999px;
  padding: 0.55rem 0.9rem;
  border: 1px solid rgba(79, 101, 81, 0.12);
  background: rgba(255, 255, 255, 0.62);
  color: var(--ink);
}

.hero-pill strong,
.emotion-pill strong {
  font-size: 0.95rem;
}

.chip {
  padding: 0.48rem 0.82rem;
  font-size: 0.92rem;
}

.chip.active,
.emotion-pill.active {
  background: rgba(126, 149, 129, 0.2);
  border-color: rgba(79, 101, 81, 0.28);
  color: var(--sage-deep);
}

.chip.soft {
  background: rgba(217, 140, 119, 0.12);
  border-color: rgba(217, 140, 119, 0.16);
}

.panel-header,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.section-title {
  margin-bottom: 0.8rem;
}

.section-title h3,
.panel-header h3 {
  margin: 0;
  font-size: 1.02rem;
  letter-spacing: 0.02em;
}

.entry-list,
.calendar-day-list,
.search-results,
.chat-list,
.block-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.entry-card {
  padding: 1rem;
  text-align: left;
}

.trash-card {
  padding: 1rem;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(184, 92, 92, 0.14);
  background: rgba(255, 248, 246, 0.78);
  box-shadow: 0 10px 24px rgba(75, 88, 75, 0.06);
}

.entry-card h3,
.trash-card h3,
.detail-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.25rem;
  line-height: 1.25;
}

.entry-card p,
.trash-card p,
.detail-body,
.chat-bubble p {
  margin: 0;
  line-height: 1.7;
  white-space: pre-wrap;
}

.entry-card .excerpt,
.trash-card .excerpt {
  color: var(--muted);
}

.entry-soft-summary {
  margin-top: 0.95rem;
  font-size: 0.84rem;
  line-height: 1.6;
  color: rgba(87, 95, 87, 0.72);
}

.entry-card .entry-header,
.trash-card .entry-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.entry-date {
  font-size: 0.9rem;
  color: var(--muted);
}

.entry-counts {
  font-size: 0.86rem;
  color: var(--muted);
}

.entry-media-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
  margin-top: 0.9rem;
}

.entry-media-strip img {
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.empty-card {
  text-align: center;
}

.empty-card .primary-button {
  margin-top: 0.6rem;
}

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 16;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: calc(var(--content-width) - 1.2rem);
  max-width: calc(100vw - 1.2rem);
  padding: 0.7rem 0.8rem
    calc(0.7rem + env(safe-area-inset-bottom, 0));
  transform: translateX(-50%);
  background: rgba(255, 251, 246, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 28px 28px 0 0;
  backdrop-filter: blur(20px);
  box-shadow: 0 -10px 40px rgba(77, 90, 77, 0.12);
}

.tabbar.hidden {
  display: none;
}

.nav-item {
  flex: 1;
  min-height: 3.3rem;
  padding: 0.55rem 0.5rem;
  border-radius: 22px;
  background: transparent;
  color: var(--muted);
}

.nav-item strong {
  display: block;
  font-size: 0.74rem;
  font-weight: 600;
}

.nav-item span {
  display: block;
  font-size: 1.2rem;
}

.nav-item.active {
  background: rgba(126, 149, 129, 0.14);
  color: var(--sage-deep);
}

.nav-item.compose {
  background: linear-gradient(135deg, var(--sage-deep), #69816d);
  color: #fffefc;
  box-shadow: 0 16px 30px rgba(79, 101, 81, 0.22);
}

.auth-card {
  display: grid;
  gap: 1rem;
  padding: 1.3rem;
}

.auth-card h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.7rem;
}

.form-grid,
.settings-grid,
.composer-header {
  display: grid;
  gap: 0.85rem;
}

.input-group {
  display: grid;
  gap: 0.45rem;
}

.input-group label {
  font-size: 0.93rem;
  color: var(--muted);
}

.input-group input,
.input-group textarea,
.input-group select {
  width: 100%;
  padding: 0.92rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(79, 101, 81, 0.12);
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
}

.input-group textarea {
  min-height: 7.5rem;
  resize: vertical;
}

.input-group.inline {
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 0.92rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(79, 101, 81, 0.12);
  background: rgba(255, 255, 255, 0.78);
}

.input-group.inline span {
  color: var(--ink);
}

.input-group input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  padding: 0;
  border-radius: 0.35rem;
  accent-color: var(--sage-deep);
  box-shadow: none;
}

.input-group.inline input[type="checkbox"] {
  justify-self: end;
}

.muted-link {
  background: none;
  border: 0;
  color: var(--sage-deep);
  text-decoration: underline;
  padding: 0;
  cursor: pointer;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.42rem 0.72rem;
  border-radius: 999px;
  background: rgba(201, 216, 223, 0.35);
  color: #3f5d69;
  font-size: 0.83rem;
}

.composer-panel {
  display: grid;
  gap: 1rem;
}

.segmented {
  display: inline-flex;
  padding: 0.25rem;
  gap: 0.25rem;
  border-radius: 999px;
  background: rgba(255, 251, 246, 0.86);
  border: 1px solid var(--line);
}

.segmented button {
  border: 0;
  min-height: 2.6rem;
  padding: 0 1rem;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
}

.segmented button.active {
  background: rgba(126, 149, 129, 0.18);
  color: var(--sage-deep);
}

.block-card {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(79, 101, 81, 0.1);
}

.block-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
}

.block-top strong {
  font-size: 0.95rem;
}

.block-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.block-card textarea {
  min-height: 7rem;
}

.image-preview {
  display: grid;
  gap: 0.55rem;
}

.image-preview img,
.detail-image {
  width: 100%;
  border-radius: var(--radius-lg);
  object-fit: cover;
}

.audio-shell {
  display: grid;
  gap: 0.75rem;
}

.audio-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.waveform {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  align-items: end;
  gap: 0.15rem;
  min-height: 3rem;
}

.waveform span {
  display: block;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(217, 140, 119, 0.75), rgba(126, 149, 129, 0.75));
}

.detail-layout {
  display: grid;
  gap: 1rem;
}

.detail-quote {
  padding: 0.95rem 1rem;
  border-left: 4px solid rgba(217, 140, 119, 0.55);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background: rgba(255, 250, 246, 0.62);
  color: var(--muted);
}

.detail-block {
  display: grid;
  gap: 0.6rem;
}

.audio-note {
  padding: 0.72rem 0.85rem;
  border-radius: var(--radius-md);
  background: rgba(126, 149, 129, 0.12);
  color: var(--sage-deep);
  font-size: 0.9rem;
}

.companion-card {
  display: grid;
  gap: 0.95rem;
}

.companion-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.companion-head h3 {
  margin: 0;
}

.analysis-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

.summary-card {
  padding: 0.95rem 1rem;
  border-radius: var(--radius-lg);
  background: rgba(126, 149, 129, 0.12);
  color: var(--sage-deep);
}

.analysis-block {
  padding: 0.95rem 1rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(79, 101, 81, 0.1);
}

.chat-bubble {
  max-width: 88%;
  padding: 0.95rem 1rem;
  border-radius: 1.15rem;
  background: rgba(255, 251, 246, 0.8);
  border: 1px solid rgba(79, 101, 81, 0.1);
}

.chat-bubble.assistant {
  border-top-left-radius: 0.45rem;
}

.chat-bubble.user {
  margin-left: auto;
  background: rgba(217, 140, 119, 0.15);
  border-top-right-radius: 0.45rem;
}

.chat-input {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
}

.chat-input textarea {
  min-height: 3.5rem;
}

.calendar-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
}

.calendar-toolbar h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.45rem;
}

.calendar-selectors {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 0.9rem;
}

.calendar-select {
  display: grid;
  gap: 0.35rem;
}

.calendar-select span {
  font-size: 0.82rem;
  color: var(--muted);
}

.calendar-select select {
  width: 100%;
  padding: 0.82rem 0.95rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(79, 101, 81, 0.12);
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

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

.weekday {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}

.calendar-day {
  min-height: 5rem;
  padding: 0.55rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(79, 101, 81, 0.08);
  text-align: left;
}

.calendar-day.muted {
  opacity: 0.48;
}

.calendar-day.active {
  background: rgba(126, 149, 129, 0.16);
  border-color: rgba(79, 101, 81, 0.24);
}

.calendar-day.today {
  outline: 1px solid rgba(217, 140, 119, 0.5);
}

.calendar-day strong {
  display: block;
  font-size: 0.86rem;
}

.calendar-day small {
  display: block;
  color: var(--muted);
  margin-top: 0.25rem;
}

.calendar-dots {
  display: flex;
  gap: 0.18rem;
  margin-top: 0.65rem;
}

.calendar-dots span {
  width: 0.44rem;
  height: 0.44rem;
  border-radius: 999px;
  background: rgba(217, 140, 119, 0.42);
}

.search-box {
  position: sticky;
  top: 4.55rem;
  z-index: 9;
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
  background: rgba(255, 251, 246, 0.76);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(18px);
  box-shadow: 0 12px 30px rgba(75, 88, 75, 0.08);
}

.search-query-form {
  display: grid;
}

.search-query-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: center;
}

.search-query-row .secondary-button {
  min-width: 4.6rem;
}

.search-stat {
  color: var(--muted);
  font-size: 0.88rem;
}

.timeline-kicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.timeline-kicker strong {
  font-family: var(--serif);
  font-size: 1.18rem;
}

.toast-root {
  position: fixed;
  left: 50%;
  bottom: calc(5.7rem + env(safe-area-inset-bottom, 0));
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: min(88vw, 360px);
  transform: translateX(-50%);
}

.toast {
  padding: 0.9rem 1rem;
  border-radius: 18px;
  background: rgba(46, 49, 46, 0.92);
  color: #fffdf8;
  box-shadow: 0 12px 24px rgba(16, 16, 16, 0.16);
  animation: toast-in 250ms ease both;
}

.toast.error {
  background: rgba(184, 92, 92, 0.94);
}

.inline-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.foot-note {
  font-size: 0.86rem;
  color: var(--muted);
}

.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;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 420px) {
  .hero-grid {
    grid-template-columns: 1fr;
  }

  .chat-input {
    grid-template-columns: 1fr;
  }

  .entry-card .entry-header,
  .trash-card .entry-header,
  .companion-head,
  .calendar-toolbar,
  .timeline-kicker {
    flex-direction: column;
    align-items: flex-start;
  }

  .calendar-selectors {
    grid-template-columns: 1fr;
  }
}
