:root {
  --canvas: #c7e8f8;
  --ink: #17191b;
  --muted: #526774;
  --rule: #9fc4d7;
  --accent: #416f87;
  --accent-strong: #2e596f;
  --wash: rgb(234 247 253 / 62%);
  --error: #8a3f39;
  color-scheme: light;
  font-family: "HanziPen SC", "HanziPen TC", "Bradley Hand", "Klee", "PingFang SC",
    sans-serif;
  background: var(--canvas);
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    repeating-linear-gradient(
      0deg,
      transparent 0,
      transparent 31px,
      rgb(65 111 135 / 8%) 32px
    ),
    var(--canvas);
}

button,
input,
textarea {
  font: inherit;
}

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

.page {
  width: min(100% - 40px, 840px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 52px 0 34px;
}

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--rule);
}

.eyebrow,
.section-label,
.inline-status,
.entry-meta,
.memory-meta,
.field-help,
.recall-note,
footer {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
}

.eyebrow,
.section-label {
  margin: 0 0 7px;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: clamp(3rem, 8vw, 5rem);
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 0.98;
}

h2 {
  margin-bottom: 10px;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1.08;
}

h3 {
  margin-bottom: 0;
  font-size: 1.18rem;
  font-weight: 500;
}

.tagline,
.section-head > p,
.section-head > div > p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.65;
}

.connection-button,
.notebook-tabs button,
.icon-button {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.connection-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.connection-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}

.connection-dot.is-online {
  background: #316e5b;
}

.notebook-tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: clamp(18px, 6vw, 54px);
  margin-bottom: 48px;
  padding: 15px 0 13px;
  border-bottom: 1px solid var(--rule);
  background: rgb(199 232 248 / 92%);
  backdrop-filter: blur(8px);
}

.notebook-tabs button {
  position: relative;
  padding: 0;
  color: var(--muted);
}

.notebook-tabs button::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -14px;
  left: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0;
  transform: scaleX(0.6);
}

.notebook-tabs button:hover,
.notebook-tabs button:focus-visible,
.notebook-tabs button.is-active {
  color: var(--ink);
}

.notebook-tabs button.is-active::after {
  opacity: 1;
  transform: scaleX(1);
}

.view {
  min-height: 590px;
}

.view[hidden] {
  display: none;
}

.section-head {
  max-width: 640px;
  margin-bottom: 38px;
}

.section-head.with-action {
  max-width: none;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.writing-form {
  margin-bottom: 58px;
}

textarea,
input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--accent);
  border-radius: 0;
  outline: 0;
  padding: 10px 2px;
  background: transparent;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

textarea:focus,
input:focus {
  border-bottom-width: 2px;
  padding-bottom: 9px;
}

textarea::placeholder,
input::placeholder {
  color: rgb(82 103 116 / 60%);
}

.writing-form textarea {
  min-height: 180px;
  font-size: 1.3rem;
  line-height: 1.75;
}

.form-foot,
.list-head,
.entry-meta,
.memory-meta,
.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.form-foot {
  min-height: 58px;
  padding-top: 12px;
}

.primary-action,
.outline-action,
.suggestion,
.entry-actions button,
.memory-actions button {
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 8px 17px;
  background: transparent;
  color: var(--accent-strong);
  cursor: pointer;
}

.primary-action:hover,
.primary-action:focus-visible,
.outline-action:hover,
.outline-action:focus-visible,
.suggestion:hover,
.suggestion:focus-visible,
.entry-actions button:hover,
.memory-actions button:hover {
  background: var(--wash);
}

button:disabled {
  cursor: wait;
  opacity: 0.52;
}

.inline-status.is-error,
.danger,
.message.is-error {
  color: var(--error);
}

.list-head {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--accent);
}

.list-head span {
  color: var(--muted);
  font-size: 0.78rem;
}

.entry-list,
.memory-list {
  display: grid;
}

.entry-item,
.memory-item {
  padding: 22px 0;
  border-bottom: 1px solid var(--rule);
}

.entry-body {
  min-height: 74px;
  margin-top: 8px;
  border-bottom-color: transparent;
  padding-inline: 0;
  font-size: 1.06rem;
  line-height: 1.65;
}

.entry-body:focus {
  border-bottom-color: var(--accent);
}

