/* tmx-recipes — mobile-first styles */
:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #f1eee7;
  --text: #1d2420;
  --muted: #69716c;
  --line: #e4e0d6;
  --primary: #0f766e;
  --primary-ink: #ffffff;
  --primary-soft: #e3f2ef;
  --warn: #b45309;
  --warn-soft: #fdf1e2;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #15803d;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .05), 0 4px 16px rgba(20, 30, 25, .05);
  --tabbar-h: 64px;
  --topbar-h: 56px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121614;
    --surface: #1b201d;
    --surface-2: #232a26;
    --text: #e9eeeb;
    --muted: #9aa49e;
    --line: #2d3530;
    --primary: #2bb3a3;
    --primary-ink: #06201d;
    --primary-soft: #16302c;
    --warn: #f0a24a;
    --warn-soft: #33261a;
    --danger: #f2776b;
    --danger-soft: #3a1f1c;
    --ok: #4ade80;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { line-height: 1.25; margin: 0 0 .6rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
p { margin: 0 0 .75rem; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
[hidden] { display: none !important; }

.icon { width: 24px; height: 24px; flex: none; }
.icon.tiny { width: 18px; height: 18px; }

/* ------------------------------------------------------------------ layout */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 16px 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 650; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand-icon { color: var(--primary); width: 26px; height: 26px; }

.avatar {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--primary); color: var(--primary-ink);
  font-weight: 700; font-size: 1rem;
}
.avatar:hover { text-decoration: none; }
.avatar.small { width: 34px; height: 34px; font-size: .9rem; flex: none; }
.avatar.large { width: 56px; height: 56px; font-size: 1.4rem; flex: none; }

.content {
  max-width: 760px; margin: 0 auto;
  padding: 20px 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
}

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: .72rem; font-weight: 600;
}
.tabbar a:hover { text-decoration: none; }
.tabbar a.is-active { color: var(--primary); }
.tabbar .icon { width: 26px; height: 26px; }

.sidebar { display: none; }

@media (min-width: 900px) {
  body.with-nav { display: grid; grid-template-columns: 250px 1fr; }
  .topbar, .tabbar { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: 8px;
    position: sticky; top: 0; height: 100vh;
    padding: 20px 14px; border-right: 1px solid var(--line); background: var(--surface);
  }
  .sidebar-brand { padding: 6px 10px 18px; }
  .content { padding: 32px 32px 48px; width: 100%; }
}
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav-bottom { margin-top: auto; border-top: 1px solid var(--line); padding-top: 10px; }
.side-nav a, .side-logout {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text); font: inherit; font-size: .98rem; font-weight: 550;
  background: none; border: 0; width: 100%; cursor: pointer; text-align: left;
}
.side-nav a:hover, .side-logout:hover { background: var(--surface-2); text-decoration: none; }
.side-nav a.is-active { background: var(--primary-soft); color: var(--primary); }
.side-nav form { margin: 0; }
.sidebar-version { color: var(--muted); font-size: .75rem; padding: 0 12px; margin: 4px 0 0; }

/* ------------------------------------------------------------------ cards */
.card {
  display: block;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 16px;
}
a.card:hover { text-decoration: none; border-color: var(--primary); }
.card.narrow { max-width: 460px; margin-left: auto; margin-right: auto; }
.card.highlight { border-color: var(--primary); background: var(--primary-soft); }
.card.danger { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.page-title { margin: 4px 0 16px; }

.hello h1 { font-size: 1.75rem; margin-bottom: 2px; }
.hello { margin: 4px 0 18px; }

.status-card { display: flex; align-items: center; gap: 14px; }
.status-icon {
  display: grid; place-items: center; width: 48px; height: 48px; flex: none;
  border-radius: 14px; background: var(--warn-soft); color: var(--warn);
}
.status-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.status-text .muted { font-size: .9rem; }
.chevron { color: var(--muted); width: 20px; height: 20px; }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 600px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 18px;
  min-height: 112px; padding: 16px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  font-weight: 650; font-size: 1.05rem;
}
.tile:hover { text-decoration: none; border-color: var(--primary); }
.tile-icon { width: 32px; height: 32px; color: var(--primary); }
.tile-admin .tile-icon { color: var(--warn); }

.install-hint { display: flex; gap: 14px; align-items: flex-start; }
.install-icon { color: var(--primary); margin-top: 2px; }
.install-hint p { margin: 4px 0 0; font-size: .92rem; }
@media (display-mode: standalone) { .install-hint { display: none; } }

.soon { text-align: center; padding: 32px 22px; }
.soon-icon {
  display: inline-grid; place-items: center; width: 72px; height: 72px; margin-bottom: 12px;
  border-radius: 22px; background: var(--primary-soft); color: var(--primary);
}
.soon-icon .icon { width: 36px; height: 36px; }
.soon-badge {
  display: inline-block; margin: 0 0 10px; padding: 3px 12px; border-radius: 99px;
  background: var(--warn-soft); color: var(--warn); font-size: .8rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
}
.soon-lead { font-size: 1.1rem; font-weight: 600; }
.soon-list { list-style: none; padding: 0; margin: 14px auto 0; max-width: 420px; text-align: left; }
.soon-list li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); }
.soon-list .icon { color: var(--primary); margin-top: 3px; }

