/* Same look as Bar Back Pro: iOS system colours and grouped lists, with a berry accent. */
:root {
  --bg: #f6f1f4;
  --card: #ffffff;                     /* secondarySystemGroupedBackground */
  --card-2: #f2f2f7;                   /* tertiarySystemGroupedBackground (column header) */
  --text: #000000;
  --muted: #6c6c70;                    /* secondary label */
  --faint: #aeaeb2;                    /* tertiary label */
  --line: #c6c6c8;                     /* separator */
  --fill: rgba(118, 118, 128, 0.12);   /* tertiarySystemFill */
  --accent: #b0306e;
  --accent-soft: rgba(176, 48, 110, 0.12);
  --accent-ink: #ffffff;
  --danger: #ff3b30;
  --danger-soft: rgba(255, 59, 48, 0.12);
  --ok: #34c759;
  --got: #2fa84f;
  --warn: #ff9500;
  --bar: rgba(249, 249, 249, 0.94);
  --seg-on: #ffffff;                   /* selected segment */
  --radius: 10px;
  --gutter: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --card: #1c1c1e;
    --card-2: #2c2c2e;
    --text: #ffffff;
    --muted: #8e8e93;
    --faint: #48484a;
    --line: #38383a;
    --fill: rgba(118, 118, 128, 0.24);
    --accent: #f27bb3;
    --accent-soft: rgba(242, 123, 179, 0.18);
    --accent-ink: #000000;
    --danger: #ff453a;
    --danger-soft: rgba(255, 69, 58, 0.16);
    --ok: #30d158;
    --got: #28a745;
    --warn: #ff9f0a;
    --bar: rgba(28, 28, 30, 0.94);
    --seg-on: #636366;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #000000;
  --card: #1c1c1e;
  --card-2: #2c2c2e;
  --text: #ffffff;
  --muted: #8e8e93;
  --faint: #48484a;
  --line: #38383a;
  --fill: rgba(118, 118, 128, 0.24);
  --accent: #f27bb3;
  --accent-soft: rgba(242, 123, 179, 0.18);
  --accent-ink: #000000;
  --danger: #ff453a;
  --danger-soft: rgba(255, 69, 58, 0.16);
  --ok: #30d158;
    --got: #28a745;
  --warn: #ff9f0a;
  --bar: rgba(28, 28, 30, 0.94);
  --seg-on: #636366;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  /* Stops the double-tap-to-zoom delay and zoom on quick repeat taps. Pinch-zoom still works. */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
body { min-height: 100vh; min-height: 100dvh; }

h1, h2, h3, p { margin: 0; }
h2 { font-size: 17px; font-weight: 600; }
ol, ul { margin: 0; padding-left: 1.3em; }
.app { min-height: 100vh; min-height: 100dvh; }

.screen {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 8px) 0 calc(env(safe-area-inset-bottom) + 32px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.screen > * { margin-left: 16px; margin-right: 16px; }
.screen > .card, .screen > .list-card { margin-left: 16px; margin-right: 16px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.pad { padding: 14px; }
.mono { font-variant-numeric: tabular-nums; }
.big-title { font-size: 22px; font-weight: 700; }
.error { color: var(--danger); font-size: 15px; }
.warning { color: var(--warn); background: var(--card); padding: 12px 14px; border-radius: var(--radius); font-size: 15px; }
.hint { color: var(--muted); font-size: 13px; margin: -4px 16px -6px; display: flex; align-items: center; gap: 6px; }

/* MARK: Buttons and links (iOS prominent / bordered / plain) */

.btn {
  appearance: none;
  border: 0;
  background: var(--card);
  color: var(--accent);
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  min-height: 50px;
  padding: 0 16px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.big { width: 100%; }
.screen > .btn.big { width: auto; }  /* the column already stretches it; 100% plus margins overflowed */
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); }
.btn.danger-fill { background: var(--danger); color: #fff; }

.linkish {
  appearance: none;
  background: none;
  border: 0;
  padding: 6px 2px;
  font: inherit;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.linkish.danger { color: var(--danger); }
.linkish.center { justify-content: center; }
.nav-back { font-weight: 400; }

.icon-btn {
  appearance: none;
  background: none;
  border: 0;
  color: var(--accent);
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.icon-btn:disabled { opacity: 0.3; }

.chip {
  appearance: none;
  border: 0;
  background: var(--fill);
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  padding: 0 10px;
  height: 32px;
  cursor: pointer;
}

.icon { flex: none; vertical-align: -3px; }

/* MARK: Navigation and top bar (iOS nav bar with translucent material) */

.navbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 44px;
  margin: 0 !important;
  padding: 0 16px;
}
.nav-title { font-size: 17px; font-weight: 600; text-align: center; grid-column: 2; }
.nav-side { display: flex; }
.nav-side.end { justify-content: flex-end; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  margin: 0 !important;
  padding: calc(env(safe-area-inset-top) + 4px) 12px 4px;
  background: var(--bar);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border-bottom: 0.5px solid var(--line);
}
.title {
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pill {
  appearance: none;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 4px;
  white-space: nowrap;
  cursor: pointer;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pill.synced { color: var(--ok); }
.pill.syncing { color: var(--accent); }
.pill.offline { color: var(--warn); }
.pill.invalidCode, .pill.error { color: var(--danger); }

.banner {
  display: block;
  margin: 10px 16px 0 !important;
  width: calc(100% - 32px);
  text-align: center;
  padding: 11px 12px;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  border: 0;
  background: var(--card);
  color: var(--warn);
}
.banner.danger { color: var(--danger); cursor: pointer; }

/* MARK: Cards (iOS insetGrouped) */

.card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
}
.form-card { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.form-card h2 { font-size: 13px; font-weight: 400; text-transform: uppercase; color: var(--muted); letter-spacing: 0.01em; }
.form-card .small { font-size: 13px; }

.empty-card { padding: 28px 16px; display: flex; flex-direction: column; gap: 8px; align-items: center; text-align: center; }
.empty-icon { color: var(--accent); opacity: 0.8; }
.empty-card h2 { font-size: 17px; }

/* MARK: Forms and inputs */

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; color: var(--muted); text-transform: uppercase; }
.row-inline { display: flex; gap: 8px; align-items: stretch; }
.row-inline > input { flex: 1; min-width: 0; }

input[type="text"], input[type="number"], input[type="date"] {
  appearance: none;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 17px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.inline { min-height: 34px !important; }
.form-card input[type="text"], .sheet-card input[type="text"] { background: var(--bg); }

.home {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 24px 16px 4px;
  text-align: center;
}
.logo {
  width: 120px;
  height: 120px;
  border-radius: 27px;
  box-shadow: 0 12px 28px rgba(176, 48, 110, 0.30), 0 1px 3px rgba(0, 0, 0, 0.15);
  animation: logo-in 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both, logo-float 6s ease-in-out 1s infinite;
}
.brand { margin-top: 14px; font-size: 30px; font-weight: 700; letter-spacing: -0.01em; animation: fade-up 0.8s 0.15s both; }
.tagline { color: var(--muted); font-size: 16px; animation: fade-up 0.8s 0.3s both; }
.home-actions { margin-top: 10px; }
.how { padding: 14px 16px 16px; margin-top: 6px; }
.how h2 { font-size: 13px; font-weight: 400; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.how .steps-list { font-size: 16px; }

@keyframes logo-in {
  from { opacity: 0; transform: translateY(18px) scale(0.9); }
  to { opacity: 1; transform: none; }
}
@keyframes logo-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.steps-list { display: flex; flex-direction: column; gap: 14px; padding-left: 1.4em; font-size: 17px; }
.steps-list li { padding-left: 4px; }
.steps-list .icon { color: var(--accent); }
.stack { display: flex; flex-direction: column; gap: 10px; }

.code-big {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-align: center;
  padding: 14px 12px;
  background: var(--card-2);
  border-radius: var(--radius);
  word-break: break-all;
  user-select: all;
}
.code-big.small { font-size: 15px; letter-spacing: 0.02em; padding: 12px 8px; }

/* MARK: Sheets (iOS action sheets and sheets) */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 8px;
}
.sheet[hidden] { display: none; }
.sheet-card {
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 14px;
  padding: 20px 16px calc(env(safe-area-inset-bottom) + 12px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}
.menu { display: flex; flex-direction: column; gap: 10px; }
.menu h2 { text-align: center; font-size: 17px; }
.menu > p { font-size: 15px; text-align: center; }
.menu-item {
  appearance: none;
  border: 0;
  background: var(--card-2);
  color: var(--accent);
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  min-height: 50px;
  border-radius: var(--radius);
  padding: 0 14px;
  text-align: center;
  cursor: pointer;
}
.menu-item.danger { color: var(--danger); }
.import-list h3 { font-size: 13px; font-weight: 400; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.import-list ol, .import-list ul { max-height: 30vh; overflow-y: auto; font-size: 15px; }

/* MARK: The list */

.list-screen { gap: 12px; }
.list-screen .topbar + .addbar, .list-screen .banner + .addbar { margin-top: 6px; }

.addbar {
  position: sticky;
  top: calc(env(safe-area-inset-top) + 57px);
  z-index: 4;
  display: flex;
  gap: 8px;
  padding: 6px;
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 6px 18px rgba(142, 44, 92, 0.08);
}
.addbar input[type="text"] { flex: 1; min-width: 0; background: transparent; min-height: 46px; }
.addbar input:focus { outline: none; }
.add-btn { min-height: 46px; width: 50px; padding: 0; border-radius: 10px; }

.list-card { display: flex; flex-direction: column; }

.swipe-row {
  position: relative;
  overflow: hidden;
  border-top: 0.5px solid var(--line);
}
.swipe-row:first-child { border-top: 0; }
.swipe-row.collapsing { transition: height 0.18s ease, opacity 0.18s ease; opacity: 0; }

.swipe-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--fill);
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}
.swipe-bg > span { display: inline-flex; align-items: center; gap: 6px; }
.swipe-row.left .swipe-bg > span:first-child,
.swipe-row:not(.left) .swipe-bg > span:last-child { visibility: hidden; }
.swipe-row.armed .swipe-bg { background: var(--got); color: #fff; }

.swipe-front {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px 4px 6px;
  min-height: 60px;
  background: var(--card);
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.swipe-row.dragging .swipe-front { cursor: grabbing; }

.check {
  appearance: none;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
}
.check::before {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--faint);
}
.check .icon { position: relative; }
@media (hover: hover) {
  .check:hover { color: var(--got); }
  .check:hover::before { border-color: var(--got); }
}
.check:active::before { background: var(--got); border-color: var(--got); }
.check:active { color: #fff; }

.item-text {
  appearance: none;
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  padding: 8px 0;
  font: inherit;
  color: var(--text);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 1px;
  cursor: pointer;
}
.item-name { font-size: 17px; font-weight: 500; overflow-wrap: anywhere; }
.item-meta { font-size: 12px; color: var(--muted); }
.swipe-front > input.inline { flex: 1; min-width: 0; background: var(--bg); }

.swipe-row.flash .swipe-front { animation: flash 1.2s ease; }
@keyframes flash {
  0%, 40% { box-shadow: inset 0 0 0 100vmax var(--accent-soft); }
  100% { box-shadow: inset 0 0 0 100vmax transparent; }
}

.list-footer { color: var(--muted); font-size: 13px; text-align: center; }

/* MARK: Toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  z-index: 40;
  transform: translate(-50%, 20px);
  opacity: 0;
  width: max-content;
  max-width: calc(100% - 32px);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 10px 10px 16px;
  border-radius: 14px;
  background: #2b2229;
  color: #fff;
  font-size: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast[hidden] { display: none; }
.toast-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast-undo {
  appearance: none;
  border: 0;
  background: rgba(255, 255, 255, 0.14);
  color: #ff9ccb;
  font: inherit;
  font-weight: 700;
  border-radius: 9px;
  padding: 7px 12px;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
