* {
  box-sizing: border-box;
}

:root {
  --ink: #2f2921;
  --muted: #7d6e5f;
  --paper: #f8f0df;
  --paper-deep: #efe0c2;
  --card: rgba(255, 249, 235, 0.86);
  --line: rgba(84, 57, 31, 0.18);
  --cinnabar: #a5382c;
  --cinnabar-dark: #7e241d;
  --jade: #496b5a;
  --gold: #b58a43;
  --shadow: 0 24px 70px rgba(75, 48, 25, 0.16);
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family:
    "Songti SC",
    "STSong",
    "Noto Serif CJK SC",
    "Source Han Serif SC",
    Georgia,
    serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(172, 57, 43, 0.13), transparent 28rem),
    radial-gradient(circle at 78% 16%, rgba(73, 107, 90, 0.14), transparent 26rem),
    linear-gradient(135deg, #f6ecd7 0%, #fbf5e8 48%, #ecd9b9 100%);
  overflow-x: hidden;
}

button,
input,
textarea {
  font: inherit;
}

.wash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.55;
  background-image:
    linear-gradient(rgba(80, 54, 30, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(80, 54, 30, 0.035) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: radial-gradient(circle at center, black, transparent 88%);
}

.wash::after {
  content: "春 水 初 生  ·  风 物 成 诗";
  position: fixed;
  right: -4rem;
  bottom: 8rem;
  writing-mode: vertical-rl;
  letter-spacing: 0.8rem;
  color: rgba(84, 57, 31, 0.08);
  font-size: 4.6rem;
  font-weight: 700;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 52px;
  position: relative;
}

.card {
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 251, 240, 0.9), rgba(246, 235, 213, 0.82));
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.hero {
  min-height: 180px;
  padding: 28px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 24px;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  width: 380px;
  height: 160px;
  right: 10%;
  bottom: -70px;
  background:
    radial-gradient(ellipse at center, rgba(73, 107, 90, 0.16), transparent 70%);
  transform: rotate(-6deg);
}

.seal,
.stamp {
  display: inline-grid;
  place-items: center;
  color: #fff7ec;
  background: linear-gradient(145deg, var(--cinnabar), var(--cinnabar-dark));
  box-shadow: inset 0 0 0 3px rgba(255, 240, 220, 0.18);
}

.seal {
  width: 82px;
  height: 82px;
  border-radius: 22px;
  font-size: 2.9rem;
  font-weight: 800;
}

.stamp {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  font-size: 1rem;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--cinnabar);
  letter-spacing: 0.22em;
  font-size: 0.82rem;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(2rem, 5vw, 4.4rem);
  line-height: 1.05;
  letter-spacing: -0.05em;
}

h2 {
  margin-bottom: 12px;
  font-size: 1.7rem;
}

h3 {
  margin-bottom: 10px;
}

.hero-text p,
.soft,
.intro-card p,
.hint {
  color: var(--muted);
  line-height: 1.8;
}

.user-badge {
  min-width: 150px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 252, 242, 0.72);
  text-align: right;
}

.user-badge span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.user-badge strong {
  display: block;
  margin: 2px 0 8px;
  font-size: 1.1rem;
}

.auth-grid {
  margin-top: 22px;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 22px;
}

.intro-card,
.auth-card,
.compose-panel,
.poem-panel,
.history-panel {
  padding: 28px;
}

.intro-card {
  min-height: 420px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background:
    radial-gradient(circle at 85% 20%, rgba(165, 56, 44, 0.12), transparent 15rem),
    linear-gradient(180deg, rgba(255, 251, 240, 0.92), rgba(239, 224, 194, 0.78));
}

.intro-card h2 {
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 1.12;
}

.ink-list {
  margin-top: 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.ink-list span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 14px;
  color: var(--jade);
  background: rgba(255, 252, 242, 0.65);
}

.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(117, 92, 58, 0.08);
}

