:root {
  color-scheme: light;
  --ink: #17211d;
  --muted: #66736d;
  --paper: #f3f1ea;
  --panel: #ffffff;
  --line: #d9dfd8;
  --green: #1f7a4d;
  --deep: #173f32;
  --teal: #0b6c73;
  --gold: #c58b20;
  --red: #b94a48;
  --blue: #2f65b7;
  --shadow: 0 16px 40px rgba(28, 43, 37, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(31, 122, 77, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(197, 139, 32, 0.14), transparent 30%),
    var(--paper);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

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

h1,
h2,
h3,
p {
  margin: 0;
}

.phone-app {
  width: min(100%, 1120px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 14px 14px calc(92px + env(safe-area-inset-bottom));
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 10px 0 12px;
  background: rgba(243, 241, 234, 0.88);
  backdrop-filter: blur(18px);
}

.role-card,
.boss-card,
.wallet-card,
.cloud-panel,
.panel,
.section-head {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.role-card {
  display: grid;
  grid-template-columns: 58px 1fr 70px;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.avatar {
  display: grid;
  width: 54px;
  height: 54px;
  border: 3px solid var(--deep);
  border-radius: 8px;
  background: linear-gradient(145deg, #56b37e 0 45%, var(--green) 46% 100%);
  place-items: center;
}

.avatar span {
  width: 22px;
  height: 22px;
  border: 5px solid #fff8dc;
  border-top-color: transparent;
  border-left-color: transparent;
  transform: rotate(45deg);
}

.role-main h1 {
  margin: 3px 0;
  font-size: clamp(24px, 7vw, 38px);
  line-height: 1;
}

.role-main p:last-child {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.level-badge {
  display: grid;
  min-height: 62px;
  border-radius: 8px;
  background: var(--deep);
  color: #fff8dc;
  place-items: center;
}

.level-badge strong {
  font-size: 28px;
  line-height: 1;
}

.level-badge span,
.eyebrow,
.mini-label,
.metric-row span,
.empty-state span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.level-badge span {
  color: rgba(255, 248, 220, 0.72);
  font-size: 10px;
}

.xp-track {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.cloud-panel {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding: 12px;
}

.cloud-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cloud-status strong {
  display: block;
  margin: 2px 0 4px;
  font-size: 16px;
}

.cloud-status span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.auth-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 8px;
}

.auth-form input {
  min-width: 0;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.auth-form button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--deep);
  border-radius: 8px;
  background: var(--deep);
  color: #fff8dc;
  font-weight: 900;
}

.hidden {
  display: none !important;
}

.app-locked {
  display: grid;
  min-height: 100vh;
  align-items: start;
}

.app-locked .phone-app {
  width: min(100%, 760px);
  padding-top: max(32px, 9vh);
}

.app-locked .app-header {
  position: static;
  padding: 0;
  background: transparent;
  backdrop-filter: none;
}

.app-locked .role-card {
  grid-template-columns: 58px 1fr;
}

.app-locked .level-badge,
.app-locked .xp-track,
.app-locked .screen,
.app-locked .bottom-nav {
  display: none;
}

.app-locked .cloud-panel {
  margin-top: 12px;
}

.progress-bar,
.project-track {
  overflow: hidden;
  height: 12px;
  margin-top: 6px;
  border-radius: 999px;
  background: #e5ebe3;
}

.progress-bar i,
.project-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--gold));
  transition: width 0.25s ease;
}

.screen {
  display: none;
  gap: 14px;
}

.screen.active {
  display: grid;
}

.boss-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 18px;
  background:
    linear-gradient(120deg, rgba(23, 63, 50, 0.96), rgba(11, 108, 115, 0.9)),
    var(--deep);
  color: #fff8dc;
}

.boss-card .eyebrow,
.boss-card p {
  color: rgba(255, 248, 220, 0.76);
}

.boss-card h2 {
  margin: 6px 0 8px;
  font-size: clamp(24px, 7vw, 42px);
  line-height: 1.08;
}

.boss-meter {
  display: grid;
  gap: 8px;
  justify-items: center;
  color: #fff8dc;
  font-weight: 900;
}

.boss-ring {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: conic-gradient(var(--gold) 0deg, rgba(255, 255, 255, 0.18) 0deg);
  box-shadow: inset 0 0 0 12px rgba(23, 63, 50, 0.82);
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.metric-row div {
  min-height: 76px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.metric-row strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.panel,
.section-head,
.wallet-card {
  padding: 16px;
}

.panel-title,
.section-head,
.wallet-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-title {
  margin-bottom: 12px;
}

.primary-btn,
.ghost-btn,
.capture-form button,
.inline-form button,
.import-btn,
.step-btn,
.delete-btn {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
}

.primary-btn,
.capture-form button,
.inline-form button {
  padding: 0 14px;
  border-color: var(--deep);
  background: var(--deep);
  color: #fff8dc;
}

.ghost-btn,
.import-btn {
  padding: 0 10px;
  color: var(--muted);
}

.daily-grid,
.quest-list,
.habit-grid,
.project-list,
.reward-grid,
.resource-list,
.snapshot-list,
.capture-list,
.attribute-list,
.review-stack {
  display: grid;
  gap: 10px;
}

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

.daily-card,
.quest-card,
.habit-card,
.project-card,
.reward-card,
.resource-item,
.snapshot-item,
.capture-item,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.daily-card {
  display: grid;
  min-height: 126px;
  padding: 12px;
  align-content: space-between;
  gap: 12px;
}

.daily-card h3,
.habit-card h3,
.project-card h3,
.reward-card h3 {
  margin-bottom: 7px;
  font-size: 16px;
}

.daily-card.done {
  border-color: rgba(31, 122, 77, 0.42);
  background: #f3faf5;
}

.quest-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.quest-card.done {
  opacity: 0.68;
}

.capture-form,
.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.capture-form {
  margin-bottom: 12px;
}

.capture-form input,
.inline-form input,
.capture-form select,
.inline-form select,
textarea {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.capture-form input,
.inline-form input {
  min-width: min(100%, 260px);
  flex: 1;
  padding: 0 12px;
}

.capture-form select,
.inline-form select {
  padding: 0 10px;
}

.capture-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
}

.resource-item,
.snapshot-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
}

.resource-item p,
.snapshot-item p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.snapshot-item {
  grid-template-columns: 1fr;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #edf5ef;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.tag.high {
  background: #f8ece9;
  color: var(--red);
}

.tag.normal {
  background: #edf2f8;
  color: var(--blue);
}

.tag.low {
  background: #f6f0df;
  color: var(--gold);
}

.project-card,
.habit-card,
.reward-card {
  padding: 14px;
}

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

.project-meta {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}

.project-track i {
  background: linear-gradient(90deg, var(--blue), var(--teal));
}

.project-actions,
.habit-actions,
.reward-actions,
.data-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
}

.step-btn,
.delete-btn {
  min-width: 36px;
  padding: 0 10px;
  color: var(--muted);
}

.habit-grid,
.reward-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.chain {
  display: flex;
  gap: 5px;
  margin: 13px 0;
}

.chain i {
  width: 100%;
  height: 11px;
  border-radius: 999px;
  background: #e5ebe3;
}

.chain i.lit {
  background: var(--gold);
}

.wallet-card {
  align-items: center;
}

.wallet-card strong {
  display: grid;
  min-width: 76px;
  min-height: 76px;
  border-radius: 8px;
  background: var(--gold);
  color: #fff8dc;
  font-size: 32px;
  place-items: center;
}

.attribute {
  display: grid;
  grid-template-columns: 74px 1fr 36px;
  gap: 10px;
  align-items: center;
}

.attribute meter {
  width: 100%;
  height: 12px;
}

.review-stack label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

textarea {
  width: 100%;
  min-height: 112px;
  padding: 12px;
  resize: vertical;
}

.import-btn {
  display: grid;
  place-items: center;
}

.import-btn input {
  display: none;
}

.empty-state {
  display: grid;
  min-height: 120px;
  padding: 20px;
  place-content: center;
  text-align: center;
}

.bottom-nav {
  position: fixed;
  right: 14px;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 14px;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  width: min(1092px, calc(100% - 28px));
  margin: 0 auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 16px 42px rgba(28, 43, 37, 0.2);
  backdrop-filter: blur(18px);
}

.nav-btn {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.nav-btn.active {
  background: var(--deep);
  color: #fff8dc;
}

@media (max-width: 820px) {
  .phone-app {
    padding: 10px 10px calc(86px + env(safe-area-inset-bottom));
  }

  .role-card {
    grid-template-columns: 50px 1fr 60px;
  }

  .avatar {
    width: 48px;
    height: 48px;
  }

  .metric-row,
  .daily-grid,
  .project-list,
  .habit-grid,
  .reward-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .boss-card,
  .wallet-card,
  .cloud-status,
  .section-head,
  .panel-title {
    align-items: stretch;
    flex-direction: column;
  }

  .bottom-nav {
    right: 10px;
    left: 10px;
    width: calc(100% - 20px);
  }
}

@media (max-width: 520px) {
  .metric-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .metric-row div {
    min-height: 64px;
    padding: 8px;
  }

  .metric-row strong {
    font-size: 19px;
  }

  .daily-grid,
  .project-list,
  .habit-grid,
  .reward-grid {
    grid-template-columns: 1fr;
  }

  .capture-form input,
  .capture-form select,
  .capture-form button,
  .auth-form input,
  .auth-form button,
  .inline-form input,
  .inline-form select,
  .inline-form button {
    width: 100%;
  }

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

  .bottom-nav {
    gap: 4px;
    padding: 6px;
  }

  .nav-btn {
    min-height: 42px;
    font-size: 13px;
  }
}
