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

:root {
  --bg:          #f0f4f8;
  --surface:     #ffffff;
  --header-bg:   #0f172a;
  --accent:      #3b82f6;
  --accent-dim:  #1d4ed8;
  --warm:        #f59e0b;
  --text:        #1e293b;
  --muted:       #64748b;
  --border:      #e2e8f0;
  --radius-sm:   8px;
  --radius:      14px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.07), 0 2px 8px rgba(0,0,0,.05);
  --shadow:      0 2px 8px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.07);
  --transition:  .18s ease;
  --shell-max-width: 1280px;
  --shell-inline-padding: 1.5rem;
  --shell-block-start: 2rem;
  --shell-block-end: 4rem;
  --shell-gap: 1.5rem;
  --panel-padding: 2rem;
  --shell-sidebar-width: 280px;
  --help-sidebar-width: 320px;
}

@media (max-width: 1200px) {
  :root {
    --shell-inline-padding: 1.375rem;
    --shell-gap: 1.375rem;
    --panel-padding: 1.875rem;
    --shell-sidebar-width: 268px;
    --help-sidebar-width: 300px;
  }
}

@media (max-width: 1024px) {
  :root {
    --shell-inline-padding: 1.25rem;
    --shell-gap: 1.25rem;
    --panel-padding: 1.75rem;
    --shell-sidebar-width: 248px;
    --help-sidebar-width: 280px;
  }
}

@media (max-width: 900px) {
  :root {
    --shell-inline-padding: 1rem;
    --shell-block-start: 1.5rem;
    --shell-block-end: 3rem;
    --shell-gap: 1.125rem;
    --panel-padding: 1.5rem;
  }
}

@media (max-width: 768px) {
  :root {
    --shell-inline-padding: 0.875rem;
    --shell-gap: 1rem;
    --panel-padding: 1.25rem;
  }
}

@media (max-width: 640px) {
  :root {
    --shell-inline-padding: 0.75rem;
    --shell-block-start: 1rem;
    --shell-block-end: 2.5rem;
    --shell-gap: 0.9rem;
    --panel-padding: 1rem;
  }
}

@media (max-width: 420px) {
  :root {
    --shell-inline-padding: 0.625rem;
    --shell-gap: 0.8rem;
    --panel-padding: 0.875rem;
  }
}

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img,
svg,
video,
canvas {
  max-width: 100%;
}

