* { box-sizing: border-box; }

:root {
  color-scheme: light;
  --bg: #f2f3f5;
  --surface: #fff;
  --text: #1c1e21;
  --text-secondary: #666;
  --text-tertiary: #6e6e6e;
  --border: #eee;
  --border-strong: #8a9099;
  --border-light: #eeeeee;
  --btn-secondary-bg: #eef1f4;
  --btn-secondary-bg-hover: #dde1e4;
  --btn-icon-bg: #d0cfcf;
  --error: #d13c3c;
  --btn-primary-bg: #1c69a0;
  --accent-contrast: #fff;
  --link: #1a6699;
  --link-header: #666666;
  --link-header-hover: rgba(255, 255, 255, 0.3);
  --nav-active: var(--link);
  --shadow: rgba(0, 0, 0, 0.1);
  --overlay-bg: rgba(0, 0, 0, 0.9);
  --photo-scrim: rgba(0, 0, 0, 0.65);
  --lightbox-btn-bg: rgba(255, 255, 255, 0.15);
  --lightbox-btn-bg-hover: rgba(255, 255, 255, 0.3);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #191d20;
  --surface: #22262b;
  --text: #e8eaed;
  --text-secondary: #9aa0a6;
  --text-tertiary: #8b8f93;
  --border: #2e3338;
  --border-strong: #6b7178;
  --border-light: #4c4b4b;
  --btn-secondary-bg: #2a2f34;
  --btn-secondary-bg-hover: #363c42;
  --btn-icon-bg: #3a3f44;
  --error: #ff6b6b;
  --btn-primary-bg: #1c69a0;
  --accent-contrast: #fff;
  --link: #5aa9e6;
  --link-header: #5aa9e6;
  --link-header-hover: #1c69a0;
  --nav-active: var(--text);
  --shadow: rgba(0, 0, 0, 0);
  --overlay-bg: rgba(0, 0, 0, 0.9);
  --photo-scrim: rgba(0, 0, 0, 0.65);
  --lightbox-btn-bg: rgba(255, 255, 255, 0.15);
  --lightbox-btn-bg-hover: rgba(255, 255, 255, 0.3);
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior-y: contain;
}

#app-header {
  padding: 0 20px;
}

.header-inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
}

.brand {
  display: flex;
  flex-direction: column;
}

.brand .logo {
  height: 34px;
  width: auto;
  display: block;
}

.instance-label {
  margin-top: 2px;
  font-size: 0.7rem;
  color: var(--text-tertiary);
  padding-left: 0.4rem;
}

#session-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

#session-info button {
  background: none;
  border: none;
  padding: 4px 2px;
  color: var(--link-header);
  font-weight: 600;
}

/* Text color only, not a background fill. --nav-active is themed
   independently rather than reused directly from --link/--text: in light
   mode it's blue (aliases --link) since blue reads clearly against the
   light header; in dark mode plain --link doesn't work as the *active*
   color because --link-header (the resting color) and --link are the
   exact same value there (#5aa9e6) — no visible difference from resting —
   so dark mode aliases --text instead, the app's full-strength text color,
   which passes contrast comfortably and reads clearly distinct from both
   the muted resting --link-header and the hover --link. */
#session-info button.active {
  color: var(--nav-active);
}

#session-info button.active .btn-icon {
  opacity: 1;
}

#session-info button .btn-label:hover {
  background: none;
  border: none;
  color: var(--link);
  text-decoration: underline;
}

.btn-icon {
  margin-right: 6px;
  margin-top: -2px;
  opacity: 0.7;
  display: inline-flex;
  vertical-align: middle;
}

.btn-icon svg {
  width: 16px;
  height: 16px;
  display: block;
}

.status-actions .btn-icon{
  margin-top: 0;
}

.status-actions .btn-icon svg {
  width: 13px;
  height: 13px;
  display: block;
  margin-top: -2px;
}

.status-actions .view-original-btn .btn-icon svg {
  margin-top: 0px;
}

.reblog-banner .btn-icon {
  margin-top: 0px;
}

