:root {
  --ink: #17211f;
  --muted: #66736f;
  --paper: #fbfaf7;
  --panel: #ffffff;
  --line: #dfe5df;
  --teal: #087f72;
  --teal-dark: #055e55;
  --coral: #e35d4f;
  --gold: #c48a18;
  --mint: #d9f4e8;
  --peach: #ffe4dc;
  --shadow: 0 18px 46px rgba(23, 33, 31, 0.11);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-width: 320px;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(8, 127, 114, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(227, 93, 79, 0.1), transparent 28%),
    var(--paper);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

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

button:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
  color: var(--ink);
  outline: 0;
}

input {
  min-height: 46px;
  padding: 0 0.9rem;
}

textarea {
  min-height: 128px;
  padding: 0.85rem 0.9rem;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 127, 114, 0.14);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 2rem);
  background: rgba(251, 250, 247, 0.9);
  border-bottom: 1px solid rgba(23, 33, 31, 0.08);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 0.88rem;
  letter-spacing: 0;
}

.main-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-width: 0;
}

.main-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border-radius: 8px;
  padding: 0 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.main-nav a:hover,
.main-nav a.is-active {
  background: #edf4ee;
  color: var(--teal-dark);
}

.wallet-area {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  min-width: 0;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0 1rem;
}

.primary-button {
  background: var(--teal);
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(8, 127, 114, 0.2);
}

.primary-button:hover:not(:disabled) {
  background: var(--teal-dark);
}

.secondary-button {
  background: var(--ink);
  color: #ffffff;
}

.icon-button {
  display: grid;
  width: 44px;
  padding: 0;
  place-items: center;
  background: #eff4ef;
  color: var(--ink);
  font-size: 1.2rem;
}

.wide-button {
  width: 100%;
}

.status-badge,
.campaign-state {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 999px;
  padding: 0 0.75rem;
  background: #edf1ed;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-badge.ready,
.campaign-state.active {
  background: var(--mint);
  color: var(--teal-dark);
}

.status-badge.warning {
  background: var(--peach);
  color: #a23d31;
}

.campaign-state.success {
  background: #edf6d7;
  color: #4f7100;
}

.campaign-state.warning {
  background: var(--peach);
  color: #a23d31;
}

.campaign-state.neutral {
  background: #e9e7df;
  color: #5f5a51;
}

main {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.page-heading {
  max-width: 760px;
  margin: 2rem 0 1.2rem;
}

.page-heading h1,
.page-heading-row h1 {
  margin: 0;
  font-size: clamp(2.2rem, 6vw, 4.2rem);
  line-height: 0.98;
}

.page-heading p:last-child {
  margin: 0.85rem 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

.page-heading-row {
  margin: 2rem 0 1rem;
}

.hero-band {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  gap: clamp(1rem, 4vw, 2rem);
  min-height: 330px;
  align-items: stretch;
  padding: clamp(1.2rem, 4vw, 2rem) 0;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 760px;
}

.eyebrow {
  margin: 0 0 0.55rem;
  color: var(--teal-dark);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  max-width: 820px;
  margin: 0;
  font-size: clamp(2.45rem, 5.4vw, 5.5rem);
  line-height: 0.94;
  letter-spacing: 0;
}

.hero-copy > p:last-child {
  max-width: 620px;
  margin: 1.1rem 0 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.4rem;
}

.hero-actions .primary-button,
.hero-actions .secondary-button {
  min-width: 160px;
}

.impact-panel {
  position: relative;
  display: grid;
  min-height: 300px;
  overflow: hidden;
  place-items: center;
  border: 1px solid rgba(23, 33, 31, 0.1);
  border-radius: 8px;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.88), rgba(217, 244, 232, 0.78)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='460' height='320' viewBox='0 0 460 320'%3E%3Crect width='460' height='320' fill='%23f8faf4'/%3E%3Cg fill='none' stroke='%23087f72' stroke-opacity='.22' stroke-width='3'%3E%3Cpath d='M40 252c56-64 122-90 198-78 63 10 109-3 138-39 18-22 32-49 42-81'/%3E%3Cpath d='M25 90c51 36 102 52 153 47 79-8 128-46 216-26'/%3E%3C/g%3E%3Cg fill='%23e35d4f' fill-opacity='.25'%3E%3Ccircle cx='89' cy='229' r='18'/%3E%3Ccircle cx='311' cy='122' r='22'/%3E%3Ccircle cx='385' cy='73' r='13'/%3E%3C/g%3E%3Cg fill='%23087f72' fill-opacity='.2'%3E%3Crect x='63' y='120' width='54' height='54' rx='8'/%3E%3Crect x='177' y='204' width='64' height='64' rx='8'/%3E%3Crect x='286' y='216' width='82' height='82' rx='8'/%3E%3C/g%3E%3C/svg%3E") center/cover;
  box-shadow: var(--shadow);
}

.impact-rings {
  position: absolute;
  inset: 12%;
}

.impact-rings span {
  position: absolute;
  border: 1px solid rgba(8, 127, 114, 0.24);
  border-radius: 50%;
}

.impact-rings span:nth-child(1) {
  inset: 0;
}

.impact-rings span:nth-child(2) {
  inset: 18%;
}

.impact-rings span:nth-child(3) {
  inset: 36%;
}

.impact-stat {
  position: relative;
  display: grid;
  gap: 0.35rem;
  min-width: min(280px, 80%);
  padding: 1.35rem;
  border: 1px solid rgba(23, 33, 31, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  text-align: center;
}

.impact-stat strong {
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1;
}

.impact-stat span {
  color: var(--muted);
  font-weight: 700;
}

.notice-row,
.setup-panel,
.create-panel,
.campaign-panel,
.page-panel,
.search-bar,
.info-grid article,
.activity-item {
  border: 1px solid rgba(23, 33, 31, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 10px 30px rgba(23, 33, 31, 0.06);
}

.notice-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
}

.notice-row > div {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

#contractStatus.ready {
  color: var(--teal-dark);
}

#message {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
  text-align: right;
}

#message.success {
  color: var(--teal-dark);
}

#message.warning {
  color: var(--gold);
}

