* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--ff-sans);
  font-size: var(--fs-16);
  color: var(--c-text);
  background: var(--c-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--c-brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: var(--fs-32); line-height: 1.2; margin: 0 0 var(--sp-3); font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: var(--fs-24); line-height: 1.3; margin: 0 0 var(--sp-3); font-weight: 650; letter-spacing: -.005em; }
h3 { font-size: var(--fs-18); margin: 0 0 var(--sp-2); font-weight: 600; }
p  { margin: 0 0 var(--sp-3); }

.muted { color: var(--c-text-muted); }
.center { text-align: center; }
.inline { display: inline; }
.inline-form { display: inline-flex; }
code { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; background: var(--c-surface-2); padding: 2px 6px; border-radius: 6px; font-size: .9em; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: var(--c-surface-2);
  color: var(--c-text);
  font: inherit; font-weight: 600;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--c-brand); color: white; box-shadow: var(--sh-sm); }
.btn-primary:hover { background: var(--c-brand-ink); }
.btn-ghost { background: transparent; border-color: var(--c-border); }
.btn-ghost:hover { background: var(--c-surface-2); }
.btn-danger { background: var(--c-danger-soft); color: var(--c-danger); }
.btn-danger:hover { background: var(--c-danger); color: white; }
.btn-sm { padding: 6px 12px; font-size: var(--fs-14); }
.btn-lg { padding: 14px 28px; font-size: var(--fs-18); }
.btn-block { width: 100%; }

.link-button { background: none; border: 0; padding: 0; color: var(--c-brand-ink); font: inherit; cursor: pointer; }
.link-button:hover { text-decoration: underline; }

/* Header */
.mu-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  position: sticky; top: 0; z-index: 10;
}
.mu-brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: var(--fs-18); color: var(--c-text);
}
.mu-brand:hover { text-decoration: none; }
.mu-nav { display: flex; align-items: center; gap: var(--sp-4); }
.mu-nav a { color: var(--c-text); font-weight: 500; }
.locale-switch { display: flex; gap: 2px; background: var(--c-surface-2); border-radius: var(--r-pill); padding: 2px; }
.locale-switch button {
  background: none; border: 0; padding: 6px 12px; border-radius: var(--r-pill);
  font-size: var(--fs-12); font-weight: 600; color: var(--c-text-muted); cursor: pointer;
}
.locale-switch button.active { background: var(--c-surface); color: var(--c-text); box-shadow: var(--sh-sm); }

/* Main */
.mu-main {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--sp-7) var(--sp-5);
}

/* Footer */
.mu-footer {
  text-align: center; padding: var(--sp-5);
  color: var(--c-text-subtle); font-size: var(--fs-14);
}

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

/* Auth card */
.auth-card {
  max-width: 420px;
  margin: var(--sp-7) auto;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  padding: var(--sp-7) var(--sp-6);
  box-shadow: var(--sh-md);
}
.auth-card h1 { text-align: center; margin-bottom: var(--sp-5); }

/* Form */
.form { display: flex; flex-direction: column; gap: var(--sp-4); }
.form label { display: flex; flex-direction: column; gap: 6px; }
.form label span { font-size: var(--fs-14); font-weight: 600; color: var(--c-text-muted); }
.form input, .form select, input[type=text], input[type=email], input[type=password], input[type=number], input[type=time], select {
  font: inherit;
  padding: 11px 14px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-surface);
  color: var(--c-text);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.form input:focus, .form select:focus, input:focus, select:focus {
  outline: none;
  border-color: var(--c-brand);
  box-shadow: 0 0 0 3px var(--c-brand-soft);
}
.alert { padding: 10px 14px; border-radius: var(--r-md); margin-bottom: var(--sp-3); font-size: var(--fs-14); }
.alert.error { background: var(--c-danger-soft); color: var(--c-danger); }

/* Page head */
.page-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}
.page-head h1 { margin-bottom: var(--sp-1); display: flex; align-items: center; gap: 10px; }
.back-link { font-size: var(--fs-14); color: var(--c-text-muted); }
.child-dot {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%;
  background: var(--child);
}