.entry-actions,
.memory-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.entry-actions button,
.memory-actions button {
  padding: 5px 11px;
  font-size: 0.72rem;
}

.empty-state {
  padding: 46px 0;
  color: var(--muted);
  line-height: 1.7;
}

.empty-state p {
  margin-bottom: 13px;
}

.suggestion {
  font-size: 0.9rem;
}

.message-list {
  min-height: 330px;
  padding-bottom: 30px;
}

.message {
  max-width: 74%;
  margin-bottom: 24px;
  font-size: 1.05rem;
  line-height: 1.72;
  white-space: pre-wrap;
}

.message.user {
  margin-left: auto;
  border-bottom: 1px solid var(--rule);
  padding: 10px 0 11px 28px;
  text-align: right;
}

.message.assistant {
  padding-left: 18px;
  border-left: 1px solid var(--accent);
}

.message.is-streaming::after {
  content: "_";
  margin-left: 3px;
  color: var(--accent);
  animation: blink 800ms step-end infinite;
}

.recall-note {
  margin: -12px 0 20px 19px;
}

.chat-composer {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 18px;
  padding: 16px 0 20px;
  border-top: 1px solid var(--rule);
  background: rgb(199 232 248 / 92%);
  backdrop-filter: blur(8px);
}

.chat-composer textarea {
  max-height: 150px;
  resize: none;
}

.memory-item {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) auto;
  gap: 22px;
  align-items: start;
}

.memory-type {
  color: var(--accent-strong);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.memory-copy {
  margin-bottom: 9px;
  font-size: 1.08rem;
  line-height: 1.6;
}

.memory-actions {
  margin-top: 0;
}

.memory-item[data-status="disabled"] {
  opacity: 0.52;
}

.growth-content {
  min-height: 300px;
  padding: 36px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.growth-quote {
  max-width: 690px;
  margin: 0;
  font-size: clamp(1.55rem, 4vw, 2.2rem);
  line-height: 1.65;
}

.growth-evidence {
  margin-top: 28px;
  color: var(--muted);
  font-size: 0.78rem;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-top: 52px;
  padding-top: 15px;
  border-top: 1px solid var(--rule);
  line-height: 1.5;
}

footer p {
  margin-bottom: 0;
}

dialog {
  width: min(calc(100% - 30px), 510px);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 0;
  background:
    repeating-linear-gradient(
      0deg,
      transparent 0,
      transparent 31px,
      rgb(65 111 135 / 8%) 32px
    ),
    #d7effa;
  color: var(--ink);
}

dialog::backdrop {
  background: rgb(39 66 79 / 24%);
}

dialog form {
  padding: 25px;
}

.dialog-head {
  align-items: flex-start;
  margin-bottom: 28px;
}

.dialog-head h3 {
  font-size: 1.5rem;
}

.icon-button {
  padding: 0;
  font-size: 1.4rem;
}

dialog label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.78rem;
}

.field-help {
  margin: 8px 0 26px;
  line-height: 1.5;
}

.dialog-actions {
  justify-content: flex-end;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: min(360px, calc(100% - 40px));
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 10px 16px;
  background: #d7effa;
  color: var(--accent-strong);
  font-size: 0.8rem;
}

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

@media (max-width: 620px) {
  .page {
    width: min(100% - 28px, 840px);
    padding-top: 30px;
  }

  .masthead {
    display: block;
  }

  .connection-button {
    margin-top: 12px;
  }

  .notebook-tabs {
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 34px;
  }

  .section-head.with-action {
    align-items: flex-start;
  }

  .message {
    max-width: 88%;
  }

  .memory-item {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .memory-actions {
    margin-top: 5px;
  }

  footer {
    display: block;
  }

  footer span {
    display: block;
    margin-top: 7px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .view.is-active {
    animation: arrive 180ms ease-out both;
  }

  button,
  .notebook-tabs button::after {
    transition:
      background-color 140ms ease,
      color 140ms ease,
      opacity 140ms ease,
      transform 140ms ease;
  }

  button:active {
    transform: scale(0.97);
  }

  @keyframes arrive {
    from {
      opacity: 0;
      transform: translateY(4px);
    }
  }

  @keyframes blink {
    50% {
      opacity: 0;
    }
  }
}
