:root {
  --paper: #f8f3ec;
  --paper-warm: #f2e9de;
  --paper-deep: #e9ded2;
  --ink: #28231e;
  --soft-ink: #514840;
  --muted: #8d8176;
  --hairline: rgba(48, 39, 31, 0.105);
  --quiet-line: rgba(48, 39, 31, 0.065);
  --brand: #96362d;
  --brand-dark: #68251f;
  --sage: #687264;
  --clay: #b89b82;
  --surface: rgba(255, 252, 247, 0.74);
  --surface-light: rgba(255, 252, 247, 0.52);
  --shadow: 0 30px 90px rgba(92, 67, 43, 0.105);
  --shadow-soft: 0 14px 44px rgba(92, 67, 43, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(248, 243, 236, 0.82), rgba(242, 233, 222, 0.76)),
    radial-gradient(circle at 8% 4%, rgba(255, 252, 247, 0.7), transparent 30rem),
    radial-gradient(circle at 92% 92%, rgba(150, 54, 45, 0.075), transparent 34rem),
    url("./assets/zhixin-bg-ink-clean-v1.png");
  background-size: auto, auto, auto, cover;
  background-position: center;
  background-attachment: fixed;
  color: var(--ink);
  font-family:
    "Noto Serif SC",
    "Source Han Serif SC",
    "Songti SC",
    "Microsoft YaHei",
    serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1480px, calc(100vw - 36px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 0 30px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  padding: 0 2px;
}

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

.brand-logo {
  width: 62px;
  height: 62px;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(84, 52, 36, 0.08));
}

.brand-name {
  font-size: 21px;
  letter-spacing: 0;
}

.brand-subtitle,
.eyebrow,
.section-head span {
  color: var(--muted);
  font-size: 12px;
}

.brand-subtitle {
  margin-top: 5px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quota-pill {
  min-width: 110px;
  padding: 10px 16px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--brand-dark);
  text-align: center;
  background: rgba(255, 252, 247, 0.56);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(430px, 0.92fr);
  gap: 20px;
  min-height: calc(100vh - 126px);
}

.panel {
  overflow: hidden;
  border: 1px solid var(--quiet-line);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 252, 247, 0.78), rgba(255, 252, 247, 0.48)),
    rgba(255, 252, 247, 0.58);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  position: relative;
}

.chat-panel::before {
  content: "";
  position: absolute;
  left: 30px;
  right: 30px;
  bottom: 92px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(48, 39, 31, 0.11), transparent);
  pointer-events: none;
}

.record-panel {
  overflow-y: auto;
  padding-bottom: 18px;
  scrollbar-width: thin;
  scrollbar-color: rgba(104, 37, 31, 0.28) transparent;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 30px 30px 20px;
}

.eyebrow {
  margin: 0 0 8px;
  letter-spacing: 0.08em;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 400;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(31px, 3.15vw, 52px);
  line-height: 1.08;
}

h2 {
  font-size: 30px;
  line-height: 1.18;
}

h3 {
  font-size: 17px;
}

.conversation-list {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 0 30px 20px;
}

.conversation-chip {
  flex: 0 0 auto;
  max-width: 230px;
  padding: 9px 13px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 252, 247, 0.28);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.conversation-chip.active {
  color: var(--ink);
  border-color: rgba(157, 51, 43, 0.3);
  background: rgba(157, 51, 43, 0.07);
}

.message-stream {
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  padding: 10px 30px 30px;
  scrollbar-width: thin;
  scrollbar-color: rgba(104, 37, 31, 0.25) transparent;
}

.message-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.message-row.assistant {
  justify-content: flex-start;
}

.message-row.user {
  justify-content: flex-end;
}

.message-row.user .message-mark {
  order: 2;
}

.message-mark {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  margin-top: 6px;
  font-size: 13px;
  line-height: 1;
}

.message-mark.assistant {
  color: var(--brand-dark);
  border: 1px solid rgba(150, 54, 45, 0.22);
  background: rgba(255, 252, 247, 0.62);
}

.message-mark.user {
  color: #fffaf5;
  background: var(--brand-dark);
  box-shadow: 0 10px 26px rgba(104, 37, 31, 0.16);
}

