/* The wall: header, tag bar, cloud, timeline, time travel, sidebar and dialogs (SPEC 10). */

.page-wall {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* --- header --------------------------------------------------------------------------- */

.topbar {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 24px;
  padding: 18px 32px 20px;
}

/* The three-part bar of the ICCAS logo as a thin line under the header. */
.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--brand-grey) 0 33.3%,
    #1e88c8 33.3% 66.6%,
    var(--brand-grey-light) 66.6% 100%
  );
  opacity: 0.55;
}

/* View switch and tags sit in the middle of the header. */
.topbar-center {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-wrap: nowrap; /* wrapping happens inside the tag bar, never here */
  align-items: center;
  gap: 10px 14px;
}

.topbar-center .view-switch {
  flex: none;
}

/* Wide screens: "Beitrag senden" sits above the side panel instead of the header. */
@media (min-width: 1100px) {
  #open-submit {
    display: none;
  }
}

@media (max-width: 1099px) {
  .topbar-center {
    order: 10;
    flex-basis: 100%;
  }
}

.side-submit {
  display: flex;
  justify-content: center;
  width: 100%;
  min-height: 54px;
  border-radius: 14px;
  font-size: 17px;
}

.topbar-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex: 0 0 auto;
}

.topbar h1 {
  margin: 0;
  display: flex;
  flex-direction: column;
  font-family: var(--font-heading);
  line-height: 1.15;
}

.app-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.app-subtitle {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
}

.topbar-title .muted {
  font-size: 13px;
}

.view-switch {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: var(--surface-input);
}

.view-switch button {
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-label);
  font: 600 14px var(--font-text);
  cursor: pointer;
}

.view-switch button[aria-pressed="true"] {
  background: var(--accent-strong);
  color: #ffffff;
}

.user-menu {
  position: relative;
}

.menu-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
}

.menu-button[aria-expanded="true"] .chevron {
  rotate: 180deg;
}

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 1500;
  min-width: 200px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface-panel);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

.menu form {
  margin: 0;
}

.menu-item {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font: 14px var(--font-text);
  cursor: pointer;
}

a.menu-item {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.menu-item:hover,
.menu-item:focus-visible {
  background: var(--surface-input);
}

/* --- tag bar -------------------------------------------------------------------------- */

.tagbar {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.tagbar-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 40px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: 500 12px var(--font-text);
  white-space: nowrap;
  cursor: help;
}

.tagbar-label:hover,
.tagbar-label:focus-visible {
  color: var(--text);
}

.tagbar-empty {
  color: var(--text-faint);
  font-size: 12px;
}

.tooltip {
  position: fixed;
  z-index: 3000;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--card-top);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.tag-search {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-chip);
  background: var(--surface-input);
  color: var(--text-muted);
}

.tag-search:focus-within {
  border-color: var(--accent);
}

.tag-search input {
  width: 120px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font: 13px var(--font-text);
}

.tag-chips {
  display: contents;
}

.tag-chip {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-chip);
  background: transparent;
  color: var(--text-label);
  font: 13px var(--font-text);
  cursor: pointer;
}

.tag-chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-surface);
  color: var(--accent-light);
}

/* Hidden by right click: red and struck through. */
.tag-chip.is-excluded {
  border-color: var(--danger);
  background: var(--danger-surface);
  color: var(--danger-text);
}

.tag-chip.is-excluded .name {
  text-decoration: line-through;
}

.tag-chip .count {
  margin-left: 4px;
  color: var(--text-muted);
  font-size: 12px;
}

/* --- layout --------------------------------------------------------------------------- */

.layout {
  display: flex;
  flex-wrap: wrap;
  flex-grow: 1;
}

.wall-area {
  flex: 999 1 560px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  outline: none;
}

.sidebar {
  flex: 1 1 300px;
  max-width: 380px;
  padding: 20px 32px 28px 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  /* The opened item stays in view while the page (timeline) scrolls. */
  position: sticky;
  top: 0;
  align-self: flex-start;
  max-height: 100dvh;
  overflow-y: auto;
}

/* Opened item in the right-hand panel (wide screens, SPEC 10.5). */
.detail-panel {
  padding: 0;
  gap: 0;
  overflow: hidden;
}

/* Statistics while no item is open (no ranking). */
.stats {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 20px 20px;
}

.stats p {
  margin: 0;
}

.detail-panel .stats h2.panel-title {
  font: 500 12px var(--font-text);
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-input);
}

