:root {
  --ink: #202722;
  --ink-soft: #3f4942;
  --muted: #747a73;
  --muted-light: #969a94;
  --paper: #f5f0e7;
  --paper-strong: #fffdf8;
  --paper-deep: #e9e0d2;
  --line: #d8cfc1;
  --line-dark: #bcb09e;
  --jade: #285f52;
  --jade-light: #dce9e3;
  --vermilion: #bd4c31;
  --gold: #ad8236;
  --danger: #aa4235;
  --success: #2f755f;
  --shadow: 0 20px 60px rgba(41, 48, 43, 0.12);
  --display: "Songti SC", "STSong", "Noto Serif SC", serif;
  --body: "Microsoft YaHei", "PingFang SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--body);
  background:
    radial-gradient(circle at 16% 8%, rgba(173, 130, 54, 0.11), transparent 28rem),
    linear-gradient(135deg, #f7f3eb 0%, #eee6da 100%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

[hidden] {
  display: none !important;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--gold);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.brand-mark {
  display: grid;
  width: 58px;
  height: 58px;
  color: #fff8ec;
  font-family: var(--display);
  font-size: 28px;
  background: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.14);
  place-items: center;
}

.brand-mark.small {
  width: 38px;
  height: 38px;
  font-size: 18px;
}

.button {
  min-height: 42px;
  padding: 0 17px;
  border: 1px solid transparent;
  transition:
    transform 150ms ease,
    background 150ms ease,
    border-color 150ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button-primary {
  color: #fff;
  background: var(--jade);
  border-color: var(--jade);
}

.button-primary:hover:not(:disabled) {
  background: #1f5045;
}

.button-ghost {
  color: var(--ink-soft);
  background: rgba(255, 253, 248, 0.7);
  border-color: var(--line);
}

.button-wide {
  width: 100%;
}

.icon-button {
  width: 36px;
  height: 36px;
  color: var(--muted);
  font-size: 24px;
  background: transparent;
  border: 1px solid var(--line);
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  min-height: 100vh;
}

.auth-story {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 9vw;
  overflow: hidden;
  background:
    linear-gradient(rgba(33, 40, 35, 0.88), rgba(33, 40, 35, 0.94)),
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.04) 0,
      rgba(255, 255, 255, 0.04) 1px,
      transparent 1px,
      transparent 28px
    );
}

.auth-story::after {
  position: absolute;
  right: -9rem;
  bottom: -9rem;
  width: 34rem;
  height: 34rem;
  content: "";
  border: 1px solid rgba(173, 130, 54, 0.3);
  border-radius: 50%;
  box-shadow:
    0 0 0 4rem rgba(173, 130, 54, 0.04),
    0 0 0 9rem rgba(173, 130, 54, 0.025);
}

.auth-story .brand-mark {
  margin-bottom: 44px;
  color: var(--ink);
  background: var(--paper);
}

.auth-story h1 {
  position: relative;
  z-index: 1;
  max-width: 780px;
  margin: 0;
  color: #fff9ef;
  font-family: var(--display);
  font-size: clamp(40px, 5.6vw, 84px);
  font-weight: 700;
  line-height: 1.16;
  letter-spacing: -0.035em;
}

.auth-copy {
  position: relative;
  z-index: 1;
  max-width: 680px;
  margin: 34px 0 0;
  color: rgba(255, 249, 239, 0.68);
  font-size: 15px;
  line-height: 1.95;
}

.story-points {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 34px;
}

.story-points span {
  padding: 8px 11px;
  color: rgba(255, 249, 239, 0.75);
  font-size: 11px;
  border: 1px solid rgba(255, 249, 239, 0.16);
}

.auth-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8vw;
  background: rgba(255, 253, 248, 0.8);
  backdrop-filter: blur(18px);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 30px;
  border-bottom: 1px solid var(--line);
}

.auth-tabs button {
  padding: 0 0 12px;
  color: var(--muted);
  font-family: var(--display);
  font-size: 19px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
}

.auth-tabs button.is-active {
  color: var(--jade);
  border-bottom-color: var(--jade);
}

