/* ==========================================================================
   Dynamic Dexter Home Hub
   Shares its design tokens and components with TV Tracker / Movie Tracker
   ========================================================================== */

/* ==========================================================================
   Design tokens
   ========================================================================== */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #f7f8fa;
  --panel-3: #eef1f5;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --border: #e2e6ec;
  --border-strong: #cdd4dd;

  --brand: #ff7828;
  --brand-strong: #e8620f;
  --brand-ink: #b84a08;
  --brand-soft: rgba(255, 120, 40, 0.12);
  --brand-ring: rgba(255, 120, 40, 0.32);

  --navy: #0f172a;
  --navy-2: #1e293b;
  --danger: #c0362c;
  --danger-soft: rgba(192, 54, 44, 0.1);
  --success: #1c8a4a;

  --btn-bg: var(--navy);
  --btn-fg: #ffffff;
  --btn-hover: var(--brand);
  --focus: var(--brand);

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -2px rgba(15, 23, 42, 0.05), 0 10px 24px -6px rgba(15, 23, 42, 0.1);
  --shadow-lg: 0 24px 48px -12px rgba(15, 23, 42, 0.28);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* ==========================================================================
   Base
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 96px;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1,
h2,
h3 {
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: var(--text);
}

h1 {
  font-size: clamp(1.6rem, 1.2rem + 1.2vw, 2rem);
  font-weight: 800;
}

h2 {
  font-size: 1.15rem;
  font-weight: 700;
}

p {
  margin: 0 0 1em;
}

a {
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

strong {
  font-weight: 700;
}

svg {
  flex: 0 0 auto;
}

/* Inline stroke icons */
.btn svg,
.header-link svg,
.header-icon-btn svg,
.search-field svg,
.back-to-top svg,
.chip svg,
.section-icon svg,
.hero-chip svg,
.hero-word-key svg,
.app-arrow,
.password-icon,
.empty-icon {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn svg {
  width: 18px;
  height: 18px;
}

input[type="checkbox"] {
  accent-color: var(--brand);
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
  flex: 0 0 auto;
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--panel);
  color: var(--text-2);
  font: 600 0.78em/1.4 var(--font);
  text-align: center;
}

mark {
  background: var(--brand-soft);
  color: var(--brand-ink);
  border-radius: 3px;
}

.wrap {
  width: min(1240px, 92%);
  margin: 0 auto;
}

.muted {
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 2000;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--navy);
  color: #fff;
  font-weight: 600;
}

.skip-link:focus {
  top: 12px;
}

/* ==========================================================================
   Header
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  padding-top: env(safe-area-inset-top);
  background: rgba(244, 245, 247, 0.82);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.header-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "brand nav account";
  align-items: center;
  gap: 24px;
  padding: 10px 0;
}

.header-row.is-guest {
  grid-template-columns: 1fr;
  grid-template-areas: "brand";
  justify-items: center;
}

.brand {
  grid-area: brand;
  display: block;
  height: 56px;
}

.header-row:not(.is-guest) .brand {
  justify-self: start;
}

.brand-logo {
  display: block;
  height: 100%;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

/* Primary navigation: segmented pill group */
.header-nav {
  grid-area: nav;
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}

.header-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.header-link svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
  transition: color 0.15s ease;
}

.header-link:hover {
  background: var(--panel-3);
  color: var(--text);
}

.header-link:hover svg {
  color: var(--text);
}

.header-link.is-active {
  background: var(--navy);
  color: #fff;
}

.header-link.is-active svg {
  color: var(--brand);
}

/* Account: profile chip + log out */
.header-account {
  grid-area: account;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-profile {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 3px 14px 3px 3px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.header-profile:hover {
  border-color: var(--brand-ring);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.header-profile.is-active {
  border-color: var(--brand);
}

.header-profile-name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-logout-form {
  display: flex;
  margin: 0;
}

.header-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-2);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}

.header-icon-btn svg {
  width: 18px;
  height: 18px;
}

.header-logout:hover {
  background: var(--danger-soft);
  border-color: var(--danger-soft);
  color: var(--danger);
}

/* Avatars: a visible <img> hides the initial fallback that follows it */
.avatar-wrap {
  display: inline-flex;
  flex: 0 0 auto;
}

.avatar-wrap img:not([hidden]) + .avatar-fallback {
  display: none;
}

.avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brand), #ff9a52);
  color: #fff;
  font-weight: 700;
  user-select: none;
}

.header-avatar {
  border-radius: 999px;
}

.header-avatar-img {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  object-fit: cover;
  font-size: 0.9rem;
}