.message {
  max-width: min(74%, 640px);
  padding: 17px 19px;
  border-radius: 14px;
  line-height: 1.9;
  font-size: 15px;
  position: relative;
  letter-spacing: 0;
}

.message.assistant {
  color: var(--soft-ink);
  background:
    linear-gradient(90deg, rgba(104, 37, 31, 0.035), transparent 34%),
    linear-gradient(180deg, rgba(255, 253, 249, 0.88), rgba(255, 250, 244, 0.7));
  border: 1px solid var(--quiet-line);
  box-shadow: var(--shadow-soft);
}

.message.assistant::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 12px;
  bottom: 12px;
  width: 2px;
  border-radius: 99px;
  background: linear-gradient(180deg, rgba(150, 54, 45, 0.42), rgba(150, 54, 45, 0.05));
}

.message.user {
  color: #fffaf5;
  background:
    linear-gradient(180deg, rgba(150, 54, 45, 0.98), rgba(104, 37, 31, 0.98));
  box-shadow: 0 16px 36px rgba(104, 37, 31, 0.16);
  border: 1px solid rgba(255, 252, 247, 0.18);
}

.message.user::after {
  content: "";
  position: absolute;
  right: -7px;
  top: 18px;
  width: 13px;
  height: 13px;
  background: rgba(124, 43, 36, 0.98);
  transform: rotate(45deg);
  border-radius: 3px;
  box-shadow: 8px 10px 18px rgba(104, 37, 31, 0.07);
}

.message small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.message::selection,
.record-item::selection,
textarea::selection,
input::selection {
  background: rgba(150, 54, 45, 0.18);
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 18px 24px 24px;
  border-top: 0;
  background:
    linear-gradient(180deg, rgba(255, 252, 247, 0.12), rgba(255, 252, 247, 0.62));
  position: relative;
}

.composer::before {
  content: "";
  position: absolute;
  left: 24px;
  right: 24px;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(48, 39, 31, 0.12), transparent);
}

textarea,
input {
  width: 100%;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  outline: none;
  background: rgba(255, 252, 247, 0.68);
  color: var(--ink);
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

textarea:focus,
input:focus {
  border-color: rgba(157, 51, 43, 0.38);
  background: rgba(255, 252, 247, 0.92);
  box-shadow: 0 0 0 4px rgba(150, 54, 45, 0.055);
}

textarea {
  resize: none;
  line-height: 1.65;
}

.composer textarea {
  min-height: 58px;
  max-height: 150px;
  padding: 16px 18px;
  background:
    linear-gradient(180deg, rgba(255, 253, 249, 0.86), rgba(255, 248, 239, 0.72));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    0 12px 32px rgba(92, 67, 43, 0.055);
}

.primary-button,
.ghost-button,
.text-button {
  min-height: 42px;
  border-radius: 999px;
  border: 0;
  padding: 0 20px;
  transition: transform 0.16s ease, background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.primary-button:active,
.ghost-button:active,
.text-button:active {
  transform: translateY(1px);
}

.primary-button {
  color: #fffaf5;
  background: linear-gradient(180deg, var(--brand), var(--brand-dark));
  box-shadow: 0 12px 26px rgba(104, 37, 31, 0.15);
}

.primary-button:hover {
  background: var(--brand-dark);
}

.primary-button.subtle {
  color: var(--brand-dark);
  border: 1px solid rgba(157, 51, 43, 0.22);
  background: rgba(255, 252, 247, 0.38);
  box-shadow: none;
}

.primary-button.full {
  width: 100%;
  margin-top: 2px;
}

.ghost-button {
  color: var(--ink);
  border: 1px solid var(--hairline);
  background: rgba(255, 252, 247, 0.38);
}

.text-button {
  min-height: 34px;
  padding: 0 2px;
  color: var(--brand-dark);
  background: transparent;
  border-radius: 0;
}

.record-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 30px 16px;
}

.record-tab,
.mobile-tab {
  min-height: 42px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 252, 247, 0.34);
}

.record-tab.active,
.mobile-tab.active {
  color: var(--brand-dark);
  border-color: rgba(157, 51, 43, 0.26);
  background: rgba(157, 51, 43, 0.08);
}