.list-card { padding: 4px 0; }
.list-card a {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 18px; color: var(--text); border-top: 1px solid var(--line);
}
.list-card a:first-child { border-top: 0; }
.list-card a:hover { background: var(--surface-2); text-decoration: none; }
.list-card a > span:not(.avatar):not(.badges):not(.list-main) { flex: 1; }
.list-card .chevron { margin-left: auto; }
.list-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.list-main .muted { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.is-muted { opacity: .55; }

.badges { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 99px;
  background: var(--primary-soft); color: var(--primary);
  font-size: .74rem; font-weight: 700; white-space: nowrap;
}
.badge-off { background: var(--surface-2); color: var(--muted); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }

/* ------------------------------------------------------------------ forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label, fieldset { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .95rem; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
.form small { color: var(--muted); font-weight: 400; font-size: .85rem; }
input[type=text], input[type=email], input[type=password], input[type=number] {
  width: 100%; min-height: 48px; padding: 10px 14px;
  font: inherit; font-size: 17px; font-weight: 400;  /* 17px avoids iOS zoom-on-focus */
  color: var(--text); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
}
input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.radio { flex-direction: row !important; align-items: center; gap: 10px !important; font-weight: 500 !important; min-height: 40px; }
.radio input { width: 22px; height: 22px; accent-color: var(--primary); }
@media (min-width: 700px) {
  .form-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: end; }
  .form-grid button { grid-column: 1 / -1; justify-self: start; }
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 20px;
  font: inherit; font-weight: 650; font-size: 1rem;
  border-radius: var(--radius-sm); border: 1.5px solid transparent; cursor: pointer;
}
.btn:hover { text-decoration: none; filter: brightness(1.05); }
.btn .icon { width: 20px; height: 20px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.btn-danger { background: var(--danger); color: #fff; }
.actions { display: grid; gap: 10px; }
@media (min-width: 600px) { .actions { grid-template-columns: 1fr 1fr; } }
.actions form { margin: 0; }
.logout-form { margin-top: 8px; }

.flash {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; margin-bottom: 14px; border-radius: var(--radius-sm);
  background: var(--primary-soft); color: var(--text); font-weight: 550;
}
.flash .icon { color: var(--ok); width: 22px; height: 22px; }
.flash-error { background: var(--danger-soft); }
.flash-error .icon { color: var(--danger); }
.form-error {
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--danger-soft); color: var(--danger); font-weight: 600;
}
.notice { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--primary-soft); font-size: .95rem; }

/* ------------------------------------------------------------------ auth */
.auth-wrap { max-width: 440px; margin: 0 auto; padding: calc(32px + env(safe-area-inset-top)) 16px 32px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 20px; text-align: center; }
.auth-brand h1 { font-size: 1.5rem; margin: 0; }
.auth-logo {
  width: 64px; height: 64px; padding: 12px; border-radius: 20px;
  background: var(--primary); color: var(--primary-ink);
}
.auth-card h2 { font-size: 1.3rem; }
.auth-alt { text-align: center; margin: 16px 0 0; font-size: .95rem; }
.auth-alt + .auth-alt { margin-top: 6px; font-size: .85rem; }
.auth-foot { text-align: center; color: var(--muted); font-size: .75rem; margin-top: 18px; }

/* ------------------------------------------------------------------ admin */
.chips {
  display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 18px; padding: 0 16px 4px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chips a {
  flex: none; padding: 8px 16px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--text); font-weight: 600; font-size: .92rem;
}
.chips a:hover { text-decoration: none; border-color: var(--primary); }
.chips a.is-active { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { margin: 0; padding: 14px 16px; }
.stat strong { display: block; font-size: 1.8rem; line-height: 1.1; color: var(--primary); }
.stat span { color: var(--muted); font-size: .88rem; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; font-size: .95rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.rows { list-style: none; padding: 0; margin: 0; }
.rows li { display: flex; flex-direction: column; padding: 9px 0; border-top: 1px solid var(--line); font-size: .93rem; }
.rows li:first-child { border-top: 0; }
.rows .muted { font-size: .84rem; overflow-wrap: anywhere; }
.small-link { font-size: .85rem; font-weight: 500; margin-left: 8px; }

.back-link { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 12px; font-weight: 600; }
.back-link .icon { width: 20px; height: 20px; }
.user-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.user-head h2 { margin: 0; }
.user-head p { margin: 0; }

.copy-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.copy-row code {
  flex: 1; min-width: 200px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px dashed var(--primary); font-size: 1.1rem; font-weight: 700;
}

.invite-list { list-style: none; padding: 0; margin: 0; }
.invite { padding: 12px 0; border-top: 1px solid var(--line); }
.invite:first-child { border-top: 0; }
.invite-head { display: flex; align-items: center; gap: 10px; }
.invite-head code { font-size: 1.15rem; font-weight: 700; letter-spacing: .06em; }
.invite p { margin: 4px 0 8px; }
.invite-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.invite-actions form { margin: 0; }
.invite-actions .btn { min-height: 40px; padding: 6px 14px; font-size: .92rem; }

.prose ol { padding-left: 1.3rem; margin: 0 0 .75rem; }
.prose li { margin-bottom: 4px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  transform: translateX(-50%); z-index: 50;
  padding: 10px 18px; border-radius: 99px; background: var(--text); color: var(--bg);
  font-weight: 600; font-size: .92rem; box-shadow: var(--shadow);
}
@media (min-width: 900px) { .toast { bottom: 24px; } }
.visually-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
