.app { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg-soft); }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 28px; background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.topbar__brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); }
.topbar__spacer { flex: 1; }
/* Topbar Log out (mobile only — desktop has it in the sidebar) */
.topbar__logout-form { display: none; margin: 0; }
.topbar__logout {
  background: none; border: 0; color: var(--text-muted);
  font-size: 0.88rem; padding: 6px 10px; cursor: pointer;
  border-radius: var(--radius-md);
}
.topbar__logout:hover { background: var(--bg-soft); color: var(--text); }
.access-pill {
  background: linear-gradient(180deg, #5c6573 0%, #3d4350 100%);
  color: #f4f5f7; border: 0; border-radius: 999px;
  padding: 12px 22px; font-weight: 600; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.18), inset 0 1px 0 rgba(255,255,255,.12);
  transition: transform .08s ease, filter .15s ease;
}
.access-pill:hover { filter: brightness(1.08); }
.access-pill:active { transform: translateY(1px); }
.access-pill[disabled] { opacity: .6; cursor: progress; }

.layout { display: grid; grid-template-columns: 260px 1fr; gap: 0; flex: 1; }

.sidebar {
  background: var(--bg); border-right: 1px solid var(--border);
  padding: 24px 18px; display: flex; flex-direction: column; gap: 18px;
}
.sidebar__user {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 8px 14px; border-bottom: 1px solid var(--border);
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--bg-sunken); color: var(--text-muted);
  display: grid; place-items: center;
  overflow: hidden; flex: 0 0 auto;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sidebar__name { font-weight: 700; }
.sidebar__nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar__nav a {
  padding: 9px 12px; border-radius: var(--radius-md);
  color: var(--text-muted); font-weight: 500;
}
.sidebar__nav a:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.sidebar__nav a.is-active { background: var(--bg-sunken); color: var(--text); font-weight: 600; }
.sidebar__logout { margin-top: auto; }
.sidebar__logout .link {
  background: none; border: 0; color: var(--text-muted); cursor: pointer;
  padding: 6px 8px;
}
.sidebar__logout .link:hover { color: var(--text); text-decoration: underline; }

.content { padding: 40px 48px; max-width: 1040px; }
.page__title { font-size: 2.2rem; margin: 0 0 28px; letter-spacing: -.015em; }

.content .card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 36px 40px; box-shadow: var(--shadow-sm);
  max-width: 860px;
}
.card__title { margin: 0 0 24px; font-size: 1.45rem; letter-spacing: -.005em; }

.kv {
  display: grid; grid-template-columns: 200px 1fr; row-gap: 18px; column-gap: 24px;
  margin: 0; font-size: 1.1rem;
}
.kv dt { color: var(--text-muted); font-size: 1.05rem; }
.kv dd { margin: 0; font-weight: 600; font-size: 1.15rem; }
.kv code { font-size: 1.05rem; padding: 4px 10px; }
.prose { font-size: 1.08rem; line-height: 1.65; }
.page__lede { color: var(--text-muted); font-size: 1.08rem; max-width: 720px; margin: -10px 0 22px; }

