:root {
  color-scheme: light;
  --ink: #172129;
  --muted: #66737f;
  --line: #d9e2e6;
  --paper: #fffdf7;
  --foam: #f2f8f7;
  --sea: #277c84;
  --deep: #14515c;
  --coral: #e56b5d;
  --gold: #f0b44c;
  --leaf: #619968;
  --shadow: 0 24px 70px rgba(24, 44, 52, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(242, 248, 247, 0.86), rgba(255, 253, 247, 0.94)),
    radial-gradient(circle at 12% 12%, rgba(229, 107, 93, 0.2), transparent 28%),
    linear-gradient(135deg, #c7e4dc 0%, #f8e8c9 46%, #d9ebef 100%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 26px 20px;
  background: rgba(255, 253, 247, 0.78);
  border-right: 1px solid rgba(217, 226, 230, 0.9);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: var(--deep);
  color: var(--paper);
  box-shadow: 0 16px 36px rgba(20, 81, 92, 0.24);
}

.brand-mark svg {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: currentColor;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

h1,
h2,
p {
  margin: 0;
}

.brand h1 {
  font-size: 22px;
  line-height: 1.1;
}

.brand p,
.profile span,
.eyebrow,
.stat-grid p {
  color: var(--muted);
  font-size: 13px;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.tab,
.ghost-button,
.primary-button,
.mood,
.upload-button,
.privacy-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
}

.tab {
  justify-content: flex-start;
  padding: 0 14px;
  color: var(--muted);
}

.tab.is-active {
  background: var(--deep);
  color: white;
}

.icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  line-height: 1;
}

.profile {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
}

.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--coral);
  color: white;
  font-weight: 800;
}

.profile div:last-child {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 22px;
}

.topbar h2 {
  margin-top: 3px;
  font-size: 30px;
}

.ghost-button {
  padding: 0 16px;
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.56);
}

.primary-button {
  padding: 0 18px;
  background: var(--sea);
  color: white;
  border-color: rgba(20, 81, 92, 0.18);
  box-shadow: 0 12px 28px rgba(39, 124, 132, 0.2);
}

.primary-button:hover,
.tab.is-active:hover {
  background: var(--deep);
}

.primary-button.wide {
  width: min(420px, 100%);
  margin: 18px auto 0;
}

.primary-button.compact {
  min-height: 40px;
}

.view {
  display: none;
  min-height: 0;
}

.view.is-visible {
  display: block;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 22px;
}

.writer,
.today-panel,
.bottle-reader,
.list-panel,
.chat-shell {
  border: 1px solid rgba(217, 226, 230, 0.86);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.78);
  box-shadow: var(--shadow);
}

.writer {
  display: grid;
  gap: 12px;
  padding: 22px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--sea);
  box-shadow: 0 0 0 4px rgba(39, 124, 132, 0.12);
}

input {
  height: 46px;
  padding: 0 14px;
}

textarea {
  min-height: 280px;
  resize: vertical;
  padding: 14px;
  line-height: 1.7;
}

.mood-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mood {
  min-height: 38px;
  padding: 0 14px;
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.62);
}

.mood.is-selected {
  background: #f8e5d5;
  border-color: #efbd8f;
  color: #814425;
}

.tool-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.upload-button,
.privacy-toggle {
  min-height: 40px;
  padding: 0 14px;
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.62);
  font-weight: 700;
}

.privacy-toggle.is-on {
  border-color: rgba(229, 107, 93, 0.44);
  background: rgba(229, 107, 93, 0.13);
  color: #8f3d34;
}

.image-preview {
  display: grid;
  gap: 10px;
  min-height: 88px;
  padding: 10px;
  border: 1px dashed rgba(39, 124, 132, 0.38);
  border-radius: 8px;
  background: rgba(242, 248, 247, 0.62);
}

.image-preview.is-empty {
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

.image-preview img {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: 6px;
}

.form-footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.today-panel {
  overflow: hidden;
}

.sea-window {
  position: relative;
  height: 300px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(246, 201, 121, 0.85), rgba(112, 184, 181, 0.45) 42%, rgba(39, 124, 132, 0.88)),
    url("data:image/svg+xml,%3Csvg width='420' height='260' viewBox='0 0 420 260' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='rgba(255,255,255,.35)' stroke-width='2'%3E%3Cpath d='M0 80c40-28 82-28 126 0s86 28 126 0 82-28 126 0 86 28 126 0'/%3E%3Cpath d='M-40 128c42-22 84-22 126 0s84 22 126 0 84-22 126 0 84 22 126 0'/%3E%3C/g%3E%3C/svg%3E");
}

.sun {
  position: absolute;
  top: 38px;
  right: 42px;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: #ffe29a;
}

.bottle {
  position: absolute;
  width: 86px;
  height: 34px;
  border: 4px solid rgba(255, 253, 247, 0.84);
  border-radius: 22px 8px 8px 22px;
  transform: rotate(-14deg);
}

.bottle::after {
  content: "";
  position: absolute;
  right: -20px;
  top: 7px;
  width: 22px;
  height: 12px;
  border-radius: 0 6px 6px 0;
  background: rgba(255, 253, 247, 0.84);
}

.bottle-a {
  left: 48px;
  bottom: 78px;
}

.bottle-b {
  right: 42px;
  bottom: 114px;
  transform: rotate(12deg) scale(0.72);
  opacity: 0.74;
}

.wave {
  position: absolute;
  left: -10%;
  bottom: -30px;
  width: 120%;
  height: 94px;
  border-radius: 50% 50% 0 0;
  background: rgba(255, 253, 247, 0.28);
}

.wave-two {
  bottom: -52px;
  background: rgba(20, 81, 92, 0.2);
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
}

