/* ===================== Design tokens ===================== */
:root {
  --bg: #0d2818;
  --bg-elevated: #15391f;
  --card: #ffffff;
  --text: #1a2e22;
  --text-muted: #5d7268;
  --accent: #c0392b;
  --accent-dark: #962d22;
  --accent-soft: #fbeaea;
  --green: #1e6b3c;
  --green-soft: #e6f4ea;
  --gold: #d4a017;
  --border: #e3e8e4;
  --radius: 14px;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.08);
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 20% 10%, rgba(212, 160, 23, 0.08), transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(192, 57, 43, 0.08), transparent 40%);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ===================== Screens (passcode / whoami) ===================== */
.screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.card h1 {
  margin: 0 0 6px;
  font-size: 1.5rem;
}

.subtitle {
  color: var(--text-muted);
  margin: 0 0 22px;
  font-size: 0.95rem;
}

input, select, textarea {
  width: 100%;
  font-size: 1rem;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  margin-bottom: 12px;
  font-family: inherit;
  background: #fafbfa;
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green);
  background: #fff;
}

textarea {
  resize: vertical;
  min-height: 60px;
}

button {
  width: 100%;
  font-size: 1rem;
  font-weight: 600;
  padding: 13px 14px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  transition: transform 0.06s ease, background 0.15s ease;
}

button:hover { background: var(--accent-dark); }
button:active { transform: scale(0.98); }

.error {
  color: var(--accent);
  font-size: 0.9rem;
  margin-top: 4px;
}

.add-person {
  margin-top: 20px;
  text-align: left;
}

.add-person summary {
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  text-align: center;
  margin-bottom: 12px;
}

.add-person form {
  display: flex;
  gap: 8px;
}

.add-person input { margin-bottom: 0; }
.add-person button { width: auto; white-space: nowrap; }

/* ===================== Main app shell ===================== */
#screen-app {
  display: block;
  min-height: 100vh;
  padding: 0;
}

.app-header {
  background: var(--bg-elevated);
  color: white;
  padding: 16px 18px;
  padding-top: max(16px, env(safe-area-inset-top));
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}

.greeting { font-size: 0.95rem; }
.greeting strong { color: var(--gold); }

.link-btn {
  width: auto;
  background: transparent;
  color: #cfe8d8;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 6px 10px;
  text-decoration: underline;
}
.link-btn:hover { background: rgba(255,255,255,0.08); }

.tabs {
  display: flex;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 9;
}

.tab-btn {
  flex: 1;
  background: transparent;
  color: var(--text-muted);
  border-radius: 0;
  font-weight: 600;
  padding: 14px 10px;
  border-bottom: 3px solid transparent;
}

.tab-btn.active {
  color: var(--green);
  border-bottom-color: var(--green);
}

main {
  padding: 16px;
  max-width: 640px;
  margin: 0 auto;
  padding-bottom: 60px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===================== Add item form ===================== */
.add-item-form {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}

.add-item-form input, .add-item-form textarea { margin-bottom: 10px; }
.add-item-form button { background: var(--green); }
.add-item-form button:hover { background: #154f2c; }

/* ===================== Item cards ===================== */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-card {
  background: var(--card);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.item-info { flex: 1; min-width: 0; }

.item-title {
  font-weight: 600;
  font-size: 1.02rem;
  margin: 0 0 2px;
  word-break: break-word;
}

.item-title a {
  color: var(--text);
  text-decoration: none;
}
.item-title a:hover { color: var(--green); text-decoration: underline; }

.item-notes {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 4px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.item-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.item-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.btn-small {
  width: auto;
  font-size: 0.85rem;
  padding: 8px 12px;
  white-space: nowrap;
}

.btn-claim { background: var(--green); }
.btn-claim:hover { background: #154f2c; }

.btn-claimed-by-me { background: var(--gold); color: #3a2c00; }
.btn-claimed-by-me:hover { background: #b88a13; }

.btn-delete {
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
  padding: 4px 6px;
  font-size: 0.8rem;
}
.btn-delete:hover { background: var(--accent-soft); }

.badge-claimed-other {
  background: var(--border);
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 5px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

/* ===================== Everyone-else grouping ===================== */
.person-group {
  margin-bottom: 22px;
}

.person-group-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 8px 2px;
  color: #e8f0ea;
  background: var(--bg-elevated);
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
}

.empty-msg {
  text-align: center;
  color: var(--text-muted);
  margin-top: 30px;
  font-size: 0.95rem;
}

/* ===================== Toast ===================== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a2e22;
  color: white;
  padding: 12px 20px;
  border-radius: 30px;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  z-index: 100;
  max-width: 90%;
  text-align: center;
}

.toast.error { background: var(--accent-dark); }

@media (min-width: 700px) {
  main { padding: 24px; }
}