.stat-number {
  font: 600 26px/1.1 var(--font-heading);
  color: var(--text);
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 0 20px;
}

.panel-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-label);
  font-size: 16px;
  cursor: pointer;
}

.panel-close:hover {
  background: var(--surface-input);
  color: var(--text);
}

.detail-panel .focus-image {
  width: calc(100% - 32px);
  max-height: 360px;
  margin: 12px 16px 0;
  border-radius: 10px;
}

.detail-panel .link-preview {
  margin: 12px 16px 0;
}

.detail-panel .dialog-body {
  gap: 12px;
  padding: 14px 20px 20px;
}

.detail-panel h2 {
  margin: 0;
  font: 500 22px/1.2 var(--font-heading);
  overflow-wrap: anywhere;
}

.detail-panel h2[tabindex="-1"]:focus {
  outline: none;
}

.detail-panel .reactions {
  gap: 6px;
}

.detail-panel .reaction {
  padding: 0 10px;
}

@media (max-width: 1099px) {
  .sidebar {
    display: none;
  }
}

.panel {
  background: linear-gradient(180deg, #1d2a3a, var(--surface-panel));
  border: 1px solid var(--line-strong);
  box-shadow: 0 10px 30px rgba(3, 8, 14, 0.25);
  border-radius: var(--radius-panel);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-title {
  margin: 0;
  font: 500 12px var(--font-text);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.empty {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

/* --- cloud ---------------------------------------------------------------------------- */

.cloud {
  position: relative;
  touch-action: none;
  height: 640px;
  margin: 20px 32px 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-panel);
  background:
    radial-gradient(circle, rgba(165, 190, 220, 0.09) 1px, transparent 1.5px) 0 0 / 22px 22px,
    linear-gradient(180deg, #1a2738, var(--surface-wall));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.cloud-legend {
  position: absolute;
  left: 20px;
  top: 16px;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 12px;
  color: var(--text-faint);
}

.tidy {
  position: absolute;
  right: 14px;
  top: 10px;
  z-index: 900;
}

.cloud-cards {
  position: absolute;
  inset: 0;
}

.cloud .empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card {
  position: absolute;
  width: 220px;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-align: left;
  border: 1.5px solid var(--accent-border);
  border-radius: var(--radius-card);
  background: linear-gradient(180deg, var(--card-top), var(--card));
  color: var(--text);
  font: inherit;
  cursor: grab;
  box-shadow:
    0 10px 28px rgba(3, 8, 14, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  /* Every touch on a card belongs to dragging (SPEC 10.7). */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition:
    transform 0.4s,
    opacity 0.25s,
    filter 0.25s,
    scale 0.25s,
    left 0.4s,
    top 0.4s;
}

/* While dragging the card follows the pointer directly. */
.card.is-dragging {
  cursor: grabbing;
  transition:
    transform 0.4s,
    opacity 0.25s,
    filter 0.25s,
    scale 0.25s;
}

.card img {
  pointer-events: none;
  -webkit-user-drag: none;
}

/* Hover/focus: sharp, opaque, a bit larger and on top. Does not count as a view. */
.card:hover,
.card:focus-visible {
  filter: none !important;
  opacity: 1 !important;
  scale: 1.08;
  z-index: 500 !important;
}

.card:focus-visible {
  outline: 3px solid var(--info);
  outline-offset: 2px;
}

.card:hover {
  border-color: var(--accent);
}

.card.is-selected {
  border-color: var(--accent);
  box-shadow:
    0 0 0 3px rgba(44, 147, 214, 0.28),
    0 10px 28px rgba(3, 8, 14, 0.4);
}

.card.is-new {
  animation: card-in 300ms ease-out;
}

@keyframes card-in {
  from {
    opacity: 0;
    scale: 0.85;
  }
}

.card-thumb {
  display: block;
  width: 100%;
  height: 110px;
  object-fit: cover;
  background: var(--placeholder);
}

.card-domain {
  padding: 10px 12px 0;
  font-size: 11px;
  color: var(--info);
}

.card-content {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px 12px 12px;
}

.card-title .hashtag,
.tl-title .hashtag {
  font-weight: 500;
}

.card-title {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.card-tags,
.tl-tags {
  font-size: 11px;
  color: var(--accent-light);
  overflow-wrap: anywhere;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

/* --- timeline ------------------------------------------------------------------------- */

.timeline {
  min-height: 640px;
  margin: 20px 32px 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.tl-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tl-group h2 {
  margin: 0;
  font: 500 18px var(--font-heading);
  color: var(--text-label);
}

/* Cards wrap into rows (no horizontal scrolling). */
.tl-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  align-items: start;
  gap: 14px;
}

.tl-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  text-align: left;
  border: 1.5px solid var(--accent-border);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--card-top), var(--card));
  color: var(--text);
  font: inherit;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(3, 8, 14, 0.3);
}

.tl-card:hover {
  border-color: var(--accent);
}

.tl-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(44, 147, 214, 0.28);
}

.tl-card:focus-visible {
  outline: 3px solid var(--info);
  outline-offset: 2px;
}

.tl-thumb {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--placeholder);
}

.tl-meta,
.tl-stats {
  font-size: 11px;
  color: var(--text-muted);
}

.tl-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.timeline-status {
  margin: 0;
  font-size: 13px;
}

.timeline-sentinel {
  height: 1px;
}

/* --- time travel ---------------------------------------------------------------------- */

.timetravel {
  margin: 16px 32px 28px;
  padding: 16px 20px;
  border-radius: var(--radius-card);
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}

.timetravel-label {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.timetravel input[type="range"] {
  flex: 1 1 260px;
  min-height: 44px;
  accent-color: var(--accent);
}

.timetravel-value {
  min-width: 150px;
  text-align: right;
  font-size: 13px;
  color: var(--accent-light);
}

/* --- sidebar -------------------------------------------------------------------------- */

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

.stat {
  display: inline-block; /* transform (the bump animation) needs a box */
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--accent-surface);
  color: var(--accent-light);
  font-size: 12px;
}

.channel-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Help and the "other ways" fold-out in the submit form. */
.flyout {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-wall);
}

.flyout summary {
  color: var(--info);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.flyout[open] summary {
  margin-bottom: 8px;
}

.flyout p {
  margin: 0 0 4px;
}

.help {
  gap: 20px;
}

.help-section h3 {
  margin: 0 0 6px;
  font: 500 17px var(--font-heading);
  color: var(--text-label);
}

.help-section p {
  margin: 0 0 6px;
  color: var(--text-muted);
  font-size: 14px;
}

.help-list {
  margin: 0;
  padding-left: 1.2em;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

.channel-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.channel-list li > span:first-child {
  flex: none;
  white-space: nowrap;
}

.channel-list .muted {
  font-size: 13px;
  text-align: right;
}

/* --- dialogs -------------------------------------------------------------------------- */

.dialog {
  width: calc(100% - 48px);
  max-width: 620px;
  max-height: calc(100dvh - 48px);
  padding: 0;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-dialog);
  background: var(--card);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}

.dialog::backdrop {
  background: rgba(8, 14, 22, 0.7);
  backdrop-filter: blur(2px);
}

.small-dialog {
  max-width: 440px;
}

.dialog-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 24px 24px;
}

/* Headings focused by script on open: no focus ring (they are not interactive). */
.dialog h2[tabindex="-1"]:focus {
  outline: none;
}

.dialog h2 {
  margin: 0;
  font: 500 26px/1.2 var(--font-heading);
  overflow-wrap: anywhere;
}

.small-dialog h2,
.submit-dialog h2 {
  font-size: 22px;
}

.focus-image {
  display: block;
  width: 100%;
  height: auto;
  max-height: 60dvh;
  object-fit: contain;
  background: var(--placeholder);
  border-radius: var(--radius-dialog) var(--radius-dialog) 0 0;
}

.link-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 24px 24px 0;
  padding: 16px;
  border: 1px solid var(--placeholder);
  border-radius: 12px;
  background: var(--surface-wall);
}