/* ── Internal header ── */
.internal-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  padding-inline: var(--shell-inline-padding);
  height: 60px;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 2px 16px rgba(0,0,0,.3);
}
.internal-header .logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.3px;
  text-decoration: none;
}
.internal-header .logo span { color: var(--warm); }
.internal-header .subtitle {
  font-size: .78rem;
  color: #94a3b8;
  margin-top: 1px;
}
.internal-header .spacer { flex: 1; }
.internal-header .header-btn {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  color: #cbd5e1;
  padding: .4rem .9rem;
  border-radius: var(--radius-sm);
  font-size: .8rem;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.internal-header > * {
  min-width: 0;
}
.internal-header .header-btn--submit {
  font: inherit;
}
.internal-header .header-btn:hover { background: rgba(255,255,255,.15); color: #fff; }
.internal-header .header-btn.active { background: rgba(59,130,246,.25); border-color: rgba(59,130,246,.4); color: #93c5fd; }
.header-form {
  margin: 0;
}

/* ── Product shell ── */
.product-header {
  position: sticky;
  top: 0;
  z-index: 90;
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.product-header__inner,
.site-footer__inner {
  width: min(100%, var(--shell-max-width));
  margin: 0 auto;
  padding-inline: var(--shell-inline-padding);
}

.product-header__inner {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.product-header__inner > *,
.site-footer__inner > * {
  min-width: 0;
}

.product-brand {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  text-decoration: none;
}

.product-brand__name {
  color: #0f172a;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.product-brand__tagline {
  color: var(--muted);
  font-size: 0.85rem;
}

.product-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex: 1 1 auto;
  min-width: 0;
}

.product-nav__link {
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.product-nav__link.active,
.product-nav__link:hover {
  color: var(--accent-dim);
}

.product-header__actions {
  display: flex;
  align-items: center;
  margin-left: auto;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.product-header__form {
  margin: 0;
  position: relative;
  z-index: 1;
}

.product-header__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  border: 0;
  font: inherit;
  cursor: pointer;
  position: relative;
  z-index: 1;
}

.product-header__button:hover {
  background: var(--accent-dim);
}

.product-header__button--secondary {
  background: #e2e8f0;
  color: var(--text);
}

.product-header__button--secondary:hover {
  background: #cbd5e1;
}

.user-menu {
  position: relative;
}

.user-menu__trigger {
  min-width: 44px;
  padding: 0.7rem;
}

.user-menu__trigger svg {
  width: 20px;
  height: 20px;
}

.user-menu__panel {
  position: absolute;
  top: calc(100% + 0.75rem);
  right: 0;
  min-width: 220px;
  padding: 0.5rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
  display: grid;
  gap: 0.25rem;
}

.user-menu__panel[hidden] {
  display: none !important;
}

.user-menu__link,
.user-menu__logout {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 42px;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
}

.user-menu__link:hover,
.user-menu__logout:hover {
  background: #f8fafc;
}

.user-menu__form {
  margin: 0;
  padding-top: 0.25rem;
  border-top: 1px solid var(--border);
}

.user-menu__logout {
  color: #b42318;
}

.site-footer {
  border-top: 1px solid var(--border);
  background: #fff;
  flex-shrink: 0;
}

.site-footer__inner {
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
}

.site-footer__title {
  font-weight: 800;
  font-size: 1rem;
  color: #0f172a;
  margin-bottom: 0.45rem;
}

.site-footer__copy {
  max-width: 42rem;
  color: var(--muted);
  line-height: 1.55;
}

.site-footer__links {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  min-width: 0;
}

.site-footer__links a {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.site-footer__form {
  margin: 0;
}

.site-footer__form button {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  background: transparent;
  border: 0;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

.site-footer__links a:hover,
.site-footer__form button:hover {
  color: var(--accent-dim);
}

/* ── Header nav + hamburger ── */
.header-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
  flex-wrap: wrap;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 42px;
  padding: 0.72rem 1rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: #e2e8f0;
  color: #0f172a;
  font: inherit;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform var(--transition),
    background var(--transition),
    color var(--transition),
    border-color var(--transition),
    box-shadow var(--transition);
  box-shadow: var(--shadow-sm);
}

.action-btn:hover {
  transform: translateY(-1px);
}

.action-btn:focus-visible {
  outline: 3px solid rgba(59, 130, 246, 0.18);
  outline-offset: 2px;
}

.action-btn:disabled,
.action-btn[aria-busy="true"] {
  cursor: wait;
  opacity: 0.72;
  transform: none;
}

.action-btn--create {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
}

.action-btn--create:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
}

.action-btn--edit {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #fff;
}

.action-btn--edit:hover {
  background: linear-gradient(135deg, #111827 0%, #0f172a 100%);
}

.action-btn--secondary {
  background: #fff;
  border-color: #cbd5e1;
  color: #334155;
}

.action-btn--secondary:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.action-btn--success {
  background: linear-gradient(135deg, #15803d 0%, #166534 100%);
  color: #fff;
}

.action-btn--success:hover {
  background: linear-gradient(135deg, #166534 0%, #14532d 100%);
}

.action-btn--destructive {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  color: #fff;
}

.action-btn--destructive:hover {
  background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%);
}

.action-btn--soft {
  box-shadow: none;
}

.action-btn--soft.action-btn--destructive {
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.2);
  color: #b42318;
}

.action-btn--soft.action-btn--destructive:hover {
  background: rgba(220, 38, 38, 0.14);
}

.action-btn--soft.action-btn--secondary {
  background: rgba(148, 163, 184, 0.08);
}

.app-toast-stack {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: grid;
  gap: 0.75rem;
  width: min(30rem, calc(100vw - 2rem));
  pointer-events: none;
}

.app-toast {
  display: grid;
  gap: 0.2rem;
  padding: 0.85rem 1rem;
  border-radius: 18px;
  border: 1px solid transparent;
  background: #fff;
  color: #0f172a;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
  pointer-events: auto;
  transform: translateY(-0.4rem);
  opacity: 0;
  transition: opacity 180ms ease, transform 180ms ease;
}

.app-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.app-toast--success {
  background: #f0fdf4;
  border-color: rgba(22, 101, 52, 0.18);
  color: #166534;
}

.app-toast--warning {
  background: #fffbeb;
  border-color: rgba(180, 83, 9, 0.18);
  color: #b45309;
}

.app-toast--error {
  background: #fef2f2;
  border-color: rgba(185, 28, 28, 0.18);
  color: #b91c1c;
}

.app-toast__title {
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.app-toast__message {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 600;
  line-height: 1.45;
}

.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius-sm);
  padding: .45rem .55rem;
  cursor: pointer;
  flex-shrink: 0;
}
.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: #cbd5e1;
  border-radius: 2px;
  transition: var(--transition);
}

@media (max-width: 480px) {
  .internal-header {
    flex-wrap: wrap;
    height: auto;
    padding: .6rem 1rem;
    gap: .5rem;
  }
  .internal-header > div:first-child { flex: 1; }
  .hamburger { display: flex; }
  .header-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: .4rem;
    padding-bottom: .4rem;
  }
  .header-nav.open { display: flex; }
  .header-nav .header-btn { justify-content: center; }
}

@media (max-width: 900px) {
  .product-header__inner,
  .site-footer__inner {
    padding-inline: var(--shell-inline-padding);
  }

  .product-header__inner {
    min-height: auto;
    padding-top: 1rem;
    padding-bottom: 1rem;
    flex-direction: column;
    align-items: flex-start;
  }

  .product-nav {
    flex-wrap: wrap;
    gap: 0.8rem 1rem;
    width: 100%;
  }

  .product-header__actions {
    width: 100%;
  }

  .product-header__form {
    width: 100%;
  }

  .product-header__button {
    width: 100%;
  }

  .site-footer__inner {
    flex-direction: column;
  }

  .site-footer__links {
    width: 100%;
  }
}

/* ── Main layout ── */
main {
  flex: 1 0 auto;
  width: min(100%, var(--shell-max-width));
  margin: 0 auto;
  padding: var(--shell-block-start) var(--shell-inline-padding) var(--shell-block-end);
}

main > * {
  min-width: 0;
}
