:root {
  color-scheme: dark;
  --ink: #f4f1e8;
  --muted: #c9c0ad;
  --faint: #948a78;
  --deep: #111713;
  --panel: rgba(24, 31, 25, 0.56);
  --panel-solid: #20281f;
  --line: rgba(244, 241, 232, 0.22);
  --line-strong: rgba(244, 241, 232, 0.36);
  --moss: #88a87d;
  --moss-strong: #b8d0a8;
  --amber: #d8a85e;
  --rose: #d9a6a0;
  --danger: #bd7771;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans TC", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--deep);
}

body {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  overflow-x: hidden;
  background: var(--deep);
}

body::before,
body::after {
  position: fixed;
  inset: 0;
  content: "";
  pointer-events: none;
}

body::before {
  z-index: -2;
  background: url("/assets/tree-hollow-secret-sunlight-86dc0d54.png") center / cover no-repeat;
  filter: brightness(1.32) saturate(1.08);
  transform: scale(1.01);
}

body::after {
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(12, 17, 14, 0.5), rgba(12, 17, 14, 0.18) 48%, rgba(12, 17, 14, 0.42)),
    linear-gradient(180deg, rgba(12, 17, 14, 0), rgba(12, 17, 14, 0.48));
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

a {
  color: inherit;
}

h1,
h2,
p {
  margin-block: 0;
}

h1 {
  margin-top: 3px;
  font-size: clamp(1.8rem, 4vw, 2.65rem);
  line-height: 1.02;
  font-weight: 760;
}

h2 {
  margin-top: 4px;
  font-size: 1.1rem;
  line-height: 1.2;
  font-weight: 740;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.topbar,
.panel,
.auth-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 22px 68px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(18px) saturate(1.18);
  -webkit-backdrop-filter: blur(18px) saturate(1.18);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 360px) minmax(180px, 240px);
  align-items: center;
  gap: 16px;
  padding: 18px;
}

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

.brand-mark {
  display: inline-grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(244, 241, 232, 0.3);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 46%, rgba(216, 168, 94, 0.96) 0 12%, rgba(216, 168, 94, 0.2) 13% 28%, transparent 29%),
    radial-gradient(circle at 50% 50%, rgba(17, 23, 19, 0.2) 0 32%, rgba(244, 241, 232, 0.08) 33% 100%),
    #223026;
  color: #fff8e8;
  font-size: 0.78rem;
  font-weight: 800;
}

.eyebrow,
.mini-label {
  margin: 0;
  color: var(--moss-strong);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.identity-card,
.partner-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(244, 241, 232, 0.1);
  padding: 14px;
}

.identity-card form {
  margin: 0;
}

.identity-name {
  margin-top: 4px;
  color: #fff8e8;
  font-size: 1.85rem;
  font-weight: 780;
  line-height: 1;
}

.partner-strip {
  min-height: 52px;
  color: var(--muted);
}

.partner-strip strong {
  color: var(--amber);
  font-size: 1.08rem;
}

.exchange-grid,
.collab-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(340px, 0.92fr);
  gap: 18px;
  align-items: start;
}

.receive-stack {
  display: grid;
  gap: 18px;
}

.panel,
.auth-panel {
  padding: 18px;
}

.composer-panel,
.note-panel,
.goal-panel,
.message-panel,
.vault-panel {
  min-width: 0;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.entry-form,
.goal-form,
.note-form,
.auth-form {
  display: grid;
  gap: 10px;
}

.field-group {
  display: grid;
  gap: 8px;
}

.field-label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 680;
}

.delivery-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  border: 0;
  padding: 0;
}

.delivery-options legend {
  grid-column: 1 / -1;
  margin-bottom: 2px;
}

.delivery-choice {
  display: flex;
  min-height: 68px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(244, 241, 232, 0.08);
  padding: 12px;
  transition:
    border-color 160ms ease,
    background-color 160ms ease;
}

.delivery-choice:has(input:checked) {
  border-color: rgba(216, 168, 94, 0.58);
  background: rgba(216, 168, 94, 0.16);
}

.delivery-choice input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--amber);
}

.delivery-choice span {
  display: grid;
  gap: 3px;
}

.delivery-choice strong {
  color: #fff8e8;
  font-size: 0.95rem;
}

.delivery-choice small {
  color: var(--muted);
  font-size: 0.78rem;
}

textarea,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  background: rgba(9, 13, 10, 0.42);
  color: var(--ink);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease;
}

textarea {
  min-height: 270px;
  resize: vertical;
  padding: 15px;
  line-height: 1.7;
}

.note-form textarea {
  min-height: 220px;
}

input {
  min-height: 44px;
  padding: 0 12px;
}

textarea::placeholder,
input::placeholder {
  color: rgba(201, 192, 173, 0.52);
}

textarea:focus,
input:focus {
  border-color: rgba(184, 208, 168, 0.76);
  background: rgba(9, 13, 10, 0.58);
  box-shadow: 0 0 0 3px rgba(136, 168, 125, 0.17);
}

.form-actions,
.note-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.primary-button,
.secondary-button,
.icon-text-button,
.mini-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0 14px;
  color: var(--ink);
  text-decoration: none;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background-color 160ms ease;
}

.primary-button {
  width: 100%;
  background: linear-gradient(135deg, rgba(216, 168, 94, 0.98), rgba(136, 168, 125, 0.92));
  color: #12170f;
  font-weight: 800;
}

.secondary-button {
  background: rgba(184, 208, 168, 0.16);
  border-color: rgba(184, 208, 168, 0.35);
  font-weight: 750;
}

.icon-text-button,
.mini-button {
  background: rgba(244, 241, 232, 0.1);
  border-color: var(--line);
}