.record-form {
  display: grid;
  gap: 14px;
  padding: 0 30px;
}

.record-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.record-form label span b {
  color: var(--brand-dark);
  font-weight: 400;
}

.record-form input:not([type="range"]),
.record-form textarea {
  padding: 12px 13px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

input[type="range"] {
  accent-color: var(--brand);
  height: 42px;
  padding: 0;
  border: 0;
  background: transparent;
}

.deep-fields {
  display: grid;
  gap: 12px;
}

.ai-hint {
  margin: 0 30px 16px;
  padding: 16px 17px 13px;
  border-radius: 10px;
  border: 1px solid rgba(150, 54, 45, 0.14);
  background:
    linear-gradient(180deg, rgba(255, 252, 247, 0.72), rgba(255, 247, 240, 0.52)),
    rgba(150, 54, 45, 0.035);
  box-shadow: var(--shadow-soft);
}

.ai-hint p {
  margin: 0 0 8px;
  color: #433a32;
  line-height: 1.7;
}

.wave-section,
.timeline-section {
  padding: 18px 30px 0;
}

.paper-block {
  margin-top: 4px;
}

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

canvas {
  width: 100%;
  height: 188px;
  border-radius: 10px;
  background:
    linear-gradient(90deg, rgba(48, 39, 31, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(48, 39, 31, 0.026) 1px, transparent 1px),
    rgba(255, 252, 247, 0.54);
  background-size: 28px 28px;
  border: 1px solid var(--quiet-line);
}

.timeline {
  display: grid;
  gap: 11px;
}

.record-item {
  padding: 15px 16px;
  border-radius: 10px;
  background: rgba(255, 252, 247, 0.56);
  border: 1px solid var(--quiet-line);
  box-shadow: 0 10px 28px rgba(92, 67, 43, 0.045);
}

.record-item strong {
  display: block;
  margin-bottom: 5px;
  font-weight: 400;
  color: var(--soft-ink);
}

.record-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.record-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.mobile-tabs {
  display: none;
}

.paywall {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(39, 35, 31, 0.28);
}

.paywall-panel {
  position: relative;
  width: min(440px, 100%);
  padding: 30px;
  border-radius: 10px;
  background: rgba(255, 252, 247, 0.94);
  box-shadow: 0 24px 90px rgba(39, 35, 31, 0.18);
  border: 1px solid var(--quiet-line);
  backdrop-filter: blur(22px);
}

.paywall-copy {
  color: var(--muted);
  line-height: 1.8;
}

.paywall-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.close-button {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  font-size: 24px;
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .app-shell {
    width: min(100vw - 20px, 720px);
    padding-top: 16px;
  }

  .topbar {
    align-items: flex-start;
  }

  .brand-logo {
    width: 50px;
    height: 50px;
  }

  .top-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .quota-pill {
    min-width: 92px;
    padding: 8px 10px;
  }

  .mobile-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
  }

  .workspace {
    display: block;
    min-height: auto;
  }

  .panel {
    min-height: calc(100vh - 148px);
    border-radius: 10px;
  }

  .panel:not(.active-mobile) {
    display: none;
  }

  .message {
    max-width: 88%;
  }

  .panel-head,
  .message-stream,
  .conversation-list,
  .record-tabs,
  .record-form,
  .wave-section,
  .timeline-section {
    padding-left: 18px;
    padding-right: 18px;
  }

  .composer {
    padding: 16px 16px 18px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar {
    display: grid;
  }

  .top-actions {
    flex-direction: row;
  }

  .brand-subtitle {
    font-size: 11px;
  }

  h1 {
    font-size: 31px;
  }

  h2 {
    font-size: 24px;
  }

  .composer {
    grid-template-columns: 1fr;
  }

  .message {
    max-width: calc(100% - 44px);
    font-size: 14px;
  }

  .message-mark {
    width: 30px;
    height: 30px;
    font-size: 12px;
  }

  canvas {
    height: 160px;
  }

  .primary-button,
  .ghost-button {
    width: 100%;
  }

  .paywall-actions {
    display: grid;
  }
}