.tabs button {
  flex: 1;
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.tabs button.active {
  color: #fff8ed;
  background: var(--ink);
}

.auth-form {
  display: grid;
  gap: 16px;
}

label span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  outline: none;
  border-radius: 18px;
  padding: 13px 15px;
  color: var(--ink);
  background: rgba(255, 253, 246, 0.82);
  transition: border-color 0.2s, box-shadow 0.2s;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: rgba(165, 56, 44, 0.55);
  box-shadow: 0 0 0 4px rgba(165, 56, 44, 0.1);
}

.btn {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px 18px;
  color: var(--ink);
  background: rgba(255, 252, 242, 0.78);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(75, 48, 25, 0.12);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.primary {
  border-color: transparent;
  color: #fff8ed;
  background: linear-gradient(145deg, var(--cinnabar), var(--cinnabar-dark));
}

.link-btn {
  border: 0;
  padding: 0;
  color: var(--cinnabar);
  background: transparent;
  cursor: pointer;
}

.dashboard {
  margin-top: 22px;
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(320px, 1.15fr);
  gap: 22px;
  align-items: start;
}

.history-panel {
  grid-column: 1 / -1;
}

.panel-head,
.poem-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 20px 0 14px;
}

.location-hint {
  padding: 14px 16px;
  border: 1px dashed rgba(73, 107, 90, 0.38);
  border-radius: 18px;
  color: var(--jade);
  background: rgba(73, 107, 90, 0.06);
  line-height: 1.6;
}

.note-box {
  display: block;
  margin-top: 18px;
}

.weather-card {
  margin-top: 18px;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(73, 107, 90, 0.08), rgba(255, 252, 242, 0.78));
}

.weather-card p {
  color: var(--muted);
  line-height: 1.7;
}

.weather-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.weather-item {
  padding: 10px 12px;
  border-radius: 15px;
  background: rgba(255, 252, 242, 0.72);
  border: 1px solid rgba(84, 57, 31, 0.1);
}

.weather-item span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
}

.weather-item strong {
  font-size: 1.05rem;
}

.poem-panel {
  min-height: 560px;
  background:
    linear-gradient(90deg, rgba(165, 56, 44, 0.08) 0 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 251, 240, 0.94), rgba(246, 235, 213, 0.84));
  background-size: 34px 100%, auto;
}

.poem-time,
.modal-time {
  color: var(--muted);
  white-space: nowrap;
}

.poem-text {
  margin: 18px 0 0;
  padding: 24px;
  min-height: 380px;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 22px;
  border: 1px solid rgba(84, 57, 31, 0.13);
  color: #2a241c;
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.68), rgba(255, 248, 232, 0.78));
  line-height: 2.05;
  font-size: 1.08rem;
}

.history-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.history-item {
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 15px;
  color: var(--ink);
  background: rgba(255, 252, 242, 0.68);
  cursor: pointer;
}

.history-item:hover {
  border-color: rgba(165, 56, 44, 0.35);
}

.history-item strong {
  display: block;
  margin-bottom: 6px;
}

.history-item small {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.history-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.92rem;
}

.toast {
  position: fixed;
  z-index: 40;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(520px, calc(100% - 28px));
  padding: 12px 16px;
  border-radius: 999px;
  color: #fff8ed;
  background: var(--ink);
  box-shadow: var(--shadow);
}

.toast.err {
  background: var(--cinnabar-dark);
}

.modal[hidden],
.hidden {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(38, 28, 18, 0.42);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  width: min(760px, 100%);
  max-height: min(86vh, 820px);
  overflow: auto;
  padding: 28px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  color: #fff8ed;
  background: var(--ink);
  cursor: pointer;
  font-size: 1.4rem;
}

.modal-weather {
  color: var(--muted);
  line-height: 1.7;
}

@media (max-width: 880px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .user-badge {
    text-align: left;
  }

  .auth-grid,
  .dashboard,
  .history-list {
    grid-template-columns: 1fr;
  }

  .weather-grid {
    grid-template-columns: 1fr;
  }

  .poem-panel {
    min-height: auto;
  }
}