.reblog-banner .btn-icon svg {
  width: 13px;
  height: 13px;
  display: block;
  stroke-width: 3;
  color: var(--link);
  margin-top: 1px;
}

.hidden {
  display: none !important;
}

.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;
}

#app {
  padding: 10px 20px 20px 20px;
  max-width: 900px;
  margin: 0 auto;
}

.card {
  background: var(--surface);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px var(--shadow);
}

.intro {
  margin: 0 0 30px;
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--text);
}

.intro a {
  color: var(--link);
}

.login-hook {
  margin: 0 0 10px;
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
}

.login-columns {
  display: flex;
  align-items: flex-start;
  gap: 32px;
  margin-bottom: 20px;
}

.login-columns .feature-checklist,
.login-columns .login-form {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

.feature-checklist {
  list-style: none;
  margin: 0 0 28px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.feature-checklist li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.check-icon {
  display: inline-flex;
  flex-shrink: 0;
  color: var(--link);
}

.check-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

.login-form {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
}

.login-form h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

.login-form .form-row button {
  font-weight: 600;
  padding: 8px 20px;
}

.outtro{
  margin-top: 30px;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 30px;
}

.section-header h2 {
  margin: 0;
}

.home-link {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  cursor: pointer;
  color: var(--link);
  font-size: 0.9rem;
  white-space: nowrap;
  text-decoration: none;
}

.link-button {
  display: inline;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: var(--link);
  font: inherit;
  cursor: pointer;
}

.link-button:hover {
  text-decoration: underline;
}

h3 {
  color: var(--text);
}

label {
  display: block;
  margin: 10px 0 4px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  cursor: pointer;
}

input[type="text"], select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--btn-primary-bg);
}

.font-size-slider-wrap {
  position: relative;
  padding-bottom: 10px;
}

.font-size-ticks {
  display: flex;
  justify-content: space-between;
  position: absolute;
  top: 80%;
  left: 8px;
  right: 8px;
  margin-top: px;
  pointer-events: none;
}

.font-size-ticks .tick {
  width: 2px;
  background: var(--border-strong);
  border-radius: 1px;
}

.font-size-ticks .tick-default {
  width: 3px;
  height: 9px;
  background: var(--btn-primary-bg);
}

.font-size-preview {
  margin: 30px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: var(--post-font-size, 1rem);
  color: var(--text);
}

.form-row {
  display: flex;
  gap: 8px;
}

.form-row input[type="text"],
.form-row select {
  flex: 1;
  min-width: 0;
}

.form-row button {
  flex-shrink: 0;
}

button {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  background: var(--btn-primary-bg);
  color: var(--accent-contrast);
  font-size: 0.85rem;
  cursor: pointer;
}

button:hover {
  opacity: 0.9;
}

.error {
  color: var(--error);
  margin-top: 10px;
}

.hint {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.version-tag {
  margin: -10px 0 16px;
  color: var(--text-tertiary);
  font-size: 0.8rem;
}

.app-disclosure {
  margin-top: 30px;
  padding-top: 30px;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.4;
}

.copyright {
  margin-top: 16px;
  color: var(--text-tertiary);
  font-size: 0.8rem;
}

.settings-section {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.sub-settings-section{
  margin-bottom: 20px;
}

.settings-section:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

/* A labeled grouping *within* a .settings-section (e.g. Profile's "Display"
   vs "Filters") — unlike the plain, unlabeled .sub-settings-section above,
   this one carries its own small heading, so the visual hierarchy reads
   clearly at three distinct levels: h3 section title (full text color,
   default weight) > this muted, uppercase, letter-spaced label > the
   controls/field labels themselves (also muted, but not uppercase — see
   the plain `label` rule). */
.settings-subsection + .settings-subsection {
  margin-top: 24px;
}

.settings-subsection-heading {
  margin: 0 0 10px;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#list-members-heading {
  margin: 20px 0 0;
}

#list-members-heading summary {
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

#list-members-heading summary:hover {
  color: var(--text);
}

#list-members-heading[open] summary {
  margin-bottom: 8px;
}

