:root {
  color-scheme: light;
  --paper: #f7f5ef;
  --paper-deep: #eeebe2;
  --surface: #fffefa;
  --surface-muted: #f2efe7;
  --ink: #26241f;
  --ink-soft: #68645c;
  --line: #ded9cd;
  --accent: #b85f3d;
  --accent-dark: #8f452b;
  --accent-pale: #f3ded2;
  --green: #5f7c63;
  --shadow: 0 18px 50px rgba(65, 54, 39, 0.09);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
}

body {
  min-height: 100vh;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.mobile-only {
  display: none;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: Georgia, "Songti SC", serif;
  font-size: 22px;
  font-weight: 700;
}

.brand-large {
  font-size: 26px;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
}

.auth-layout {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(420px, 1.1fr) minmax(430px, 0.9fr);
}

.auth-intro {
  position: relative;
  display: flex;
  overflow: hidden;
  flex-direction: column;
  justify-content: space-between;
  padding: 52px clamp(48px, 7vw, 110px);
  background:
    radial-gradient(circle at 78% 16%, rgba(255, 255, 255, 0.65), transparent 25%),
    linear-gradient(145deg, #eee5d6 0%, #d9c8ae 100%);
}

.auth-intro::after {
  position: absolute;
  right: -130px;
  bottom: -170px;
  width: 470px;
  height: 470px;
  border: 1px solid rgba(104, 78, 52, 0.18);
  border-radius: 50%;
  box-shadow:
    0 0 0 60px rgba(255, 255, 255, 0.06),
    0 0 0 130px rgba(255, 255, 255, 0.04);
  content: "";
}

.intro-copy {
  position: relative;
  z-index: 1;
  max-width: 610px;
}

.intro-copy h1 {
  margin: 0 0 28px;
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(48px, 5.2vw, 76px);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 1.06;
}

.intro-copy > p:last-child {
  max-width: 500px;
  margin: 0;
  color: #5c5144;
  font-size: 17px;
  line-height: 1.8;
}

.intro-foot {
  position: relative;
  z-index: 1;
  margin: 0;
  color: #695e50;
  font-size: 13px;
  letter-spacing: 0.16em;
}

.auth-panel {
  display: grid;
  min-height: 100vh;
  padding: 48px;
  place-items: center;
  background: var(--surface);
}

.auth-card {
  width: min(100%, 430px);
}

.auth-mobile-brand {
  display: none;
}

.auth-tabs {
  display: flex;
  width: fit-content;
  margin-bottom: 52px;
  gap: 26px;
  border-bottom: 1px solid var(--line);
}

.auth-tab {
  padding: 10px 2px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--ink-soft);
}

.auth-tab.active {
  border-color: var(--accent);
  color: var(--ink);
  font-weight: 700;
}

.auth-form {
  display: grid;
  gap: 22px;
}

.auth-form h2 {
  margin: 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: 34px;
  font-weight: 500;
}

label {
  display: grid;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
}

input,
textarea,
select {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 150ms, box-shadow 150ms;
}

textarea {
  resize: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(184, 95, 61, 0.12);
}

.primary-button,
.secondary-button,
.quiet-button,
.send-button,
.icon-button {
  min-height: 42px;
  border-radius: 10px;
  font-weight: 700;
}

.primary-button {
  padding: 10px 18px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
}

.primary-button:hover {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
}

.secondary-button {
  padding: 9px 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.secondary-button:hover {
  background: var(--surface-muted);
}

.quiet-button {
  min-height: 34px;
  padding: 6px 9px;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
}

.quiet-button:hover {
  color: var(--accent);
}

.full-width {
  width: 100%;
}

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

.sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  height: 100vh;
  flex-direction: column;
  padding: 30px 20px 22px;
  border-right: 1px solid var(--line);
  background: var(--paper-deep);
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 9px;
}

.main-nav {
  display: grid;
  margin-top: 48px;
  gap: 6px;
}

.nav-item {
  display: flex;
  min-height: 46px;
  align-items: center;
  padding: 10px 14px;
  gap: 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-soft);
  text-align: left;
}

.nav-item > span:first-child {
  width: 20px;
  font-size: 18px;
  text-align: center;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.62);
  color: var(--ink);
}

.nav-item.active {
  font-weight: 700;
}