.mini-button {
  min-height: 34px;
  padding: 0 11px;
  color: var(--muted);
  font-size: 0.82rem;
}

.danger {
  color: #ffd8d2;
  border-color: rgba(189, 119, 113, 0.42);
  background: rgba(189, 119, 113, 0.14);
}

.primary-button:hover,
.secondary-button:hover,
.icon-text-button:hover,
.mini-button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.count-pill {
  display: inline-flex;
  min-width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(216, 168, 94, 0.34);
  border-radius: 50%;
  background: rgba(216, 168, 94, 0.14);
  color: #ffe3ad;
  font-weight: 800;
}

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

.goal-list.has-goals {
  border: 1px solid rgba(216, 168, 94, 0.24);
  border-radius: calc(var(--radius) + 2px);
  background:
    linear-gradient(180deg, rgba(216, 168, 94, 0.11), rgba(9, 13, 10, 0.08)),
    rgba(244, 241, 232, 0.04);
  box-shadow:
    inset 0 1px 0 rgba(244, 241, 232, 0.1),
    0 16px 42px rgba(0, 0, 0, 0.18);
  padding: 10px;
}

.entry-item,
.goal-item,
.empty-item {
  border: 1px solid rgba(244, 241, 232, 0.16);
  border-radius: var(--radius);
  background: rgba(9, 13, 10, 0.28);
  padding: 13px;
}

.entry-item.read {
  opacity: 0.72;
}

.item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--faint);
  font-size: 0.78rem;
  font-weight: 680;
}

.item-tag {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 4px 8px;
  color: #142014;
  font-size: 0.72rem;
  font-weight: 800;
}

.item-tag.warm {
  background: #ffdca3;
}

.item-tag.soft {
  background: #cfe5c2;
}

.item-tag.heavy {
  background: #e8b2ab;
}

.message-body,
.note-form textarea {
  color: var(--ink);
  line-height: 1.7;
}

.message-body {
  margin-top: 10px;
}

.message-body p + p {
  margin-top: 8px;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.item-actions form {
  margin: 0;
}

.goal-form {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: end;
  margin-bottom: 14px;
}

.goal-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  overflow: hidden;
  border-color: rgba(216, 168, 94, 0.38);
  background:
    linear-gradient(135deg, rgba(216, 168, 94, 0.19), rgba(136, 168, 125, 0.12)),
    rgba(9, 13, 10, 0.4);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.22);
}

.goal-item::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  content: "";
  background: linear-gradient(180deg, var(--amber), var(--moss-strong));
}

.goal-item.done {
  border-color: rgba(244, 241, 232, 0.16);
  background: rgba(9, 13, 10, 0.3);
  opacity: 0.82;
}

.goal-item.done::before {
  background: rgba(184, 208, 168, 0.38);
}

.goal-copy {
  display: grid;
  gap: 7px;
  padding-left: 4px;
}

.goal-copy strong {
  color: #fff8e8;
  font-size: 1.03rem;
  line-height: 1.28;
}

.goal-item.done .goal-copy strong {
  color: var(--muted);
  text-decoration: line-through;
}

.goal-copy span {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  border: 1px solid rgba(216, 168, 94, 0.22);
  border-radius: 999px;
  background: rgba(216, 168, 94, 0.12);
  padding: 5px 9px;
  color: #ffe3ad;
  font-size: 0.84rem;
  font-weight: 720;
}

.goal-copy small,
.empty-item,
.sync-status {
  color: var(--muted);
}

.note-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  color: var(--faint);
  font-size: 0.78rem;
  font-weight: 680;
}

.auth-shell {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

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

.auth-link {
  color: var(--muted);
  font-size: 0.9rem;
  text-decoration-color: rgba(201, 192, 173, 0.38);
}

.flash-stack {
  position: fixed;
  z-index: 5;
  top: 16px;
  left: 50%;
  display: grid;
  width: min(520px, calc(100% - 32px));
  gap: 8px;
  transform: translateX(-50%);
}

.flash-message {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(24, 31, 25, 0.86);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  color: var(--ink);
  backdrop-filter: blur(18px);
}

.flash-message.alert {
  border-color: rgba(189, 119, 113, 0.5);
}

@media (max-width: 980px) {
  .topbar,
  .exchange-grid,
  .collab-grid,
  .goal-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  body::before,
  body::after {
    position: absolute;
  }

  body::before {
    transform: none;
  }

  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 10px 0;
  }

  .panel,
  .topbar,
  .auth-panel {
    padding: 14px;
  }

  .topbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .brand-lockup {
    grid-column: 1 / -1;
    gap: 10px;
  }

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

  .topbar h1 {
    font-size: 1.45rem;
  }

  .identity-card,
  .partner-strip {
    min-height: 80px;
    gap: 8px;
    padding: 10px;
  }

  .identity-name {
    font-size: 1.22rem;
  }

  .partner-strip strong {
    font-size: 1rem;
  }

  .icon-text-button {
    min-height: 34px;
    width: 100%;
    padding: 0 10px;
    font-size: 0.82rem;
  }

  .goal-item {
    align-items: stretch;
    flex-direction: column;
  }

  .item-meta,
  .note-meta,
  .note-actions,
  .delivery-options {
    align-items: flex-start;
    flex-direction: column;
  }

  .delivery-options,
  .form-actions,
  .item-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .delivery-choice {
    min-height: 62px;
    padding: 10px;
  }

  .delivery-choice strong {
    font-size: 0.88rem;
  }

  .delivery-choice small {
    font-size: 0.72rem;
  }

  .form-actions,
  .item-actions {
    display: grid;
    width: 100%;
  }

  .form-actions .primary-button {
    grid-column: 1 / -1;
  }

  .item-actions form,
  .item-actions .button_to,
  .mini-button {
    width: 100%;
  }
}