#list-members {
  list-style: none;
  margin: 0;
  padding: 0;
}

#list-members li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

#list-members img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

#list-members .member-info {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1 1 auto;
}

#list-members .member-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  text-decoration: none;
  overflow-wrap: anywhere;
}

a.member-name:hover {
  text-decoration: underline;
}

#list-members .member-handle {
  color: var(--text-secondary);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

#pull-refresh {
  height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  transition: height 0.2s ease;
}

#pull-refresh.pulling {
  transition: none;
}

#pull-refresh-icon {
  display: inline-block;
  transition: transform 0.2s ease;
}

#pull-refresh.ready #pull-refresh-icon {
  transform: rotate(180deg);
}

#timeline-container,
#profile-container {
  min-width: 0;
}

#profile-banner {
  position: relative;
  aspect-ratio: 3 / 1;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
  background: var(--btn-secondary-bg);
}

#profile-banner-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Name/handle sit directly on top of the banner photo (overlaid), not below
   it — a gradient scrim (not a theme token, deliberately the same fixed dark
   value in both themes, same reasoning as --overlay-bg: it's
   compositing over unpredictable user-photo content, not the app's own
   surface) keeps --accent-contrast (white) text legible regardless of how
   bright the underlying banner image is. */
#profile-banner-info {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 12px 16px;
  background: linear-gradient(to top, var(--photo-scrim), transparent);
}

#profile-banner-avatar {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--accent-contrast);
  background: var(--btn-secondary-bg);
}

#profile-banner-names {
  min-width: 0;
  color: var(--accent-contrast);
}

#profile-banner-displayname {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#profile-banner-username {
  font-size: 0.85rem;
  opacity: 0.85;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-card {
  position: relative;
  background: var(--surface);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 40px;
  box-shadow: 0 1px 2px var(--shadow);
}

.new-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--btn-primary-bg);
  color: var(--accent-contrast);
  font-size: 0.55rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 4px 9px;
  border-radius: 4px;
  white-space: nowrap;
}

.reblog-banner {
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 1rem;
  margin-bottom: 1rem;
}

.status-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding-right: 110px;
}

/* Profile's cards (no avatar/author row — see renderStatusCard()'s
   showAuthor param): .status-date's usual position:absolute corner anchor
   exists to coexist with that row and the "New" badge, neither of which
   exist here, so it's flowed normally instead — the higher specificity
   (two classes) beats both this desktop padding-right and the mobile
   override below unconditionally, regardless of source order. */
.status-header.status-header-date-only {
  padding-right: 0;
  justify-content: flex-end;
}

.status-header.status-header-date-only .status-date {
  position: static;
}

.status-header img {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.status-author {
  min-width: 0;
  flex: 1 1 auto;
  height: 48px;
  padding-top: 1px;
}

.status-author .display-name,
.status-author .username {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-author .display-name {
  font-weight: 600;
  margin-bottom: 3px;
}

.status-author .display-name a{
  color: var(--text);
  text-decoration: none;
}

.status-author .username {
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-decoration: none;
  margin-top: 2px;
}

a.username:hover {
  text-decoration: underline;
}

.status-date {
  position: absolute;
  bottom: 9px;
  right: 0;
  color: var(--text-tertiary);
  font-size: 0.8rem;
  white-space: nowrap;
}

.status-content {
  font-size: var(--post-font-size, 1rem);
  word-wrap: break-word;
  line-height: 1.4;
}

img.emoji {
  width: 1.2em !important;
  height: 1.2em !important;
  object-fit: contain;
  vertical-align: middle;
}

.reblog-banner .emoji {
  margin:0 5px;
}

.status-content p {
  margin: 0 0 8px;
}

.status-content a {
  color: var(--link);
}

.status-content a.tag-link {
  color: var(--text-tertiary);
  font-size: 0.85em;
  text-decoration: none;
}

.status-media {
  margin-bottom: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 6px;
}

.status-media img, .status-media video {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
}

.status-media img {
  cursor: zoom-in;
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
}

/* A single-photo post normally keeps the photo's own aspect ratio (via its
   width/height attributes); once it's failed to load for good, there's
   nothing left to preserve that ratio for, so fall back to a shorter, fixed
   4:3 box (same ratio the multi-photo grid below already uses) instead of
   whatever tall shape a portrait photo happened to be. */
.status-media img.media-load-failed {
  aspect-ratio: 4 / 3;
}

.status-media-grid {
  grid-template-columns: repeat(var(--media-columns, 2), minmax(0, 1fr));
}

.status-media-grid img,
.status-media-grid video {
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

#lightbox {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: zoom-out;
  z-index: 1000;
}

#lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
}

#lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: var(--lightbox-btn-bg);
  color: var(--accent-contrast);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

#lightbox-close:hover {
  background: var(--lightbox-btn-bg-hover);
}