/* ==========================================================================
   Layout shell
   ========================================================================== */
main.wrap {
  flex: 1 0 auto;
  padding: 28px 0 56px;
}

.hub-footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.88rem;
  padding: 18px 0 calc(18px + env(safe-area-inset-bottom));
  margin-top: auto;
}

.hub-footer-inner {
  display: flex;
  justify-content: center;
  text-align: center;
}

.back-to-top {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease,
    background 0.18s ease,
    visibility 0.18s ease;
  z-index: 1100;
}

.back-to-top svg {
  width: 20px;
  height: 20px;
}

.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--brand);
}

/* ==========================================================================
   Flash messages
   ========================================================================== */
.flash {
  margin-bottom: 20px;
  padding: 12px 16px 12px 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  border-left-width: 4px;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 0.28s ease,
    transform 0.28s ease,
    margin 0.28s ease,
    padding 0.28s ease;
}

.flash.is-hiding {
  opacity: 0;
  transform: translateY(-4px);
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  pointer-events: none;
}

.flash-success {
  background: #f0faf4;
  border-color: rgba(28, 138, 74, 0.25);
  border-left-color: var(--success);
  color: #17643a;
}

.flash-error {
  background: #fdf3f2;
  border-color: rgba(192, 54, 44, 0.25);
  border-left-color: var(--danger);
  color: #8a241d;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--btn-bg);
  border-radius: 12px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: var(--shadow-sm);
  transition:
    transform 0.08s ease,
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease;
}

.btn:hover {
  background: var(--btn-hover);
  border-color: var(--btn-hover);
  color: #fff;
}

.btn:active {
  transform: translateY(1px);
}

.btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn.secondary {
  background: var(--panel);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn.secondary:hover {
  background: var(--panel);
  border-color: var(--brand);
  color: var(--brand-ink);
}

.btn-block {
  width: 100%;
}

.btn-link {
  padding: 4px 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-link:hover {
  color: var(--brand-ink);
  background: var(--brand-soft);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ==========================================================================
   Cards + headings
   ========================================================================== */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.card h1,
.card h2 {
  margin: 0 0 8px;
}

.card-head-meta {
  font-size: 0.88rem;
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand-strong);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
}

.narrow {
  max-width: 440px;
}

.empty {
  display: grid;
  justify-items: center;
  text-align: center;
  padding: 48px 24px;
  margin-bottom: 24px;
}

.empty p {
  max-width: 420px;
}

.empty-icon {
  width: 44px;
  height: 44px;
  color: var(--brand);
  margin-bottom: 8px;
}

/* ==========================================================================
   Forms
   ========================================================================== */
.stack {
  display: grid;
  gap: 12px;
}

label {
  font-weight: 600;
  font-size: 0.93rem;
  color: var(--text-2);
}

input[type="text"],
input[type="password"],
input[type="search"] {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

input::placeholder {
  color: #94a0b0;
}

input[type="text"]:hover,
input[type="password"]:hover,
input[type="search"]:hover {
  border-color: #b5bfcb;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="search"]:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-ring);
}

input:disabled {
  background: var(--panel-2);
  color: var(--muted);
  cursor: not-allowed;
}

.search-field {
  position: relative;
  width: 100%;
}

.search-field > svg {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.search-field input {
  padding-left: 42px;
}

.form-help {
  margin: 6px 0 0;
  font-size: 0.86rem;
}

.form-help-tight {
  margin-top: -6px;
}

.form-help-top {
  margin: 0 0 14px;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  cursor: pointer;
}

.file-input {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 0.92rem;
  color: var(--muted);
  padding: 10px;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  background: var(--panel-2);
  cursor: pointer;
}

.file-input::file-selector-button {
  margin-right: 12px;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.file-input:hover::file-selector-button {
  border-color: var(--brand);
}

/* Password reveal */
.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 3.2em;
}

.password-toggle {
  position: absolute;
  top: 1px;
  bottom: 1px;
  right: 1px;
  background: transparent;
  border: none;
  padding: 0 0.7em;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  border-radius: 0 11px 11px 0;
  transition: color 0.15s ease;
}

.password-icon {
  display: block;
  width: 20px;
  height: 20px;
}

.password-icon--hide,
.password-toggle.is-revealed .password-icon--show {
  display: none;
}

.password-toggle.is-revealed .password-icon--hide {
  display: block;
}

.password-toggle:hover,
.password-toggle.is-revealed {
  color: var(--brand-strong);
}

.password-toggle:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -4px;
}

/* ==========================================================================
   Auth (login / register)
   ========================================================================== */
.auth-card {
  width: 100%;
  margin: 0 auto;
  padding: 32px;
  box-shadow: var(--shadow-md);
}

.auth-card h1 {
  font-size: 1.75rem;
  margin-bottom: 4px;
}

.auth-lead {
  color: var(--muted);
  margin: 0;
  min-height: 1.55em;
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
}

.auth-lead.is-swapping {
  opacity: 0;
  transform: translateY(-3px);
}

.auth-error {
  margin: 18px 0 0;
  box-shadow: none;
  font-size: 0.93rem;
}

.auth-form {
  margin-top: 22px;
}

.auth-actions {
  display: grid;
  gap: 14px;
  margin-top: 10px;
}

.auth-switch {
  margin: 0;
  text-align: center;
  font-size: 0.93rem;
  color: var(--muted);
}

.auth-switch a {
  color: var(--brand-ink);
  font-weight: 600;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.is-login-scene main.wrap {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  align-content: center;
}

.is-login-scene main.wrap::before {
  content: "";
  position: fixed;
  inset: 70px -16vw -8vh -16vw;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(40% 30% at 18% 22%, rgba(255, 120, 40, 0.2), transparent 70%),
    radial-gradient(36% 26% at 78% 28%, rgba(15, 23, 42, 0.12), transparent 70%),
    radial-gradient(45% 36% at 52% 74%, rgba(255, 120, 40, 0.13), transparent 72%);
  filter: blur(26px);
  animation: loginAmbientDrift 12s ease-in-out infinite alternate;
}

.is-login-scene .flash {
  width: min(440px, 100%);
}

.login-card {
  position: relative;
  overflow: hidden;
}

.login-title {
  display: inline-block;
}

.login-title.is-tuning {
  animation: loginTitleTuneIn 0.58s ease-out both;
}

.btn[data-login-submit].is-submitting {
  background: linear-gradient(90deg, var(--btn-bg), #22345e, var(--btn-bg));
  background-size: 220% 100%;
  animation: loginSubmitSweep 1s linear infinite;
}

@keyframes loginAmbientDrift {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(0, -8px, 0) scale(1.03);
  }
}

@keyframes loginTitleTuneIn {
  0% {
    opacity: 0;
    transform: translateY(-2px) scale(1.01);
    filter: blur(6px);
  }
  45% {
    opacity: 1;
    transform: translateY(0) scale(1.005);
    filter: blur(0);
  }
  58% {
    transform: translateX(-1px);
  }
  76% {
    transform: translateX(1px);
  }
  100% {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

@keyframes loginSubmitSweep {
  from {
    background-position: 0% 50%;
  }
  to {
    background-position: 220% 50%;
  }
}

/* ==========================================================================
   Home: hero
   ========================================================================== */
.home-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 20px;
  padding: 32px;
  border-radius: var(--radius-lg);
  color: #e2e8f0;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(255, 120, 40, 0.28), transparent 55%),
    radial-gradient(80% 120% at 0% 100%, rgba(56, 89, 160, 0.35), transparent 60%),
    var(--navy);
  box-shadow: var(--shadow-md);
}

.home-hero-main {
  min-width: 0;
  flex: 1 1 auto;
  display: grid;
  gap: 18px;
}

.home-user-row {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.home-avatar-wrap {
  border-radius: 999px;
  transition: transform 0.15s var(--ease);
}

.home-avatar-wrap:hover {
  transform: scale(1.04);
}

.home-avatar {
  width: 64px;
  height: 64px;
  border-radius: 999px;
  object-fit: cover;
  border: 3px solid rgba(255, 255, 255, 0.9);
  font-size: 1.5rem;
}

.home-user-text {
  min-width: 0;
}

.home-eyebrow {
  margin: 0 0 2px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #ffa66e;
}

.home-user-greeting {
  margin: 0;
  color: #fff;
  font-size: clamp(1.5rem, 1.1rem + 1.2vw, 2.1rem);
}

.hero-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hero-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 14px 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 0.92rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.hero-chip svg {
  width: 18px;
  height: 18px;
  color: var(--brand);
}

.hero-chip-clock {
  font-weight: 700;
}

.hero-weather-icon {
  display: inline-flex;
}

.hero-weather-range {
  padding-left: 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.18);
  color: #94a3b8;
  font-size: 0.86rem;
}

/* Word of the day: frosted panel */
.hero-word {
  flex: 0 1 400px;
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.hero-word-key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
}

.hero-word-key svg {
  width: 14px;
  height: 14px;
  color: var(--brand);
}

.hero-word-title {
  color: #fff;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.hero-word-def {
  margin: 0;
  color: #cbd5e1;
  font-size: 0.95rem;
  line-height: 1.45;
}

/* ==========================================================================
   Home: search + category chips
   ========================================================================== */
.hub-toolbar {
  display: grid;
  gap: 14px;
  margin-bottom: 28px;
  padding: 16px;
}

.hub-search {
  display: flex;
  gap: 10px;
}

.hub-search-field {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}

.hub-search-btn {
  flex: 0 0 auto;
}

body.is-searching .app-section .card-head-meta {
  visibility: hidden;
}

.hub-search-field input {
  min-height: 50px;
  padding-right: 48px;
  font-size: 1.02rem;
  border-radius: 14px;
  background: var(--panel-2);
}

.hub-search-field input:focus {
  background: var(--panel);
}

/* Hide the browser's own clear button; Esc clears instead */
.hub-search-field input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.search-kbd {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.hub-search-field input:focus ~ .search-kbd,
.hub-search-field input:not(:placeholder-shown) ~ .search-kbd {
  opacity: 0;
}

.hub-search-btn {
  min-height: 50px;
  border-radius: 14px;
}

.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
}

.category-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  transition: opacity 0.15s ease;
}

.category-chips.is-searching {
  opacity: 0.5;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 6px 8px 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text-2);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

.chip svg {
  width: 16px;
  height: 16px;
  margin-left: -2px;
  color: var(--muted);
}

.chip:hover {
  border-color: var(--brand-ring);
  color: var(--text);
}

.chip.is-active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

.chip.is-active svg {
  color: var(--brand);
}

.chip-count {
  min-width: 24px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--panel-3);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.chip.is-active .chip-count {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.search-status {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.search-status:empty {
  display: none;
}

.search-status strong {
  color: var(--text);
}

/* ==========================================================================
   Home: app sections + tiles
   ========================================================================== */
.app-sections {
  display: grid;
  gap: 32px;
}

.quick-launch {
  margin-bottom: 32px;
  padding: 20px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #fff4ec, #fffaf6 60%);
  border: 1px solid rgba(255, 120, 40, 0.25);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.section-icon {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--brand-strong);
  box-shadow: var(--shadow-sm);
}

.section-icon svg {
  width: 17px;
  height: 17px;
}

.section-icon-brand {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.section-icon-brand svg {
  fill: currentColor;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 12px;
}

.app-tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  min-height: 76px;
  padding: 12px 36px 12px 12px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition:
    transform 0.15s var(--ease),
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.app-tile:hover,
.app-tile:focus-visible {
  transform: translateY(-2px);
  border-color: var(--brand-ring);
  box-shadow: var(--shadow-md), 0 0 0 3px var(--brand-soft);
}

.app-tile:focus-visible {
  outline: none;
  border-color: var(--brand);
}

.app-tile:active {
  transform: translateY(0);
}

.app-thumb {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border-radius: 14px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--tile, var(--brand)) 82%, #fff), var(--tile, var(--brand)));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 4px 10px -4px color-mix(in srgb, var(--tile, var(--brand)) 70%, transparent);
  transition: transform 0.2s var(--ease);
}

.app-tile:hover .app-thumb {
  transform: rotate(-4deg) scale(1.05);
}

.app-logo {
  display: block;
  width: var(--logo-size, 28px);
  height: var(--logo-size, 28px);
  max-width: 34px;
  max-height: 34px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.app-emoji {
  font-size: 26px;
  line-height: 1;
}

.app-meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.app-name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  font-weight: 700;
  font-size: 0.98rem;
  line-height: 1.25;
  color: var(--text);
}

.app-host {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8rem;
  color: var(--muted);
}

.app-arrow {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 16px;
  height: 16px;
  color: var(--brand);
  opacity: 0;
  transform: translate(-3px, 3px);
  transition:
    opacity 0.15s ease,
    transform 0.15s var(--ease);
}

.app-tile:hover .app-arrow,
.app-tile:focus-visible .app-arrow {
  opacity: 1;
  transform: none;
}

/* ==========================================================================
   Profile
   ========================================================================== */
.profile-card {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px;
}

.profile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding-bottom: 24px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.profile-heading-block p {
  margin: 0;
  max-width: 46ch;
}

.profile-logo-wrap {
  position: relative;
  width: 157px;
  height: 48px;
  margin: 0 0 10px;
  overflow: hidden;
}

/* Crop to the artwork bounds (590,115)-(1355,349) of the 1920x420 source */
.profile-heading-logo {
  position: absolute;
  width: 250.98%;
  max-width: none;
  height: auto;
  left: -77.12%;
  top: -49.15%;
}

.profile-avatar-large {
  width: 112px;
  height: 112px;
  border-radius: 999px;
  object-fit: cover;
  border: 4px solid #fff;
  box-shadow: 0 0 0 1px var(--border), var(--shadow-md);
  font-size: 2.6rem;
  font-weight: 800;
}

.profile-form {
  gap: 20px;
}

.form-section {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.form-section + .form-section {
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.form-section legend {
  float: left;
  width: 100%;
  padding: 0;
  margin-bottom: 14px;
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text);
}

.form-section > :not(legend) {
  clear: both;
}

.form-section .checkbox-row {
  margin-top: 12px;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.profile-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-footer {
  justify-content: flex-end;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 960px) {
  .header-row {
    gap: 16px;
  }

  .brand {
    height: 48px;
  }

  .header-link {
    padding: 8px 12px;
  }

  .header-profile {
    padding: 3px;
  }

  .header-profile-name {
    display: none;
  }

  .profile-grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .home-hero {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-word {
    flex: none;
  }
}

@media (max-width: 760px) {
  html {
    scroll-padding-top: 124px;
  }

  main.wrap {
    padding: 18px 0 40px;
  }

  /* Two rows: logo + account on top, full-width tabs underneath */
  .header-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand account"
      "nav nav";
    gap: 8px 12px;
    padding: 8px 0 10px;
  }

  .header-row.is-guest {
    grid-template-columns: 1fr;
    grid-template-areas: "brand";
    padding: 6px 0;
  }

  .brand {
    height: 42px;
  }

  .header-row.is-guest .brand {
    height: 50px;
  }

  .header-nav {
    justify-self: stretch;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 3px;
  }

  .header-link {
    gap: 6px;
    padding: 8px 6px;
    font-size: 0.86rem;
  }

  .header-link svg {
    width: 16px;
    height: 16px;
  }

  .header-icon-btn {
    width: 38px;
    height: 38px;
  }

  .card {
    padding: 18px;
    border-radius: 16px;
  }

  .auth-card,
  .profile-card {
    padding: 22px;
  }

  /* Home */
  .home-hero {
    padding: 22px;
    gap: 20px;
    margin-bottom: 16px;
  }

  .home-avatar {
    width: 54px;
    height: 54px;
    font-size: 1.3rem;
  }

  .hero-word {
    padding: 14px 16px;
  }

  .hero-word-title {
    font-size: 1.25rem;
  }

  .hub-toolbar {
    padding: 12px;
    margin-bottom: 22px;
  }

  .hub-search-btn span,
  .search-kbd {
    display: none;
  }

  .hub-search-btn {
    width: 50px;
    padding: 0;
  }

  /* Category chips scroll sideways rather than wrapping onto many lines */
  .toolbar-row {
    display: grid;
    gap: 8px;
  }

  .category-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin: 0 -12px;
    padding: 0 12px 2px;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 24px), transparent);
    mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 24px), transparent);
  }

  .category-chips::-webkit-scrollbar {
    display: none;
  }

  .chip {
    flex: 0 0 auto;
  }

  .app-sections {
    gap: 24px;
  }

  .quick-launch {
    margin-bottom: 24px;
    padding: 14px;
  }

  .app-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .app-tile {
    gap: 10px;
    min-height: 64px;
    padding: 10px;
  }

  .app-thumb {
    width: 42px;
    height: 42px;
    border-radius: 12px;
  }

  .app-logo {
    max-width: 26px;
    max-height: 26px;
  }

  .app-name {
    font-size: 0.9rem;
  }

  .app-host,
  .app-arrow {
    display: none;
  }

  /* Profile */
  .profile-header {
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 16px;
  }

  .profile-avatar-large {
    width: 88px;
    height: 88px;
    font-size: 2rem;
  }

  .profile-logo-wrap {
    width: 131px;
    height: 40px;
  }

  .profile-grid,
  .profile-grid-3 {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-footer .btn {
    flex: 1;
  }

  .back-to-top {
    right: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 440px) {
  .header-link svg {
    display: none;
  }

  .header-link {
    padding: 8px 4px;
  }
}

@media (max-width: 340px) {
  .app-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (hover: none) {
  .app-tile:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
  }

  .app-tile:hover .app-thumb {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }

  .is-login-scene main.wrap::before,
  .login-title.is-tuning,
  .btn[data-login-submit].is-submitting {
    animation: none !important;
  }
}
