/* ── Apple iOS Settings Style ── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #F2F2F7;
  --card:      #FFFFFF;
  --separator: #E5E5EA;
  --text:      #000000;
  --secondary: #8E8E93;
  --tertiary:  #C7C7CC;
  --blue:      #007AFF;
  --green:     #34C759;
  --red:       #FF3B30;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 430px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

.status-bar {
  height: env(safe-area-inset-top, 0px);
}

/* ── Header ── */

.header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 12px 0 8px;
}

.title {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.manage-link {
  font-size: 15px;
  font-weight: 500;
  color: var(--blue);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
}

.manage-link.dimmed {
  color: var(--secondary);
}

/* ── Toast ── */

.toast {
  background: var(--card);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 16px;
  transition: opacity 0.3s;
}
.toast.error {
  color: var(--red);
}

/* ── Grouped Section Header ── */

.section-header {
  font-size: 13px;
  font-weight: 400;
  color: var(--secondary);
  text-transform: uppercase;
  letter-spacing: 0.2px;
  padding: 20px 16px 6px;
}

.section-header:first-of-type {
  padding-top: 8px;
}

/* ── Grouped Table Card ── */

.group {
  background: var(--card);
  border-radius: 10px;
  overflow: hidden;
}

/* ── Table Row ── */

.row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  min-height: 44px;
  background: var(--card);
  position: relative;
}

.row + .row {
  border-top: 0.5px solid var(--separator);
  margin: 0;
}

/* Inset separator for non-checkbox rows */
.row + .row::before {
  display: none;
}
@supports (border-top: 0.5px solid var(--separator)) {
  .row + .row {
    margin-left: 0;
  }
}

/* ── Circle checkbox (iOS style) ── */

.circle {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--tertiary);
  background: transparent;
  cursor: pointer;
  padding: 0;
}
.circle.checked {
  border-color: var(--green);
  background: var(--green);
  position: relative;
}
.circle.checked::after {
  content: '';
  position: absolute;
  inset: 3px;
  background: white;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M13.3 4.3L6 11.6L2.7 8.3l1.4-1.4L6 8.8l5.9-5.9z' fill='black'/%3E%3C/svg%3E") center/contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M13.3 4.3L6 11.6L2.7 8.3l1.4-1.4L6 8.8l5.9-5.9z' fill='black'/%3E%3C/svg%3E") center/contain no-repeat;
}

/* ── Row content ── */

.row-body {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.row-label {
  font-size: 17px;
  line-height: 1.3;
}

.row-label.struck {
  text-decoration: line-through;
  color: var(--tertiary);
}

.row-qty {
  font-size: 17px;
  font-weight: 400;
  color: var(--secondary);
}

.row-by {
  font-size: 15px;
  color: var(--tertiary);
  margin-left: auto;
}

/* Row actions (manage mode) */
.row-actions {
  display: flex;
  gap: 14px;
  flex-shrink: 0;
}

.act {
  font-size: 15px;
  color: var(--blue);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 400;
  padding: 2px 0;
}

.act.danger {
  color: var(--red);
}

/* Completed rows */
.row.done {
  opacity: 0.45;
}

/* ── Empty state ── */

.empty {
  color: var(--secondary);
  font-size: 15px;
  text-align: center;
  padding: 32px 0;
}

/* ── Footer row (clear) ── */

.footer-row {
  text-align: center;
  padding: 12px;
}

.clear-btn {
  border: none;
  background: none;
  color: var(--red);
  font-size: 17px;
  cursor: pointer;
  padding: 0;
  font-weight: 400;
}

/* ── Add Bar ── */

.add-bar {
  margin-bottom: 4px;
}

.add-card {
  background: var(--card);
  border-radius: 10px;
  padding: 4px 6px;
}

.add-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.add-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 17px;
  padding: 10px 10px;
  outline: none;
  color: var(--text);
  min-width: 0;
}

.add-input::placeholder {
  color: var(--tertiary);
}

/* Stepper */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  border-radius: 8px;
  flex-shrink: 0;
  overflow: hidden;
}

.stepper button {
  width: 36px;
  height: 36px;
  border: none;
  background: #E5E5EA;
  font-size: 18px;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stepper button:first-child {
  border-radius: 8px 0 0 8px;
}

.stepper button:last-child {
  border-radius: 0 8px 8px 0;
}

.stepper button:active {
  background: #D1D1D6;
}

.stepper span {
  font-size: 17px;
  font-weight: 400;
  min-width: 28px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  background: #E5E5EA;
  padding: 0 4px;
  height: 36px;
  line-height: 36px;
}

/* Add button */
.add-btn {
  flex-shrink: 0;
  border: none;
  border-radius: 8px;
  background: var(--blue);
  color: white;
  font-size: 15px;
  font-weight: 600;
  padding: 10px 16px;
  cursor: pointer;
}

.add-btn:active {
  opacity: 0.7;
}

/* Who bar (inside add card, separated) */
.who-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-top: 0.5px solid var(--separator);
  margin-top: 4px;
}

.who-chip {
  border: none;
  border-radius: 16px;
  background: #E5E5EA;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  padding: 6px 14px;
  cursor: pointer;
  flex-shrink: 0;
}

.who-chip.active {
  background: var(--blue);
  color: white;
}

.who-other {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  padding: 6px 4px;
  outline: none;
  color: var(--text);
  min-width: 0;
}

.who-other::placeholder {
  color: var(--tertiary);
}

/* ── Completed collapsible ── */

.toggle-row {
  cursor: pointer;
  user-select: none;
}

.toggle-row .chevron {
  font-size: 18px;
  color: var(--secondary);
  transition: transform 0.2s;
  flex-shrink: 0;
  margin-left: auto;
}

.toggle-row.open .chevron {
  transform: rotate(90deg);
}

.collapsed {
  display: none;
}

.collapsed.open {
  display: block;
}

/* ── Login / Edit (shared) ── */

.card-page {
  max-width: 360px;
  margin: 80px auto 0;
  padding: 0 16px;
}

.card-page h1 {
  font-size: 34px;
  font-weight: 700;
  margin-bottom: 4px;
}

.card-page .sub {
  color: var(--secondary);
  font-size: 15px;
  margin-bottom: 24px;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-stack label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--secondary);
  font-weight: 500;
}

.form-stack input {
  border: none;
  border-radius: 10px;
  background: var(--card);
  padding: 12px 14px;
  font-size: 17px;
  outline: none;
  color: var(--text);
}

.primary-btn {
  border: none;
  border-radius: 10px;
  background: var(--blue);
  color: white;
  font-size: 17px;
  font-weight: 600;
  padding: 14px;
  cursor: pointer;
  text-align: center;
}

.primary-btn:active {
  opacity: 0.7;
}

.secondary-link {
  color: var(--blue);
  text-decoration: none;
  font-size: 15px;
  font-weight: 400;
}

.split-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.split-actions .primary-btn {
  flex: 1;
}

.inline-form {
  display: inline;
}