.status-media img:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

#info-view h3 {
  margin-bottom: 8px;
}

#info-view ul {
  margin: 0 0 16px;
  padding-left: 20px;
  line-height: 1.6;
}

#info-view p {
  line-height: 1.5;
}

#info-view a {
  color: var(--link);
}

.status-actions {
  margin-top: 12px;
  display: flex;
  gap: 10px;
}

.status-actions button,
.status-actions .view-original-btn,
.status-actions .status-stat {
  margin-top: 0;
  background: var(--btn-secondary-bg);
  color: var(--text);
  font-size: 0.85rem;
}

.status-actions .view-original-btn,
.status-actions .status-stat {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: 6px;
  text-decoration: none;
}

/* Profile's read-only favourite/boost counts: same icon+count shape as the
   real buttons, but never a <button> — there's no action to take, so no
   pointer cursor, no hover/active state, no click handler. */
.status-actions .status-stat {
  cursor: default;
}

.status-actions button.active {
  background: var(--btn-primary-bg);
  color: var(--accent-contrast);
}

.status-actions .btn-icon,
.reblog-banner .btn-icon {
  opacity: 1;
}

.reblog-banner {
  display: flex;
  align-items: center;
}

#scroll-sentinel,
#profile-scroll-sentinel {
  height: 1px;
}

#load-more-status,
#profile-load-more-status {
  text-align: center;
  margin: 10px auto;
}


@media (max-width: 480px) {

  .login-columns {
    flex-direction: column;
    gap: 0;
  }

  .login-columns .feature-checklist {
    margin-bottom: 28px;
  }

  .login-columns .login-form {
    margin-bottom: 20px;
  }

  #app-header {
    padding: 10px 10px 0 10px;
  }

  #profile-banner-avatar {
    width: 44px;
    height: 44px;
    border-radius: 6px;
  }

  #profile-banner-info {
    gap: 8px;
    padding: 8px 10px;
  }

  #profile-banner-username {
    font-size: 0.75rem;
  }

  #app{
    padding: 10px;
  }

  #session-info {
    /* 5 icon-only buttons (was 3, before Timeline/Profile) at the 12px
       desktop gap leaves ~0 spare width on a 320px viewport next to the
       logo — tighten it here rather than shrinking the buttons themselves. */
    gap: 6px;
  }

  #session-info button {
    width: 28px;
    height: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  #session-info .btn-icon {
    margin-right: 0;
  }

  #session-info .btn-icon svg {
    width: 20px;
    height: 20px;
  }

  #session-info .btn-label {
    display: none;
  }

  .status-card {
    margin-bottom: 20px;
  }

  .status-author .display-name {
    margin-bottom: 5px;
  }

  .status-author .username {
    display: block;
    width: 195px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: clip;
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 20px), transparent 100%);
    mask-image: linear-gradient(to right, black calc(100% - 20px), transparent 100%);
    font-size: 0.8rem;
  }

  .status-date {
    font-size: 0.7rem;
    bottom: 5px;
  }

  .status-header {
    padding-right: 90px;
  }

  #list-members .member-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
  }

  #list-members .member-handle{
    font-size: 0.6rem;
  }

}