form label,
.profile-grid label {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

form label + label {
  margin-top: 17px;
}

form label > span,
.profile-grid label > span {
  color: var(--muted);
  font-size: 11px;
}

input,
textarea {
  width: 100%;
  color: var(--ink);
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid var(--line);
  border-radius: 0;
  outline: 0;
  transition: border-color 150ms ease;
}

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

textarea {
  padding: 11px 12px;
  line-height: 1.65;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--jade);
}

.auth-card .button {
  margin-top: 26px;
}

.auth-note {
  margin: 12px 0 0;
  color: var(--muted-light);
  font-size: 10px;
  text-align: center;
}

.form-error {
  min-height: 18px;
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 11px;
  text-align: center;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 22px 18px;
  color: #f9f4e9;
  background:
    linear-gradient(rgba(31, 38, 33, 0.96), rgba(31, 38, 33, 0.99)),
    repeating-linear-gradient(
      0deg,
      transparent 0,
      transparent 17px,
      rgba(255, 255, 255, 0.025) 17px,
      rgba(255, 255, 255, 0.025) 18px
    );
}

.sidebar-brand {
  display: flex;
  gap: 11px;
  align-items: center;
  padding: 0 4px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand strong,
.sidebar-brand small {
  display: block;
}

.sidebar-brand strong {
  font-family: var(--display);
  font-size: 17px;
}

.sidebar-brand small {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.45);
  font-size: 9px;
  letter-spacing: 0.12em;
}

.credit-card {
  margin: 18px 0;
  padding: 15px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.credit-card span,
.credit-card strong {
  display: block;
}

.credit-card span {
  color: rgba(255, 255, 255, 0.48);
  font-size: 10px;
}

.credit-card strong {
  margin: 5px 0 11px;
  color: #f2c877;
  font-family: var(--display);
  font-size: 32px;
}

.credit-card button {
  padding: 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: 10px;
  background: transparent;
  border: 0;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px 8px;
  color: rgba(255, 255, 255, 0.42);
  font-size: 10px;
}

.sidebar-head button {
  color: #fff;
  font-size: 20px;
  background: transparent;
  border: 0;
}

.project-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: auto;
}

.project-item {
  width: 100%;
  padding: 11px 12px;
  color: rgba(255, 255, 255, 0.65);
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
}

.project-item strong,
.project-item small {
  display: block;
}

.project-item strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-item small {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.35);
  font-size: 9px;
}

.project-item.is-active {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.1);
}

.sidebar-user {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding: 17px 4px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-user strong,
.sidebar-user small {
  display: block;
  max-width: 145px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user strong {
  font-size: 11px;
}

.sidebar-user small {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.4);
  font-size: 9px;
}

.sidebar-user button {
  color: rgba(255, 255, 255, 0.55);
  font-size: 10px;
  background: transparent;
  border: 0;
}

.main {
  min-width: 0;
  padding: 0 32px 50px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 104px;
  border-bottom: 1px solid var(--line-dark);
}

.topbar h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 28px;
}

.saas-price-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 13px;
  align-items: center;
  padding: 10px 0;
  color: var(--muted);
  font-size: 9px;
  border-bottom: 1px solid var(--line);
}

.saas-price-strip > span {
  color: var(--gold);
  font-weight: 800;
  letter-spacing: 0.12em;
}

.saas-price-strip b {
  color: var(--jade);
  font-weight: 700;
}

.saas-price-strip em {
  color: var(--muted-light);
  font-style: normal;
}

.saas-cost {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  margin-left: 7px;
  padding: 0 6px;
  color: #fff8e8;
  font-size: 8px;
  font-style: normal;
  font-weight: 700;
  background: var(--vermilion);
  border-radius: 999px;
  vertical-align: middle;
}

.empty-project {
  display: grid;
  min-height: calc(100vh - 104px);
  place-items: center;
}

.empty-project > div {
  max-width: 520px;
  padding: 45px;
  text-align: center;
  background: rgba(255, 253, 248, 0.65);
  border: 1px dashed var(--line-dark);
}

.empty-project h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 30px;
}

.empty-project p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}

.project-content {
  display: grid;
  gap: 18px;
  padding-top: 22px;
}