.link-preview img {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: 8px;
}

.link-preview .domain {
  font-size: 12px;
  color: var(--info);
}

.focus-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.focus-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.55;
}

.hashtag {
  color: var(--accent-light);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.focus-tag {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--accent-border);
  border-radius: 16px;
  background: var(--accent-surface);
  color: var(--accent-light);
  font: 12px var(--font-text);
  cursor: pointer;
}

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

.reaction {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  background: transparent;
  color: var(--text-label);
  font: 13px var(--font-text);
  cursor: pointer;
}

.reaction[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-surface);
  color: var(--accent-light);
}

.reaction .emoji {
  font-size: 18px;
  line-height: 1;
}

/* Views chip: tooltip on hover/focus, emphasis animation when the own view counts. */
.stat-tip {
  position: relative;
  cursor: help;
}

.stat-tip:hover::after,
.stat-tip:focus-visible::after {
  content: attr(data-tip);
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 20;
  width: max-content;
  max-width: 240px;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-panel);
  color: var(--text);
  font-size: 12px;
  box-shadow: 0 8px 20px rgba(3, 8, 14, 0.45);
}

.stat.is-bumped {
  animation: views-bump 900ms cubic-bezier(0.2, 0.9, 0.3, 1.3);
}

@keyframes views-bump {
  0% {
    transform: scale(1);
  }
  25% {
    transform: scale(1.35);
    background: var(--accent-strong);
    color: #ffffff;
    box-shadow: 0 0 0 6px rgba(44, 147, 214, 0.35);
  }
  55% {
    transform: scale(0.95);
  }
  80% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

.view-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.sheet-handle,
.sheet-hint {
  display: none;
}

.sheet-footer {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.btn-danger-quiet {
  border-color: rgba(229, 103, 93, 0.55);
  color: var(--danger-text);
}

.btn-danger-quiet:hover {
  background: var(--danger-surface);
}

.btn-primary.btn-danger-solid {
  background: #b3423a;
  box-shadow: none;
}

.btn-primary.btn-danger-solid:hover {
  background: #c54b42;
}

.report-link {
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: 13px var(--font-text);
  text-decoration: underline;
  cursor: pointer;
}

.report-link:disabled {
  text-decoration: none;
  cursor: default;
}

/* --- forms in dialogs ----------------------------------------------------------------- */

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label,
.kind-switch legend {
  color: var(--text-label);
  font-size: 14px;
  font-weight: 500;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
  background: var(--surface-wall);
  color: var(--text);
  font: 15px var(--font-text);
}

.field textarea {
  min-height: 110px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: transparent;
}

/* The title is the main field of the submit form. */
.field-title label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.field-title input {
  padding: 0.75rem 0.9rem;
  font: 500 20px var(--font-heading);
}

.text-toggle summary {
  color: var(--info);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.text-toggle[open] summary {
  margin-bottom: 8px;
}

/* Optional text: smaller than the title. */
.field-small label {
  font-size: 13px;
}

.field-small textarea {
  min-height: 90px;
  font-size: 14px;
}

.field-counter {
  align-self: flex-end;
  font-size: 12px;
  color: var(--text-muted);
}

.kind-switch {
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 4px;
  border: 0;
  border-radius: 10px;
  background: var(--surface-input);
}

.kind-switch legend {
  /* Visually hidden; the segmented control speaks for itself. */
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.kind-switch label {
  flex: 1;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--text-label);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.kind-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.kind-switch input:checked + label {
  background: var(--accent-strong);
  color: #ffffff;
}

.kind-switch input:focus-visible + label {
  outline: 2px solid var(--info);
}

.field-label {
  color: var(--text-label);
  font-size: 14px;
  font-weight: 500;
}

/* Image source: picker, drag and drop, Ctrl+V. */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px;
  border: 2px dashed var(--line-strong);
  border-radius: 12px;
  text-align: center;
}

.dropzone p {
  margin: 0;
}

.dropzone.is-dragging {
  border-color: var(--accent);
  background: var(--accent-surface);
}

.dropzone label.btn-secondary {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.file-input:focus-visible + label {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.dropzone-file {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dropzone .image-preview {
  align-self: center;
}

.image-preview {
  max-width: 100%;
  max-height: 220px;
  object-fit: contain;
  align-self: flex-start;
  border-radius: 10px;
  background: var(--placeholder);
}

.field-check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--text-label);
  font-size: 14px;
}

.field-check input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
}

/* Settings: own data and the folded-away "delete all" below the form. */
.settings-section,
.danger-zone {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.settings-section {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.settings-section h3 {
  margin: 0;
  font: 500 17px var(--font-heading);
  color: var(--text-label);
}

.settings-hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

a.btn-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.danger-zone summary {
  padding: 12px 0; /* touch target; display stays list-item for the disclosure marker */
  color: var(--danger-text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.danger-zone[open] summary {
  margin-bottom: 4px;
}

.danger-form {
  border: 1px solid rgba(229, 103, 93, 0.45);
  border-radius: 10px;
  padding: 12px 14px;
}

.danger-form + .danger-form {
  margin-top: 12px;
}

.danger-form h3 {
  margin: 0;
  color: var(--danger-text);
  font: 500 16px var(--font-heading);
}

/* Tag autocomplete (tagcomplete.js): positioned by script below its input. */
.tag-options {
  position: fixed;
  z-index: 3000;
  margin: 0;
  padding: 4px;
  overflow-y: auto;
  list-style: none;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--card-top);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.tag-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.tag-option:hover,
.tag-option[aria-selected="true"] {
  background: var(--accent-surface);
  outline: 1px solid var(--accent);
}

.tag-option.is-excluded .name {
  color: var(--danger-text);
  text-decoration: line-through;
}

.tag-option .meta {
  color: var(--text-muted);
  font-size: 12px;
}

.form .form-error:empty,
.form div:empty {
  display: none;
}

/* --- dropping an image on the wall ------------------------------------------------------- */

.drop-overlay {
  position: fixed;
  inset: 12px;
  z-index: 2500;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px dashed var(--accent);
  border-radius: var(--radius-dialog);
  background: rgba(13, 22, 33, 0.86);
  pointer-events: none; /* drag events keep reaching the page underneath */
}

.drop-overlay p {
  margin: 0;
  padding: 16px 24px;
  border-radius: 14px;
  background: var(--accent-surface);
  color: var(--accent-light);
  font: 500 22px var(--font-heading);
}

/* --- toast ---------------------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 3000;
  translate: -50% 0;
  padding: 10px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface-panel);
  color: var(--text);
  font-size: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

/* --- desktop: the cloud view uses the full height of the window --------------------------- */

@media (min-width: 701px) and (min-height: 501px) {
  body.view-cloud {
    height: 100dvh;
  }

  /* No wrapping here: with wrap, a long open item would make the row taller than the window. */
  body.view-cloud .layout {
    flex-wrap: nowrap;
    min-height: 0;
  }

  body.view-cloud .wall-area,
  body.view-cloud .sidebar {
    min-height: 0;
  }

  body.view-cloud .cloud {
    flex: 1 1 auto;
    height: auto;
    min-height: 360px;
  }

  /* The side panel takes the same height and scrolls inside. */
  body.view-cloud .sidebar {
    position: static;
    align-self: stretch;
    max-height: none;
    overflow-y: auto;
  }
}

/* --- phones (SPEC 10.7) ---------------------------------------------------------------- */

html,
body {
  overscroll-behavior: none; /* no pull-to-refresh or swipe-back from gestures on the wall */
}

@media (max-width: 700px) {
  .topbar {
    padding: 16px 16px 10px;
    gap: 10px;
  }

  /* The long title may wrap so "+" and the menu stay on the same row. */
  .topbar-title {
    flex: 1 1 0;
    min-width: 0;
  }

  .app-title {
    font-size: 19px;
  }

  .menu-button {
    padding: 0.4rem;
  }

  .app-subtitle {
    font-size: 12px;
  }

  .topbar-title .muted,
  #user-name {
    display: none;
  }

  #open-submit {
    width: 44px;
    padding: 0;
    justify-content: center;
    border-radius: 12px;
  }

  #open-submit span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .topbar {
    padding-bottom: 14px;
  }

  /* Second row: view switch over the full width, then the tags. */
  .topbar-center {
    flex-direction: column;
    align-items: stretch;
  }

  .view-switch button {
    flex: 1;
  }

  /* Tag bar: one line, swipe sideways (keeps its height in the column layout). */
  .tagbar {
    flex: none;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 2px 0 4px;
    scrollbar-width: none;
    touch-action: pan-x;
  }

  .tag-search,
  .tagbar-label,
  .tag-chip,
  #clear-tags {
    flex: none;
  }

  .tag-chip {
    min-height: 36px;
    padding: 0 12px;
  }

  .tag-search {
    min-height: 36px;
  }

  .tag-search input {
    width: 90px;
  }

  .cloud {
    height: 70dvh;
    margin: 4px 12px 0;
  }

  .cloud-legend {
    left: 12px;
    top: 10px;
    font-size: 11px;
  }

  .tidy {
    right: 8px;
    top: 6px;
    min-height: 32px;
    padding: 0 12px;
    font-size: 12px;
  }

  .card-thumb {
    height: 90px;
  }

  .card-content {
    gap: 5px;
    padding: 10px;
  }

  .card-title {
    font-size: 13px;
  }

  .timeline {
    min-height: 0;
    margin: 12px 12px 0;
  }

  .tl-row {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
  }

  .timetravel {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "label value"
      "range range"
      "now ago";
    gap: 2px 8px;
    margin: 10px 12px 14px;
    padding: 10px 14px;
  }

  .timetravel-label {
    grid-area: label;
    font-size: 12px;
  }

  .timetravel-value {
    grid-area: value;
    min-width: 0;
    font-size: 12px;
  }

  .timetravel input[type="range"] {
    grid-area: range;
    width: 100%;
    min-height: 36px;
  }

  .timetravel > span:first-of-type {
    grid-area: now;
    font-size: 11px;
  }

  .timetravel > span:last-of-type {
    grid-area: ago;
    font-size: 11px;
    text-align: right;
  }

  /* Cloud view: exactly one screen high, the page itself does not scroll. */
  body.view-cloud {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  body.view-cloud .layout,
  body.view-cloud .wall-area {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
  }

  body.view-cloud .cloud {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
  }

  /* Focus view as bottom sheet, up to about 90 % of the height. */
  .focus-dialog {
    width: 100%;
    max-width: none;
    max-height: 90dvh;
    margin: auto 0 0;
    border-bottom: 0;
    border-radius: 22px 22px 0 0;
    transition: translate 0.2s;
  }

  .focus-dialog.is-swiping {
    transition: none;
  }

  .sheet-handle {
    display: block;
    width: 40px;
    height: 5px;
    margin: 10px auto 6px;
    border-radius: 3px;
    background: var(--line-strong);
    cursor: grab;
  }

  .focus-image {
    width: calc(100% - 32px);
    margin: 8px 16px 0;
    border-radius: 14px;
  }

  .link-preview {
    margin: 8px 16px 0;
  }

  .focus-dialog .dialog-body {
    padding: 18px 20px 24px;
  }

  .focus-dialog h2 {
    font-size: 24px;
  }

  .reactions {
    justify-content: space-between;
  }

  .reaction {
    min-width: 56px;
    justify-content: center;
    padding: 0 8px;
  }

  .focus-dialog .dialog-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .focus-dialog .dialog-actions .btn-primary,
  .focus-dialog .dialog-actions .btn-secondary {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .sheet-footer {
    margin-left: 0;
    justify-content: space-between;
  }

  .sheet-hint {
    display: inline;
    font-size: 11px;
    color: var(--text-muted);
  }

  .sheet-footer .report-link {
    min-height: 24px;
    padding: 0;
    font-size: 11px;
  }

  /* Submit form as full-screen sheet. */
  .submit-dialog {
    width: 100%;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }
}

/* Phones in landscape: title, view switch, time travel and buttons share one slim bar,
   the tags get a second slim row, the wall takes the rest. */
@media (max-height: 500px) and (orientation: landscape) {
  body.view-cloud {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto auto;
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas:
      "title switch travel submit menu"
      "tags tags tags tags tags"
      "wall wall wall wall wall";
    align-items: center;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  body.view-cloud .topbar,
  body.view-cloud .topbar-center,
  body.view-cloud .layout,
  body.view-cloud .wall-area {
    display: contents;
  }

  body.view-cloud .sidebar,
  body.view-cloud #user-name,
  body.view-cloud .app-subtitle {
    display: none;
  }

  body.view-cloud .topbar-title {
    grid-area: title;
    padding: 6px 8px 6px 12px;
  }

  body.view-cloud .app-title {
    font-size: 16px;
    white-space: nowrap;
  }

  body.view-cloud .view-switch {
    grid-area: switch;
  }

  body.view-cloud .view-switch button {
    min-height: 32px;
  }

  body.view-cloud #open-submit {
    grid-area: submit;
    width: 36px;
    min-height: 32px;
    margin: 0 4px;
    padding: 0;
    justify-content: center;
  }

  body.view-cloud .user-menu {
    grid-area: menu;
    margin-right: 8px;
  }

  body.view-cloud #open-submit span,
  body.view-cloud .timetravel > span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  body.view-cloud .timetravel {
    grid-area: travel;
    flex-wrap: nowrap;
    gap: 8px;
    margin: 6px 8px;
    padding: 4px 12px;
  }

  body.view-cloud .timetravel input[type="range"] {
    min-height: 28px;
  }

  body.view-cloud .timetravel-value {
    min-width: 0;
  }

  body.view-cloud .tagbar {
    grid-area: tags;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 0 12px 6px;
  }

  body.view-cloud .card-thumb {
    height: 80px;
  }

  body.view-cloud .cloud {
    grid-area: wall;
    align-self: stretch;
    height: auto;
    min-height: 0;
    margin: 0 12px 8px;
  }
}

/* --- motion --------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .card,
  .card.is-new,
  .stat.is-bumped,
  .focus-dialog {
    transition: none;
    animation: none;
  }
}