/* Card grid (children) */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--sp-4);
}
.child-card {
  display: flex; align-items: center; gap: var(--sp-4);
  text-decoration: none; color: inherit;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
  border-left: 4px solid var(--child);
}
.child-card:hover { transform: translateY(-2px); box-shadow: var(--sh-md); text-decoration: none; }
.child-avatar {
  width: 64px; height: 64px; border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--child) 18%, white);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.child-avatar img { width: 40px; height: 40px; }
.child-avatar .initial { font-size: var(--fs-32); font-weight: 700; color: var(--child); }
.child-meta { flex: 1; }
.child-meta h3 { margin-bottom: 2px; }
.child-arrow { color: var(--c-text-subtle); font-size: var(--fs-24); }

.card-add {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-3);
  text-decoration: none; color: var(--c-text-muted);
  border-style: dashed;
  background: transparent;
}
.card-add:hover { border-color: var(--c-brand); color: var(--c-brand); text-decoration: none; }
.big-plus { font-size: 48px; line-height: 1; }

.empty-state { text-align: center; padding: var(--sp-7); }
.empty-state h2 { margin-top: var(--sp-4); }

/* Routine list */
.routine-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.routine-row {
  display: flex; justify-content: space-between; align-items: center;
  text-decoration: none; color: inherit;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.routine-row:hover { transform: translateX(3px); text-decoration: none; box-shadow: var(--sh-md); }
.routine-arrow { font-size: var(--fs-24); color: var(--c-text-subtle); }

/* Color picker */
.color-grid { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.color-chip input { display: none; }
.color-chip span {
  display: block; width: 36px; height: 36px; border-radius: 50%;
  cursor: pointer; border: 3px solid transparent;
  transition: transform var(--dur-fast) var(--ease);
}
.color-chip input:checked + span { border-color: var(--c-text); transform: scale(1.1); }

/* Icon picker (inline + modal) */
.icon-picker-inline { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.icon-chip { position: relative; cursor: pointer; }
.icon-chip input { position: absolute; opacity: 0; }
.icon-chip img {
  width: 56px; height: 56px;
  padding: 8px;
  background: var(--c-surface-2);
  border-radius: var(--r-md);
  border: 2px solid transparent;
  transition: border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.icon-chip input:checked + img { border-color: var(--c-brand); background: var(--c-brand-soft); }

.icon-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--sp-2); max-height: 400px; overflow: auto; padding: var(--sp-2); }
.icon-grid button {
  background: var(--c-surface-2); border: 2px solid transparent; border-radius: var(--r-md); padding: 10px; cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.icon-grid button:hover { background: var(--c-brand-soft); border-color: var(--c-brand); }
.icon-grid img { width: 40px; height: 40px; display: block; }

dialog {
  border: 0; border-radius: var(--r-xl); padding: var(--sp-5);
  max-width: 480px; width: calc(100% - 40px);
  box-shadow: var(--sh-lg);
}
dialog::backdrop { background: rgba(15,18,34,.5); backdrop-filter: blur(4px); }
dialog h3 { margin-bottom: var(--sp-3); }
dialog menu { padding: 0; margin: var(--sp-4) 0 0; display: flex; justify-content: flex-end; gap: var(--sp-2); }

/* Routine editor */
.routine-editor { display: flex; flex-direction: column; gap: var(--sp-5); }
.routine-settings {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-4);
  position: relative;
}
.routine-settings .field { display: flex; flex-direction: column; gap: 6px; }
.routine-settings .field label { font-size: var(--fs-14); font-weight: 600; color: var(--c-text-muted); }
.routine-settings .field-wide { grid-column: span 3; }
.saved-indicator {
  position: absolute; top: var(--sp-3); right: var(--sp-3);
  color: var(--c-ok); font-size: var(--fs-14); font-weight: 600;
  opacity: 0; transition: opacity var(--dur) var(--ease);
}
.saved-indicator.show { opacity: 1; }

.task-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.task-item {
  display: grid;
  grid-template-columns: auto 72px 1fr auto auto;
  gap: var(--sp-3);
  align-items: center;
  padding: var(--sp-3);
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.task-item.dragging { opacity: .4; }
.task-item.drag-over { transform: translateY(3px); box-shadow: var(--sh-md); }
.drag-handle { cursor: grab; color: var(--c-text-subtle); font-size: var(--fs-18); user-select: none; padding: 4px; }
.task-icon {
  width: 72px; height: 72px; border-radius: var(--r-md);
  background: var(--c-surface-2);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.task-icon img { width: 100%; height: 100%; object-fit: cover; }
.task-icon .placeholder { font-size: var(--fs-24); color: var(--c-text-subtle); }
.task-fields { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.task-fields input { font-size: var(--fs-14); padding: 6px 10px; }
.task-duration { display: flex; align-items: center; gap: 6px; }
.task-duration input { width: 64px; text-align: right; }
.task-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

.danger-zone { margin-top: var(--sp-7); text-align: center; }

/* Settings */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-4);
}
.kid-link {
  display: inline-block;
  cursor: pointer;
  padding: 8px 12px;
  font-size: var(--fs-14);
  word-break: break-all;
}
.kid-link:hover { background: var(--c-brand-soft); }

/* Landing */
.hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-7);
  align-items: center;
  padding: var(--sp-7) 0;
}
.hero h1 { font-size: var(--fs-48); line-height: 1.1; letter-spacing: -.02em; }
.hero .lead { font-size: var(--fs-18); color: var(--c-text-muted); margin-bottom: var(--sp-5); }
.cta-row { display: flex; gap: var(--sp-3); flex-wrap: wrap; }

.hero-art { display: flex; justify-content: center; }
.preview-card {
  position: relative;
  width: 280px; height: 320px;
  background: var(--c-surface);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-lg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: var(--sp-5);
  transform: rotate(-3deg);
  border: 1px solid var(--c-border);
}
.preview-ring {
  position: relative;
  width: 140px; height: 140px;
  margin-bottom: var(--sp-4);
}
.preview-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.preview-ring .ring-track { fill: none; stroke: var(--c-brand-soft); stroke-width: 10; }
.preview-ring .ring-fill { fill: none; stroke: var(--c-brand); stroke-width: 10; stroke-linecap: round; }
.preview-time {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-24); font-weight: 700;
}
.preview-icon {
  position: absolute; top: var(--sp-4); left: var(--sp-4);
  width: 48px; height: 48px; background: var(--c-brand-soft); border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
}
.preview-icon img { width: 28px; height: 28px; }
.preview-title { font-weight: 600; font-size: var(--fs-18); }