.panel {
  padding: 24px;
  background: rgba(255, 253, 248, 0.7);
  border: 1px solid var(--line);
  box-shadow: 0 12px 32px rgba(55, 58, 53, 0.045);
}

.section-head {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 23px;
}

.save-state,
.muted {
  color: var(--muted-light);
  font-size: 10px;
}

.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.span-2 {
  grid-column: span 2;
}

.goal-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 17px;
}

.goal-button {
  padding: 13px 14px;
  text-align: left;
  background: rgba(255, 253, 248, 0.65);
  border: 1px solid var(--line);
}

.goal-button strong,
.goal-button small {
  display: block;
}

.goal-button strong {
  font-family: var(--display);
  font-size: 14px;
}

.goal-button small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

.goal-button.is-active {
  color: var(--jade);
  background: var(--jade-light);
  border-color: rgba(40, 95, 82, 0.45);
}

.profile-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.analysis-card {
  padding: 19px 22px;
  background:
    linear-gradient(90deg, rgba(40, 95, 82, 0.11), rgba(40, 95, 82, 0.035));
  border-left: 4px solid var(--jade);
}

.analysis-card span,
.analysis-card strong {
  display: block;
}

.analysis-card span {
  color: var(--jade);
  font-size: 10px;
}

.analysis-card strong {
  margin-top: 6px;
  font-family: var(--display);
  font-size: 18px;
}

.analysis-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.topic-modes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 13px;
}

.topic-modes button {
  padding: 13px 14px;
  text-align: left;
  background: rgba(255, 253, 248, 0.72);
  border: 1px solid var(--line);
}

.topic-modes button strong,
.topic-modes button small {
  display: block;
}

.topic-modes button strong {
  font-family: var(--display);
  font-size: 14px;
}

.topic-modes button small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

.topic-modes button.is-active {
  color: var(--jade);
  background: var(--jade-light);
  border-color: rgba(40, 95, 82, 0.45);
}

.topic-mode-panel {
  margin-bottom: 18px;
  padding: 16px;
  background: rgba(245, 240, 231, 0.62);
  border: 1px solid var(--line);
}

.topic-mode-panel > p {
  margin: 0 0 13px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.manual-topic-grid,
.reference-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.reference-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 13px;
}

.reference-list {
  display: grid;
  gap: 7px;
  margin-top: 15px;
}

.reference-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 11px 12px;
  background: rgba(255, 253, 248, 0.82);
  border: 1px solid var(--line);
}

.reference-row strong,
.reference-row small {
  display: block;
}

.reference-row strong {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-row small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
}

.reference-row button {
  color: var(--danger);
  font-size: 9px;
  background: transparent;
  border: 0;
}

.topic-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
}

.topic-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 230px;
  padding: 18px;
  background: rgba(255, 253, 248, 0.82);
  border: 1px solid var(--line);
  transition:
    transform 160ms ease,
    box-shadow 160ms ease;
}

.topic-card::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 48px;
  height: 3px;
  content: "";
  background: var(--gold);
}

.topic-card.is-high::before {
  background: var(--vermilion);
}

.topic-card:hover {
  box-shadow: 0 16px 35px rgba(39, 47, 41, 0.1);
  transform: translateY(-3px);
}

.topic-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.priority {
  color: var(--jade);
  font-size: 10px;
  font-weight: 800;
}

.topic-card.is-high .priority {
  color: var(--vermilion);
}

.topic-card h3 {
  margin: 16px 0 9px;
  font-family: var(--display);
  font-size: 18px;
  line-height: 1.45;
}

.topic-card p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.7;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.topic-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 13px;
}

.tag {
  padding: 5px 7px;
  color: var(--ink-soft);
  font-size: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
}

.tag.jade {
  color: var(--jade);
  background: var(--jade-light);
  border-color: rgba(40, 95, 82, 0.2);
}

.topic-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 15px;
}

.topic-card-foot span {
  color: var(--muted-light);
  font-size: 9px;
}

.topic-card-foot button {
  min-height: 31px;
  padding: 0 10px;
  color: #fff;
  font-size: 9px;
  background: var(--jade);
  border: 0;
}

