/* Meoww design system — CSS variables, reset, shared primitives. Mobile-first. */

:root {
  --bg: #f5f6f8;
  --bg-elevated: #ffffff;
  --bg-inset: #eef0f3;
  --text: #16181d;
  --text-muted: #5b6270;
  --border: #e2e4e9;
  --accent: #5b5bd6;
  --accent-contrast: #ffffff;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;

  --priority-high-bg: rgba(220, 38, 38, 0.10);
  --priority-high-border: rgba(220, 38, 38, 0.35);
  --priority-medium-bg: rgba(217, 119, 6, 0.10);
  --priority-medium-border: rgba(217, 119, 6, 0.35);
  --priority-low-bg: rgba(37, 99, 235, 0.10);
  --priority-low-border: rgba(37, 99, 235, 0.30);
  --priority-normal-bg: transparent;
  --priority-normal-border: var(--border);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(16, 20, 30, 0.06);
  --shadow-md: 0 6px 20px rgba(16, 20, 30, 0.10);
  --nav-height: 60px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101216;
    --bg-elevated: #1a1d23;
    --bg-inset: #22262e;
    --text: #eef0f3;
    --text-muted: #9aa1ad;
    --border: #2b2f38;
    --accent: #8484f0;
    --accent-contrast: #101216;

    --priority-high-bg: rgba(248, 113, 113, 0.14);
    --priority-high-border: rgba(248, 113, 113, 0.35);
    --priority-medium-bg: rgba(251, 191, 36, 0.14);
    --priority-medium-border: rgba(251, 191, 36, 0.35);
    --priority-low-bg: rgba(96, 165, 250, 0.14);
    --priority-low-border: rgba(96, 165, 250, 0.35);
    --priority-normal-bg: transparent;
    --priority-normal-border: var(--border);
  }
}

:root[data-theme="dark"] {
  --bg: #101216;
  --bg-elevated: #1a1d23;
  --bg-inset: #22262e;
  --text: #eef0f3;
  --text-muted: #9aa1ad;
  --border: #2b2f38;
  --accent: #8484f0;
  --accent-contrast: #101216;

  --priority-high-bg: rgba(248, 113, 113, 0.14);
  --priority-high-border: rgba(248, 113, 113, 0.35);
  --priority-medium-bg: rgba(251, 191, 36, 0.14);
  --priority-medium-border: rgba(251, 191, 36, 0.35);
  --priority-low-bg: rgba(96, 165, 250, 0.14);
  --priority-low-border: rgba(96, 165, 250, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  max-width: 100%;
  overflow-x: hidden;
}

body { min-height: 100vh; }

a { color: var(--accent); }

button, input, textarea, select {
  font-family: inherit;
  font-size: 16px; /* prevents iOS zoom-on-focus */
  color: var(--text);
}

button {
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 10px 16px;
  font-weight: 600;
  transition: opacity .15s ease, transform .1s ease;
}
button:active { transform: scale(0.98); }
button:disabled { opacity: .5; cursor: not-allowed; }

button.secondary {
  background: var(--bg-inset);
  color: var(--text);
  border: 1px solid var(--border);
}
button.ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 8px 10px;
}
button.danger { background: var(--danger); color: #fff; }
button.icon-btn {
  background: transparent;
  color: var(--text-muted);
  padding: 6px;
  border-radius: 999px;
  line-height: 1;
}
button.icon-btn:hover { background: var(--bg-inset); }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="datetime-local"], input[type="search"], textarea, select {
  width: 100%;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
}
textarea { resize: vertical; min-height: 70px; }
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

label { font-size: 13px; font-weight: 600; color: var(--text-muted); display: block; margin-bottom: 6px; }
.field { margin-bottom: 14px; }
.hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.error-text { color: var(--danger); font-size: 13px; margin-top: 6px; }

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-inset);
  color: var(--text-muted);
}

.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

.muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-inset) 25%, var(--border) 37%, var(--bg-inset) 63%);
  background-size: 400% 100%;
  animation: skeleton-loading 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-loading {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.toast-stack {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  width: min(420px, 92vw);
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  animation: toast-in .2s ease;
}
.toast.error { border-color: var(--priority-high-border); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (min-width: 768px) {
  .toast-stack { bottom: 16px; }
}