/* ----- Reviews ----- */
.reviews { display: grid; gap: 16px; max-width: 860px; }
.review {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 22px 26px; box-shadow: var(--shadow-sm);
}
.review__head { display: flex; align-items: center; gap: 14px; }
.review__avatar {
  width: 52px; height: 52px; border-radius: 50%; overflow: hidden;
  background: var(--bg-sunken); display: grid; place-items: center; flex: 0 0 auto;
}
.review__avatar img { width: 100%; height: 100%; object-fit: cover; }
.review__initial { color: var(--text-muted); font-weight: 700; font-size: 1.2rem; }
.review__who { flex: 1; min-width: 0; }
.review__name { font-weight: 700; font-size: 1.05rem; }
.review__date { font-size: 0.88rem; }
.review__rating { letter-spacing: 2px; }
.star { color: #d6dbe5; font-size: 1.1rem; }
.star--on { color: #f5a623; }
.review__body { margin: 14px 0 0; color: var(--text); line-height: 1.6; }

/* ----- News ----- */
.news { display: grid; gap: 18px; max-width: 860px; }
.news-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px 28px; box-shadow: var(--shadow-sm);
}
.news-item__date { font-size: 0.88rem; margin-bottom: 6px; font-family: var(--font-mono); }
.news-item__title { margin: 0 0 12px; font-size: 1.35rem; letter-spacing: -0.01em; }
.news-item__body { margin: 0; }
.markdown { line-height: 1.65; color: var(--text); font-size: 1.05rem; }
.markdown p { margin: 0 0 14px; }
.markdown p:last-child { margin-bottom: 0; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 { margin: 22px 0 10px; line-height: 1.3; letter-spacing: -.01em; }
.markdown h1 { font-size: 1.4rem; }
.markdown h2 { font-size: 1.2rem; }
.markdown h3 { font-size: 1.05rem; }
.markdown ul, .markdown ol { margin: 0 0 14px; padding-left: 26px; }
.markdown li { margin: 4px 0; }
.markdown a { color: var(--primary); text-decoration: underline; text-decoration-thickness: 1px; }
.markdown a:hover { text-decoration-thickness: 2px; }
.markdown code {
  background: var(--bg-sunken); padding: 2px 6px; border-radius: 4px;
  font-family: var(--font-mono); font-size: 0.92em;
}
.markdown pre {
  background: var(--bg-sunken); padding: 14px 16px; border-radius: 8px;
  overflow: auto; margin: 0 0 14px;
}
.markdown pre code { background: none; padding: 0; }
.markdown blockquote {
  border-left: 3px solid var(--border-strong); padding: 4px 0 4px 14px;
  color: var(--text-muted); margin: 0 0 14px;
}
.markdown img { max-width: 100%; border-radius: 8px; margin: 8px 0; }
.markdown hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }

.form__row { display: flex; gap: 16px; }
.form__row--two { grid-template-columns: 1fr 1fr; display: grid; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { color: var(--text-muted); font-size: .92rem; font-weight: 600; }
.field input, .field textarea {
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  padding: 11px 12px; background: white;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus, .field textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(11,92,255,.15);
}
.field input.is-invalid {
  border-color: var(--danger); box-shadow: 0 0 0 3px rgba(210,69,69,.2);
}
.field__readonly {
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  padding: 11px 12px; background: var(--bg-soft); color: var(--text);
  min-height: calc(1.5em + 22px);
  user-select: text;
  transition: background-color .35s ease, border-color .35s ease;
}
.field__readonly.is-flashing {
  animation: readonlyFlash 1.6s ease-out;
}
@keyframes readonlyFlash {
  0%   { background: rgba(34, 197, 94, .25); border-color: rgba(34,197,94,.6); }
  100% { background: var(--bg-soft); border-color: var(--border-strong); }
}
.form__actions { margin-top: 18px; }
.form__actions--split {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.autosave { font-size: 0.92rem; color: var(--text-muted); min-height: 1.2em; transition: color .15s ease; }
.autosave.is-pending { color: var(--text-muted); }
.autosave.is-ok { color: var(--ok); font-weight: 600; }
.autosave.is-err { color: var(--danger); font-weight: 600; }

.access-pill--hero {
  position: relative; overflow: hidden;
  padding: 14px 28px;
  font-size: 1rem;
  background: linear-gradient(180deg, #2d6cff 0%, #0b3eb5 100%);
  color: #fff;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.18);
  box-shadow:
    0 0 0 4px rgba(45,108,255,.12),
    0 12px 28px rgba(11,62,181,.45),
    inset 0 1px 0 rgba(255,255,255,.18);
  animation: accessPulse 2.4s ease-in-out infinite;
}
.access-pill--hero:hover {
  filter: brightness(1.08);
  box-shadow:
    0 0 0 6px rgba(45,108,255,.18),
    0 14px 34px rgba(11,62,181,.55),
    inset 0 1px 0 rgba(255,255,255,.22);
}
.access-pill__glow {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(120deg, transparent 0%, rgba(255,255,255,.45) 50%, transparent 100%);
  transform: translateX(-120%);
  animation: accessShine 2.8s ease-in-out infinite;
}
@keyframes accessPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(45,108,255,.12), 0 12px 28px rgba(11,62,181,.45), inset 0 1px 0 rgba(255,255,255,.18); }
  50%      { box-shadow: 0 0 0 8px rgba(45,108,255,.22), 0 16px 36px rgba(11,62,181,.55), inset 0 1px 0 rgba(255,255,255,.22); }
}
@keyframes accessShine {
  0%   { transform: translateX(-120%); }
  60%  { transform: translateX(120%); }
  100% { transform: translateX(120%); }
}
@media (prefers-reduced-motion: reduce) {
  .access-pill--hero, .access-pill__glow { animation: none; }
}
.form__error {
  background: #fdecec; color: #9a2222; border: 1px solid #f3b9b9;
  padding: 10px 12px; border-radius: var(--radius-md); font-size: .92rem; margin-bottom: 14px;
}
.form__ok {
  background: #e8f7ee; color: #186434; border: 1px solid #b9e3c7;
  padding: 10px 12px; border-radius: var(--radius-md); font-size: .92rem; margin-bottom: 14px;
}
.prose { white-space: pre-wrap; color: var(--text); margin: 0; }

.modal { position: fixed; inset: 0; display: grid; place-items: center; z-index: 100; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(15,18,22,.45); backdrop-filter: blur(2px); }
.modal__panel {
  position: relative; background: white; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 28px; max-width: 460px; width: calc(100% - 40px);
  animation: pop .18s ease-out;
}
.modal__panel h2 { margin: 0 0 10px; }
.modal__panel p { margin: 0 0 20px; color: var(--text-muted); }
.modal__actions { display: flex; justify-content: flex-end; }
@keyframes pop {
  from { transform: translateY(8px) scale(.98); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

/* ==========================================================================
   PROFILE AVATAR — upload area on /account/me
   ========================================================================== */
.profile-avatar {
  display: flex; align-items: center; gap: 22px;
  padding: 4px 0 22px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.profile-avatar__display {
  width: 88px; height: 88px; border-radius: 50%;
  background: var(--bg-sunken);
  display: grid; place-items: center;
  overflow: hidden; flex: 0 0 auto;
  border: 2px solid var(--border);
}
.profile-avatar__img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-avatar__initial {
  font-size: 2rem; font-weight: 700; color: var(--text-muted);
  letter-spacing: -.02em;
}
.profile-avatar__controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  flex: 1 1 220px;
}
.profile-avatar__hint {
  flex: 1 1 100%;
  font-size: 0.82rem; color: var(--text-faint); margin: 4px 0 0;
}
.profile-avatar__status {
  font-size: 0.85rem; color: var(--text-muted); min-height: 1.2em;
}
.profile-avatar__status.is-pending { color: var(--text-muted); }
.profile-avatar__status.is-ok      { color: var(--ok); font-weight: 600; }
.profile-avatar__status.is-err     { color: var(--danger); font-weight: 600; }
.profile-avatar__remove { color: var(--danger); }
.profile-avatar__remove:hover { background: rgba(210,69,69,.06); }

@media (max-width: 760px) {
  .profile-avatar { gap: 16px; padding-bottom: 18px; margin-bottom: 18px; }
  .profile-avatar__display { width: 72px; height: 72px; }
  .profile-avatar__initial { font-size: 1.6rem; }
}

/* ==========================================================================
   ABOUT page — hero card + facts list
   ========================================================================== */
.about-hero {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  max-width: 860px;
}
.about-hero__tag {
  color: var(--primary); font-size: 0.78rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  margin: 0 0 10px;
}
.about-hero__title {
  margin: 0 0 14px; font-size: 1.45rem; font-weight: 700; line-height: 1.3;
  letter-spacing: -.01em;
}
.about-hero__body {
  margin: 0; color: var(--text); font-size: 1.05rem; line-height: 1.7;
  white-space: pre-wrap;
}
.about-facts {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); overflow: hidden;
  max-width: 860px;
}
.about-fact {
  display: grid; grid-template-columns: 140px 1fr;
  gap: 14px; padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.about-fact:last-child { border-bottom: 0; }
.about-fact__label {
  color: var(--text-muted); font-size: 0.78rem;
  font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  align-self: center;
}
.about-fact__value { color: var(--text); font-size: 1.02rem; font-weight: 600; }

/* ==========================================================================
   NEWS — accent the latest item
   ========================================================================== */
.news-item--latest {
  border-top: 3px solid var(--primary);
  padding-top: 26px;
}
.news-item__pill { display: none; } /* hidden on non-latest items */
.news-item--latest .news-item__pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(11,92,255,.10); color: var(--primary);
  font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  padding: 4px 12px; border-radius: 999px;
  margin: 0 0 12px;
}
.news-item--latest .news-item__title { font-size: 1.5rem; line-height: 1.25; }

/* ==========================================================================
   Page footer line — fills the bottom of short pages, gives closure.
   ========================================================================== */
.page-foot {
  text-align: center; color: var(--text-faint);
  font-size: 0.78rem; padding: 28px 0 8px;
  letter-spacing: 0.04em;
}

/* ==========================================================================
   BOTTOM TAB BAR — mobile only (>760px = hidden via display:none default)
   Pattern: Airbnb-style. 5 tabs, fixed at viewport bottom, blue active state
   with a small underline above the icon.
   ========================================================================== */
.tabbar {
  display: none; /* shown via media query at ≤760px */
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  grid-template-columns: repeat(5, 1fr);
  background: var(--bg);
  border-top: 1px solid var(--border);
  /* iOS safe-area cushion (notch / home indicator) */
  padding: 6px 0 calc(10px + env(safe-area-inset-bottom));
  box-shadow: 0 -1px 12px rgba(15,18,22,.04);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 6px 4px;
  text-decoration: none; color: var(--text-muted);
  font-size: 0.68rem; font-weight: 500;
  letter-spacing: 0.01em;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.tabbar a:hover { text-decoration: none; color: var(--text); }
.tabbar a svg { width: 22px; height: 22px; stroke-width: 1.7; }
.tabbar a.is-active { color: var(--primary); font-weight: 600; }
.tabbar a.is-active svg { stroke-width: 2; }
.tabbar a.is-active::before {
  content: ''; position: absolute; top: 0; left: 50%;
  transform: translateX(-50%);
  width: 24px; height: 2px;
  background: var(--primary); border-radius: 0 0 2px 2px;
}

/* ==========================================================================
   Mobile breakpoint (≤760px) — hide the desktop sidebar, surface the tab bar.
   ========================================================================== */
@media (max-width: 760px) {
  .topbar { padding: 12px 14px; gap: 10px; }
  .topbar__brand { font-size: 0.95rem; min-width: 0; }
  .topbar__brand .brand__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar__logout-form { display: block; }
  .access-pill { padding: 10px 16px; font-size: 0.92rem; width: 100%; }

  /* Sidebar replaced by bottom tabbar */
  .layout { display: block; flex: 0 0 auto; }
  .sidebar { display: none; }
  .tabbar { display: grid; }

  /* Reserve space at the bottom of content so the fixed tabbar doesn't
     cover the last items. ~64px tab + safe-area inset. */
  .content {
    padding: 22px 16px calc(80px + env(safe-area-inset-bottom));
    max-width: 100%;
  }
  .page__title { font-size: 1.55rem; margin-bottom: 18px; }
  .content .card { padding: 22px 20px; max-width: 100%; }
  .card__title { font-size: 1.15rem; margin-bottom: 16px; }
  .form__row--two { grid-template-columns: 1fr; }
  /* Lock inputs to card width — without min-width:0 grid items can blow past 100% */
  .field { min-width: 0; }
  .field input, .field textarea, .field__readonly {
    width: 100%; box-sizing: border-box; min-width: 0; padding: 10px 12px;
  }
  .kv {
    grid-template-columns: 120px 1fr; row-gap: 12px; column-gap: 14px;
    font-size: 1rem;
  }
  .kv dt { font-size: 0.95rem; }
  .kv dd { font-size: 1.02rem; word-break: break-word; min-width: 0; }
  .kv code { font-size: 0.95rem; padding: 3px 8px; word-break: break-all; }
  .prose { font-size: 1rem; }

  .reviews, .news { max-width: 100%; }
  .review, .news-item { padding: 18px 16px; }
  .review__head { flex-wrap: wrap; }

  .modal__panel { padding: 22px; border-radius: 12px; }
  .modal__panel h2 { font-size: 1.2rem; }
  .form__actions--split { flex-direction: column; align-items: stretch; }
  .form__actions--split .btn,
  .form__actions--split .access-pill--hero { width: 100%; }

  /* About — tighter hero + 2-col facts at narrow widths */
  .about-hero { padding: 18px 18px 18px 20px; }
  .about-hero__title { font-size: 1.2rem; }
  .about-hero__body { font-size: 1rem; }
  .about-fact { grid-template-columns: 110px 1fr; padding: 14px 16px; gap: 10px; }
  .about-fact__value { font-size: 0.96rem; }

  /* News latest — slightly smaller hero title on phone */
  .news-item--latest .news-item__title { font-size: 1.3rem; }
}

/* iPhone-class screens (393px etc.) — tighter still */
@media (max-width: 440px) {
  .topbar { padding: 10px 12px; }
  .brand__name { font-size: 0.9rem; }
  .sidebar { padding: 12px 12px 14px; }
  .sidebar__nav a { padding: 7px 10px; font-size: 0.88rem; }

  .content { padding: 18px 12px; }
  .page__title { font-size: 1.35rem; margin-bottom: 14px; letter-spacing: 0; }
  .content .card { padding: 16px 14px; }
  .card__title { font-size: 1.05rem; margin-bottom: 12px; }

  .kv { grid-template-columns: 96px 1fr; column-gap: 10px; row-gap: 10px; font-size: 0.95rem; }
  .kv dt { font-size: 0.85rem; }
  .kv dd { font-size: 0.95rem; }

  .review { padding: 14px 14px; }
  .review__avatar { width: 44px; height: 44px; }
  .review__name { font-size: 1rem; }
  .review__rating { letter-spacing: 1px; }
  .star { font-size: 1rem; }

  .news-item { padding: 16px 14px; }
  .news-item__title { font-size: 1.1rem; }
  .markdown { font-size: 0.98rem; }

  .modal__panel { padding: 18px 16px; }
  .modal__panel h2 { font-size: 1.1rem; }
  .modal__panel p { font-size: 0.95rem; }

  .access-pill--hero { padding: 12px 18px; font-size: 0.95rem; }
}