#message.error {
  color: var(--coral);
}

.setup-panel {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 1rem;
  align-items: end;
  margin-top: 1rem;
  padding: 1rem;
}

.setup-panel h2,
.section-heading h2 {
  margin: 0;
  font-size: 1.15rem;
}

.contract-form {
  display: grid;
  gap: 0.45rem;
}

label {
  display: grid;
  gap: 0.45rem;
  color: #41504c;
  font-size: 0.9rem;
  font-weight: 700;
}

.inline-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.6rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.stats-grid article {
  display: grid;
  gap: 0.35rem;
  min-height: 108px;
  padding: 1rem;
  border: 1px solid rgba(23, 33, 31, 0.1);
  border-radius: 8px;
  background: #ffffff;
}

.stats-grid span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.stats-grid strong {
  align-self: end;
  font-size: clamp(1.45rem, 3vw, 2.15rem);
  overflow-wrap: anywhere;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.info-grid article {
  display: grid;
  gap: 0.6rem;
  min-height: 190px;
  padding: 1rem;
}

.info-grid span {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  font-weight: 800;
}

.info-grid h2 {
  margin: 0;
  font-size: 1.1rem;
}

.info-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 0.86fr) minmax(0, 1.3fr);
  gap: 1rem;
  align-items: start;
}

.create-panel,
.campaign-panel {
  padding: 1rem;
}

.page-panel {
  max-width: 820px;
  padding: 1rem;
}

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

.stacked-form {
  display: grid;
  gap: 1rem;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.search-bar {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 1rem;
  padding: 1rem;
}

.campaign-list {
  display: grid;
  gap: 1rem;
}

.campaign-card {
  display: grid;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
}

.campaign-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.campaign-id {
  display: inline-block;
  margin-bottom: 0.25rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.campaign-card h3 {
  margin: 0;
  font-size: 1.32rem;
}

.campaign-description {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.campaign-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
  margin: 0;
}

.campaign-facts div {
  min-width: 0;
  padding: 0.65rem;
  border-radius: 8px;
  background: #f3f5ef;
}

.campaign-facts dt {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.campaign-facts dd {
  margin: 0.25rem 0 0;
  font-size: 0.92rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.progress-wrap {
  display: grid;
  gap: 0.5rem;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.progress-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6ece6;
}

.progress-completed {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--coral));
}

.owner-line {
  margin: 0;
  color: var(--muted);
  font-size: 0.87rem;
  font-weight: 700;
}

.donate-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: end;
}

.owner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.empty-state {
  display: grid;
  min-height: 230px;
  place-content: center;
  gap: 0.5rem;
  padding: 1.5rem;
  border: 1px dashed #cfd8cf;
  border-radius: 8px;
  background: #fbfcf8;
  color: var(--muted);
  text-align: center;
}

.empty-state h3 {
  margin: 0;
  color: var(--ink);
}

.empty-state h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1.1rem;
}

.empty-state p {
  max-width: 380px;
  margin: 0 auto;
  line-height: 1.5;
}

.activity-stats {
  margin-top: 1rem;
}

.activity-feed {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.activity-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
}

.activity-item h2 {
  margin: 0;
  font-size: 1rem;
}

.activity-item p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.activity-detail {
  display: grid;
  gap: 0.25rem;
  min-width: 140px;
  text-align: right;
}

.activity-detail strong {
  font-size: 1rem;
}

.activity-detail span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.toast {
  position: fixed;
  top: 5.5rem;
  right: 1.25rem;
  z-index: 50;
  display: grid;
  gap: 0.25rem;
  width: min(380px, calc(100vw - 2rem));
  padding: 1rem;
  border: 1px solid rgba(23, 33, 31, 0.1);
  border-left: 5px solid var(--coral);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

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

.toast.warning {
  border-left-color: var(--gold);
}

.toast strong {
  color: var(--ink);
  font-size: 0.95rem;
}

.toast p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

@media (max-width: 980px) {
  .hero-band,
  .workspace,
  .setup-panel {
    grid-template-columns: 1fr;
  }

  .topbar {
    grid-template-columns: 1fr auto;
  }

  .main-nav {
    grid-column: 1 / -1;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 0.1rem;
  }

  .impact-panel {
    min-height: 240px;
  }

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

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

@media (max-width: 660px) {
  .topbar,
  .notice-row,
  .campaign-card-header,
  .progress-label {
    align-items: stretch;
    flex-direction: column;
  }

  .wallet-area,
  .notice-row > div {
    justify-content: flex-start;
  }

  .wallet-area,
  .inline-control,
  .field-grid,
  .donate-form,
  .stats-grid,
  .campaign-facts,
  .info-grid {
    grid-template-columns: 1fr;
  }

  .wallet-area {
    display: grid;
    width: 100%;
  }

  #message {
    text-align: left;
  }

  .toast {
    top: auto;
    right: 1rem;
    bottom: 1rem;
    left: 1rem;
    width: auto;
  }

  .activity-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .activity-detail {
    min-width: 0;
    text-align: left;
  }

  h1 {
    font-size: clamp(2.2rem, 15vw, 3.9rem);
  }

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