.stat-grid div {
  padding: 18px;
}

.stat-grid div + div {
  border-left: 1px solid var(--line);
}

.stat-grid span {
  font-size: 30px;
  font-weight: 850;
}

.ocean-stage {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 22px;
  align-items: stretch;
}

.map-card {
  position: relative;
  min-height: 440px;
  overflow: hidden;
  border: 1px solid rgba(217, 226, 230, 0.86);
  border-radius: 8px;
  background:
    linear-gradient(30deg, rgba(97, 153, 104, 0.16) 0 19%, transparent 19% 34%, rgba(240, 180, 76, 0.18) 34% 48%, transparent 48%),
    linear-gradient(140deg, #d9ece5, #fbefd6 52%, #c7e0e5);
  box-shadow: var(--shadow);
}

.map-card::before,
.map-card::after {
  content: "";
  position: absolute;
  inset: 34px;
  border: 1px solid rgba(20, 81, 92, 0.18);
  transform: rotate(9deg);
}

.map-card::after {
  inset: 90px 54px;
  transform: rotate(-13deg);
}

.map-pin {
  position: absolute;
  left: 50%;
  top: 48%;
  z-index: 2;
  width: 24px;
  height: 24px;
  border-radius: 50% 50% 50% 0;
  background: var(--coral);
  transform: translate(-50%, -50%) rotate(-45deg);
  box-shadow: 0 10px 24px rgba(229, 107, 93, 0.36);
}

.map-rings {
  position: absolute;
  left: 50%;
  top: 48%;
  width: 180px;
  height: 180px;
  border: 2px solid rgba(39, 124, 132, 0.34);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.map-rings::before,
.map-rings::after {
  content: "";
  position: absolute;
  inset: 32px;
  border: inherit;
  border-radius: inherit;
}

.map-rings::after {
  inset: 64px;
}

.map-card p {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  padding: 14px;
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.78);
  color: var(--muted);
}

.bottle-reader {
  min-height: 440px;
  padding: 24px;
}

.empty-state {
  display: grid;
  place-items: center;
  height: 100%;
  min-height: 340px;
  color: var(--muted);
  text-align: center;
}

.diary-card {
  display: grid;
  gap: 16px;
}

.diary-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.diary-card h3 {
  margin: 0;
  font-size: 28px;
}

.diary-card article {
  padding: 18px;
  border-left: 4px solid var(--gold);
  background: rgba(242, 248, 247, 0.74);
  line-height: 1.8;
  white-space: pre-wrap;
}

.diary-image {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: 8px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.secondary-button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
}

.list-panel {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.timeline-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid rgba(217, 226, 230, 0.86);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.78);
  box-shadow: var(--shadow);
}

.timeline-toolbar input {
  max-width: 320px;
}

.timeline {
  position: relative;
  display: grid;
  gap: 16px;
  padding-left: 20px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: rgba(39, 124, 132, 0.22);
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 16px;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -19px;
  top: 7px;
  width: 14px;
  height: 14px;
  border: 3px solid var(--paper);
  border-radius: 50%;
  background: var(--sea);
  box-shadow: 0 0 0 1px rgba(39, 124, 132, 0.28);
}

.timeline-item time {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.timeline-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(217, 226, 230, 0.86);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.82);
  box-shadow: 0 12px 34px rgba(24, 44, 52, 0.1);
}

.timeline-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.timeline-head h3 {
  margin: 0 0 4px;
  font-size: 20px;
}

.timeline-head p,
.timeline-body {
  color: var(--muted);
  line-height: 1.7;
}

.timeline-body {
  color: var(--ink);
  white-space: pre-wrap;
}

.timeline-image {
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  border-radius: 8px;
}

.privacy-pill {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(39, 124, 132, 0.24);
  border-radius: 999px;
  background: rgba(39, 124, 132, 0.08);
  color: var(--deep);
}

.privacy-pill.is-private {
  border-color: rgba(229, 107, 93, 0.4);
  background: rgba(229, 107, 93, 0.12);
  color: #8f3d34;
}

.person-card,
.conversation-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

.person-card strong,
.conversation-item strong {
  display: block;
}

.person-card p,
.conversation-item p {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.chat-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 560px;
  overflow: hidden;
}

.conversation-list {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 14px;
  border-right: 1px solid var(--line);
}

.conversation-item {
  text-align: left;
}

.conversation-item.is-active {
  border-color: var(--sea);
  background: rgba(39, 124, 132, 0.1);
}

.conversation {
  display: grid;
  grid-template-rows: 1fr auto;
  min-width: 0;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  overflow: auto;
}

.message {
  max-width: min(520px, 82%);
  padding: 10px 12px;
  border-radius: 8px;
  background: #edf4f1;
  line-height: 1.55;
}

.message.mine {
  align-self: flex-end;
  background: var(--deep);
  color: white;
}

.message-form {
  display: flex;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 44px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-tabs {
    grid-template-columns: repeat(5, 1fr);
  }

  .tab {
    justify-content: center;
    padding: 0 8px;
  }

  .profile {
    display: none;
  }

  .workspace {
    padding: 18px;
  }

  .editor-layout,
  .ocean-stage,
  .chat-shell,
  .timeline-item {
    grid-template-columns: 1fr;
  }

  .conversation-list {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
  }

  .topbar h2 {
    font-size: 24px;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
  }

  .nav-tabs {
    grid-template-columns: repeat(2, 1fr);
  }

  .tab {
    min-height: 40px;
  }

  .form-footer,
  .message-form,
  .timeline-toolbar,
  .timeline-head {
    align-items: stretch;
    flex-direction: column;
  }

  .timeline-toolbar input {
    max-width: none;
  }

  .map-card,
  .bottle-reader {
    min-height: 340px;
  }
}