.account-summary {
  display: grid;
  align-items: center;
  margin-top: auto;
  padding: 13px 9px 0;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 10px;
  border-top: 1px solid var(--line);
}

.avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: #d6c5aa;
  color: #4d4235;
  font-weight: 800;
}

.account-summary-copy {
  display: grid;
  overflow: hidden;
  gap: 2px;
}

.account-summary-copy strong,
.account-summary-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-summary-copy span {
  color: var(--ink-soft);
  font-size: 11px;
}

.workspace {
  display: flex;
  min-width: 0;
  height: 100vh;
  flex-direction: column;
  background: var(--paper);
}

.topbar {
  display: flex;
  min-height: 92px;
  align-items: center;
  justify-content: space-between;
  padding: 20px clamp(24px, 4vw, 58px);
  border-bottom: 1px solid var(--line);
  background: rgba(247, 245, 239, 0.92);
}

.topbar h2 {
  margin: 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: 26px;
  font-weight: 500;
}

.network-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(95, 124, 99, 0.13);
}

.panel {
  overflow: auto;
  flex: 1;
  padding: 32px clamp(24px, 4vw, 58px) 50px;
}

.panel-chat {
  display: flex;
  overflow: hidden;
  padding-bottom: 24px;
  flex-direction: column;
}

.chat-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  padding-bottom: 18px;
  gap: 14px;
}

.select-label {
  width: min(360px, 70%);
}

.message-list {
  display: flex;
  overflow-y: auto;
  min-height: 240px;
  flex: 1;
  flex-direction: column;
  padding: 24px max(12px, 7vw);
  gap: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.empty-state {
  display: grid;
  max-width: 430px;
  margin: auto;
  place-items: center;
  color: var(--ink-soft);
  text-align: center;
}

.empty-state h3 {
  margin: 12px 0 5px;
  color: var(--ink);
  font-family: Georgia, "Songti SC", serif;
  font-size: 23px;
  font-weight: 500;
}

.empty-state p {
  margin: 0;
  line-height: 1.7;
}

.empty-symbol {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-pale);
  color: var(--accent);
  font-size: 23px;
}

.message {
  max-width: min(75%, 680px);
}

.message.mine {
  align-self: end;
}

.message.theirs {
  align-self: start;
}

.message-meta {
  display: flex;
  margin: 0 4px 6px;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 11px;
}

.message.mine .message-meta {
  justify-content: end;
}

