:root {
  color-scheme: light;
  --bg: #f7f3ed;
  --panel: #ffffff;
  --ink: #211f1d;
  --muted: #706a63;
  --line: #ded6cb;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --danger: #b42318;
  --warn: #a16207;
  --ok: #15803d;
  --shadow: 0 12px 32px rgba(39, 32, 25, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 12px 12px calc(188px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: -12px -12px 12px;
  padding: calc(12px + env(safe-area-inset-top)) 12px 12px;
  background: rgba(247, 243, 237, 0.94);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}

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

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: 0;
}

.subtitle {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
}

.status.active {
  border-color: rgba(21, 128, 61, 0.28);
  color: var(--ok);
}

.progress {
  margin-top: 12px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.progress-track {
  overflow: hidden;
  height: 8px;
  margin-top: 6px;
  border-radius: 999px;
  background: #e9e1d8;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 160ms ease;
}

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

.metric {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.items {
  display: grid;
  gap: 10px;
}

.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 2px 10px rgba(39, 32, 25, 0.04);
}

.item-mine {
  border-color: rgba(15, 118, 110, 0.45);
  box-shadow: 0 8px 24px rgba(15, 118, 110, 0.08);
}

.item-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px;
}

.item-name {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.item-meta {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.item-state {
  text-align: right;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.item-state strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
  font-size: 14px;
}

.controls {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 8px;
  padding: 0 12px 12px;
}

.participants-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 12px;
  color: var(--muted);
  font-size: 13px;
}

.participants-select {
  min-width: 72px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.icon-button,
.split-button,
.action-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #faf8f5;
  color: var(--ink);
}

.icon-button {
  font-size: 24px;
  line-height: 1;
}

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

.icon-button:disabled,
.split-button:disabled,
.action-button:disabled {
  opacity: 0.42;
}

.my-count {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  font-size: 13px;
}

.assignments {
  border-top: 1px solid var(--line);
  padding: 8px 12px 12px;
  color: var(--muted);
  font-size: 12px;
}

.assignment {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 5px;
}

.split-button {
  margin: 0 12px 12px;
  width: calc(100% - 24px);
  color: var(--accent-strong);
}

.bottom-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.my-total {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.my-total span {
  color: var(--muted);
  font-size: 12px;
}

.my-total strong {
  display: block;
  margin-top: 2px;
  font-size: 20px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.actions-single {
  grid-template-columns: 1fr;
}

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

.action-button.danger {
  color: var(--danger);
}

.action-button.secondary {
  color: var(--ink);
}

.state {
  min-height: 72vh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  text-align: center;
  color: var(--muted);
}

.state h2 {
  margin: 0;
  color: var(--ink);
  font-size: 20px;
}

.state p {
  max-width: 320px;
  margin: 0;
}

.loader {
  width: 32px;
  height: 32px;
  border: 3px solid #d8cec2;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (min-width: 720px) {
  .app-shell {
    max-width: 760px;
    margin: 0 auto;
    padding-bottom: calc(156px + env(safe-area-inset-bottom));
  }

  .topbar {
    margin-left: 0;
    margin-right: 0;
    border: 1px solid var(--line);
    border-top: 0;
    border-radius: 0 0 8px 8px;
  }

  .bottom-sheet {
    left: 50%;
    right: auto;
    width: min(760px, 100vw);
    transform: translateX(-50%);
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
  }
}

@media (max-width: 420px) {
  .app-shell {
    padding-bottom: calc(204px + env(safe-area-inset-bottom));
  }

  .bottom-sheet {
    padding-top: 8px;
  }

  .my-total strong {
    font-size: 18px;
  }

}
