:root {
  color-scheme: light dark;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  --text-strong: #101828;
  --text-muted: #475467;
  --text-subtle: #667085;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --surface-raised: #ffffff;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --primary: #2d6df6;
  --primary-strong: #1f5fe0;
  --primary-soft: #e8f0ff;
  --success: #168a4b;
  --warning: #b54708;
  --danger: #b42318;
  --info: #1570ef;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.08);
  --shadow-md: 0 8px 20px rgba(16, 24, 40, 0.12);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text-strong: #f9fafb;
    --text-muted: #d0d5dd;
    --text-subtle: #98a2b3;
    --surface: #0f172a;
    --surface-muted: #1e293b;
    --surface-raised: #1e293b;
    --border: #334155;
    --border-strong: #475569;
    --primary: #3b82f6;
    --primary-strong: #60a5fa;
    --primary-soft: #172554;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.6);
  }
}

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

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--surface-muted);
  color: var(--text-strong);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* App Shell */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: 80px; /* Space for nav */
}

/* Top Bar */
.top-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.top-bar__inner {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.top-bar__eyebrow {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
}

.top-bar__title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-strong);
}

.top-bar__subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 2px 0 0;
}

/* Page Content */
.page-content {
  flex: 1;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  border: 1px solid var(--border);
}

.card-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0 0 16px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-header .card-title {
  margin: 0;
}

.card-subtitle {
  color: var(--text-muted);
  margin: -8px 0 16px;
  font-size: 0.9375rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
  border: none;
  font-weight: 600;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn:hover {
  background: var(--primary-strong);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn--secondary {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.btn--secondary:hover {
  background: #dbeafe; /* Slightly darker soft blue */
}

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn--ghost:hover {
  background: var(--surface-muted);
  color: var(--text-strong);
}

.btn--danger {
  background: #fef2f2;
  color: var(--danger);
}

/* Lists */
.list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.list-row {
  display: flex;
  flex-direction: column;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.list-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.list-row:first-child {
  padding-top: 0;
}

.list-row__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 4px;
}

.list-row__title {
  font-weight: 600;
  margin: 0;
  font-size: 1rem;
}

.list-row__meta {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin: 0;
}

.list-row__actions {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.badge--success {
  background: #ecfdf5;
  color: var(--success);
}

.badge--warning {
  background: #fffbeb;
  color: var(--warning);
}

.badge--danger {
  background: #fef2f2;
  color: var(--danger);
}

/* Forms */
.form-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-strong);
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #1f2937;
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 0.9375rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  opacity: 0;
  animation: slideUp 0.3s forwards;
  pointer-events: auto;
}

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

.toast--success {
  background: var(--success);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Empty States */
.empty-state {
  text-align: center;
  padding: 32px 0;
}

.empty-state__title {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 8px;
}

.empty-state__text {
  color: var(--text-muted);
  margin: 0;
}

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 16px 24px; /* Extra padding for safe area */
  z-index: 20;
}

.bottom-nav__list {
  display: flex;
  justify-content: space-around;
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 600px;
  margin: 0 auto;
}

.bottom-nav__item {
  flex: 1;
}

.bottom-nav__link {
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-subtle);
  font-size: 0.75rem;
  font-weight: 600;
  position: relative;
  padding: 8px 0;
  text-decoration: none;
}

.nav-badge {
  position: absolute;
  top: 6px;
  right: 25%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--surface);
}

.bottom-nav__item.is-active .bottom-nav__link {
  color: var(--primary);
  background: var(--primary-soft);
}


.bottom-nav__icon {
  width: 24px;
  height: 24px;
}

.bottom-nav__icon svg {
  width: 100%;
  height: 100%;
}

/* Preview Banner */
.preview-banner {
  background-color: var(--warning);
  color: #ffffff;
  padding: 0.75rem 1rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.875rem;
}

.preview-banner a {
  color: #ffffff;
  text-decoration: underline;
  margin-left: 0.5rem;
}