.features {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--sp-5);
  padding: var(--sp-7) 0;
}
.feature {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.feature:hover { transform: translateY(-4px); box-shadow: var(--sh-md); }
.feature-icon {
  width: 48px; height: 48px; border-radius: var(--r-md);
  background: var(--c-brand-soft);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: var(--sp-4);
}
.feature-icon img { width: 28px; height: 28px; }
.feature p { color: var(--c-text-muted); margin: 0; }

/* Toast */
.toast {
  position: fixed; bottom: var(--sp-5); left: 50%; transform: translateX(-50%);
  background: var(--c-text); color: white;
  padding: 10px 18px; border-radius: var(--r-pill);
  box-shadow: var(--sh-lg);
  font-size: var(--fs-14);
  opacity: 0; transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
  pointer-events: none;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

@media (max-width: 720px) {
  .hero { grid-template-columns: 1fr; }
  .hero h1 { font-size: var(--fs-32); }
  .mu-main { padding: var(--sp-5) var(--sp-4); }
  .page-head { flex-direction: column; }
  .routine-settings { grid-template-columns: 1fr 1fr; }
  .routine-settings .field-wide { grid-column: span 2; }
  .task-item { grid-template-columns: auto 56px 1fr; row-gap: var(--sp-2); }
  .task-icon { width: 56px; height: 56px; }
  .task-duration, .task-actions { grid-column: 2 / -1; }
}