.empty-inline {
  padding: 35px 20px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  border: 1px dashed var(--line);
}

.jobs-list {
  display: grid;
  gap: 8px;
}

.job-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 100px;
  gap: 16px;
  align-items: center;
  padding: 13px 14px;
  background: rgba(255, 253, 248, 0.72);
  border: 1px solid var(--line);
}

.job-row strong,
.job-row small {
  display: block;
}

.job-row strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-row small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
}

.job-progress {
  height: 7px;
  overflow: hidden;
  background: var(--paper-deep);
}

.job-progress i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--jade);
  transition: width 300ms ease;
}

.job-status {
  color: var(--jade);
  font-size: 10px;
  text-align: right;
}

.job-status.failed {
  color: var(--danger);
}

.modal-scrim,
.script-scrim {
  position: fixed;
  z-index: 50;
  display: grid;
  padding: 22px;
  background: rgba(26, 31, 28, 0.5);
  backdrop-filter: blur(5px);
  inset: 0;
  place-items: center;
}

.modal-card,
.script-card {
  width: min(600px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--paper-strong);
  box-shadow: var(--shadow);
}

.modal-card {
  padding: 24px;
}

.modal-card > header,
.script-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
}

.modal-card h2,
.script-card h2 {
  margin: 0;
  font-family: var(--display);
}

.script-card {
  width: min(900px, 100%);
}

.script-header {
  padding: 24px 26px 18px;
  border-bottom: 1px solid var(--line);
}

.script-body {
  padding: 24px 26px 28px;
}

.script-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 16px;
}

.script-meta span {
  padding: 5px 8px;
  color: var(--jade);
  font-size: 9px;
  background: var(--jade-light);
}

.script-opening,
.script-main,
.script-note {
  margin-top: 15px;
  padding: 15px;
  background: rgba(245, 240, 231, 0.65);
  border-left: 3px solid var(--line-dark);
}

.script-main {
  border-left-color: var(--jade);
}

.script-opening strong,
.script-main strong,
.script-note strong {
  color: var(--muted);
  font-size: 10px;
}

.script-opening p,
.script-main p,
.script-note p {
  margin: 7px 0 0;
  font-size: 13px;
  line-height: 1.9;
  white-space: pre-wrap;
}

.script-actions,
.script-revision-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 17px;
}

.script-revision {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.script-revision-head strong,
.script-revision-head span {
  display: block;
}

.script-revision-head span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.length-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-top: 12px;
}

.length-options button {
  padding: 10px;
  background: var(--paper);
  border: 1px solid var(--line);
}

.length-options button strong,
.length-options button small {
  display: block;
}

.length-options button small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 8px;
}

.length-options button.is-active {
  color: var(--jade);
  background: var(--jade-light);
  border-color: var(--jade);
}

.script-revision textarea {
  margin-top: 12px;
}

.ledger-card {
  width: min(720px, 100%);
}

.ledger-list {
  display: grid;
  gap: 6px;
}

.ledger-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px 90px;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
}

.ledger-row strong {
  font-size: 11px;
}

.ledger-row small {
  color: var(--muted);
  font-size: 9px;
}

.ledger-amount {
  color: var(--success);
  font-weight: 800;
  text-align: right;
}

.ledger-amount.negative {
  color: var(--danger);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 100;
  max-width: min(420px, calc(100vw - 48px));
  padding: 12px 15px;
  color: #fff;
  font-size: 12px;
  background: var(--ink);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

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

  .auth-story {
    min-height: 44vh;
    padding: 60px 34px;
  }

  .auth-card {
    padding: 48px 34px 70px;
  }

  .topic-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .project-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 180px;
  }

  .sidebar-user {
    margin-top: 18px;
  }

  .main {
    padding: 0 16px 40px;
  }

  .topbar {
    min-height: 88px;
  }

  .profile-grid,
  .goal-row,
  .topic-modes,
  .manual-topic-grid,
  .reference-form,
  .topic-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .profile-actions {
    flex-direction: column;
  }

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

  .job-status {
    text-align: left;
  }

  .length-options {
    grid-template-columns: 1fr;
  }
}