.message-body {
  padding: 13px 16px;
  border-radius: 15px 15px 15px 4px;
  background: var(--surface-muted);
  line-height: 1.65;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message.mine .message-body {
  border-radius: 15px 15px 4px 15px;
  background: var(--accent);
  color: #fff;
}

.composer {
  position: relative;
  display: flex;
  margin-top: 16px;
  align-items: end;
  gap: 10px;
}

.composer textarea {
  min-height: 52px;
  max-height: 160px;
  padding: 14px 58px 14px 16px;
  border-radius: 16px;
  box-shadow: 0 6px 20px rgba(65, 54, 39, 0.05);
}

.send-button {
  position: absolute;
  right: 8px;
  bottom: 7px;
  width: 38px;
  min-height: 38px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 20px;
}

.metric-grid {
  display: grid;
  margin-bottom: 26px;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 18px;
}

.metric-card,
.surface,
.spark-card,
.node-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.metric-card {
  display: grid;
  min-height: 180px;
  align-content: space-between;
  padding: 25px;
}

.metric-card.featured {
  border-color: #d9bca9;
  background: linear-gradient(145deg, #f6e5da, #f7eee6);
}

.metric-card p,
.metric-card span {
  margin: 0;
  color: var(--ink-soft);
}

.metric-card strong {
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(33px, 5vw, 50px);
  font-weight: 500;
}

.metric-card .small-metric {
  font-size: clamp(15px, 2vw, 23px);
  overflow-wrap: anywhere;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(300px, 0.8fr) minmax(360px, 1.2fr);
  gap: 18px;
}

.surface {
  padding: 24px;
}

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

.section-heading h3 {
  margin: 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: 24px;
  font-weight: 500;
}

.page-section-heading {
  margin-bottom: 28px;
}

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

.ledger-list {
  display: grid;
  max-height: 420px;
  overflow-y: auto;
}

.ledger-item {
  display: grid;
  align-items: center;
  padding: 13px 0;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.ledger-item:last-child {
  border-bottom: 0;
}

.ledger-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.ledger-copy span {
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ledger-amount {
  font-weight: 800;
}

.ledger-amount.incoming {
  color: var(--green);
}

.ledger-amount.outgoing {
  color: var(--accent);
}

.inline-create {
  display: flex;
  align-items: end;
  margin-bottom: 24px;
  padding: 20px;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.inline-create label {
  width: min(420px, 100%);
}

.credential-notice,
.info-banner {
  display: flex;
  align-items: center;
  margin-bottom: 24px;
  padding: 16px 18px;
  gap: 15px;
  border: 1px solid #dcb9a5;
  border-radius: 14px;
  background: #f8e8de;
}

.credential-notice > div {
  min-width: 180px;
}

.credential-notice p,
.info-banner p {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.5;
}

.credential-notice code {
  overflow: hidden;
  min-width: 0;
  padding: 9px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.68);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.info-banner {
  border-color: #d8d1bd;
  background: #eeebdf;
}

.info-banner > span {
  font-size: 22px;
}

.info-banner p {
  margin: 0;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.spark-card,
.node-card {
  display: grid;
  min-height: 190px;
  padding: 22px;
  gap: 18px;
}

.card-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-title-row h4 {
  margin: 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: 20px;
  font-weight: 500;
}

.card-title-row p {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.badge {
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--ink-soft);
  font-size: 11px;
  white-space: nowrap;
}

.badge.online {
  background: #e1ece0;
  color: #4c6d50;
}

.badge.offline {
  background: #ece8e2;
  color: #7c756b;
}

.card-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.card-stat {
  display: grid;
  gap: 4px;
}

.card-stat span {
  color: var(--ink-soft);
  font-size: 11px;
}

.card-stat strong {
  font-size: 14px;
  overflow-wrap: anywhere;
}

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 100;
  max-width: min(420px, calc(100vw - 32px));
  padding: 13px 17px;
  border-radius: 11px;
  box-shadow: var(--shadow);
  background: var(--ink);
  color: #fff;
  font-size: 13px;
}

.toast.error {
  background: #8e3e32;
}

.icon-button {
  display: grid;
  width: 42px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 19px;
}

@media (max-width: 900px) {
  .auth-layout {
    grid-template-columns: 1fr;
  }

  .auth-intro {
    display: none;
  }

  .auth-panel {
    padding: 28px 20px;
  }

  .auth-mobile-brand {
    display: flex;
    align-items: center;
    margin-bottom: 44px;
    gap: 10px;
    font-family: Georgia, "Songti SC", serif;
    font-size: 24px;
    font-weight: 700;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .mobile-only {
    display: grid;
  }

  .sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-102%);
    width: min(290px, 85vw);
    transition: transform 180ms ease;
    box-shadow: var(--shadow);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-scrim {
    position: fixed;
    z-index: 15;
    inset: 0;
    display: block;
    background: rgba(38, 36, 31, 0.33);
  }

  .topbar {
    min-height: 78px;
    justify-content: flex-start;
    gap: 14px;
  }

  .network-status {
    margin-left: auto;
  }

  .metric-grid,
  .two-column {
    grid-template-columns: 1fr;
  }

  .message {
    max-width: 88%;
  }
}

@media (max-width: 580px) {
  .auth-tabs {
    margin-bottom: 36px;
  }

  .topbar {
    padding: 14px 16px;
  }

  .topbar .eyebrow {
    display: none;
  }

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

  .network-status span:last-child {
    display: none;
  }

  .panel {
    padding: 20px 14px 32px;
  }

  .chat-toolbar {
    align-items: end;
  }

  .select-label {
    width: 100%;
  }

  .message-list {
    padding: 18px 12px;
    border-radius: 14px;
  }

  .message {
    max-width: 94%;
  }

  .metric-card {
    min-height: 155px;
  }

  .surface {
    padding: 18px;
  }

  .section-heading {
    align-items: flex-start;
  }

  .page-section-heading {
    flex-direction: column;
  }

  .page-section-heading button {
    width: 100%;
  }

  .inline-create,
  .credential-notice,
  .info-banner {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-create button,
  .credential-notice button {
    width: 100%;
  }

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

  .toast {
    right: 16px;
    bottom: 16px;
    left: 16px;
  }
}
