/* comments.css — kommentarspanelen. Mörkt tema, inga externa typsnitt. */

.ac {
  /* Tokens ärvs från theme.css. Deklarera dem inte om här. */

  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  width: 100%;
  box-sizing: border-box;
  background: var(--panel);
  border-left: 1px solid var(--line);
  color: var(--ink);
  font: 13px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.ac *,
.ac *::before,
.ac *::after {
  box-sizing: border-box;
}

.ac button,
.ac input,
.ac textarea,
.ac select {
  font: inherit;
  color: inherit;
}

.ac ::selection {
  background: color-mix(in srgb, var(--accent) 45%, transparent);
}

.ac :focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-radius: 6px;
}

/* ------------------------------------------------------------ Header */

.ac-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.ac-head-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}

.ac-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.ac-count {
  color: var(--muted);
  font-size: 11px;
}

.ac-spacer {
  flex: 1 1 auto;
}

/* ------------------------------------------------------------ Knappar */

.ac-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.ac-btn:hover {
  border-color: var(--color-line-2);
  background: var(--color-surface-2);
}

.ac-btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--color-accent-ink);
}

.ac-btn-accent:hover {
  background: var(--color-accent);
  border-color: var(--color-accent);
}

.ac-btn[disabled] {
  opacity: 0.5;
  cursor: default;
}

.ac-ibtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex: 0 0 auto;
}

.ac-ibtn:hover {
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--ink);
}

.ac-ibtn.is-on {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 40%, var(--line));
  background: color-mix(in srgb, var(--ok) 12%, transparent);
}

.ac-ibtn.is-danger:hover {
  color: var(--danger);
}

.ac-ibtn svg,
.ac-ico svg {
  width: 16px;
  height: 16px;
  display: block;
}

.ac-ico {
  display: inline-flex;
  align-items: center;
}

/* ------------------------------------------------------------ Filter */

.ac-filters {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.ac-fchiprow {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.ac-fchip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  line-height: 1.6;
}

.ac-fchip:hover {
  color: var(--ink);
  background: var(--panel-2);
}

.ac-fchip.is-active {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line));
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.ac-fchip-count {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 10px;
}

.ac-fchip.is-active .ac-fchip-count {
  color: var(--ink);
}

.ac-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.ac-clear {
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 11px;
  text-decoration: underline;
  cursor: pointer;
}

.ac-clear:hover {
  color: var(--ink);
}

/* -------------------------------------------------------------- Body */

.ac-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.ac-body.is-thread {
  display: flex;
  flex-direction: column;
}

.ac-body::-webkit-scrollbar {
  width: 10px;
}

.ac-body::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 999px;
  border: 3px solid var(--panel);
}

.ac-empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--muted);
}

.ac-empty p {
  margin: 0 0 6px;
}

.ac-empty-hint {
  font-size: 11px;
  color: var(--muted);
  opacity: 0.8;
  padding: 4px 0;
}

/* ------------------------------------------------------------ Listan */

.ac-group {
  border-bottom: 1px solid var(--line);
}

.ac-group-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 8px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 1;
}

.ac-group-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ac-group-count {
  color: var(--muted);
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

.ac-row {
  display: flex;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: 0;
  border-left: 2px solid transparent;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.ac-row:hover {
  background: var(--panel-2);
}

.ac-row.is-open {
  background: var(--panel-2);
  border-left-color: var(--accent);
}

.ac-row.is-resolved .ac-row-title {
  color: var(--muted);
  text-decoration: line-through;
}

.ac-row-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex: 0 0 auto;
}

.ac-row-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}

.ac-row-title {
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ac-row-excerpt {
  color: var(--muted);
  font-size: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ac-row-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.ac-tag {
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 4px;
  line-height: 15px;
  white-space: nowrap;
}

.ac-tag-ok {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 40%, var(--line));
}

.ac-tag-h {
  color: var(--color-warning);
  border-color: color-mix(in oklch, var(--color-warning) 35%, var(--color-line));
}

.ac-time {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}

/* ------------------------------------------------------------ Trådvy */

.ac-thead {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.ac-thead-top {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
}

.ac-thead-node {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ac-thead-title {
  margin: 0 0 8px;
  padding-left: 8px;
  border-left: 3px solid var(--accent);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.ac-thead-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.ac-select {
  max-width: 100%;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--ink);
  font-size: 11px;
  cursor: pointer;
}

.ac-select-h {
  flex: 1 1 160px;
  min-width: 0;
  color: var(--muted);
}

.ac-comments {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 0 8px;
}

.ac-comment {
  padding: 8px 12px;
}

.ac-comment.is-first {
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  border-bottom: 1px solid var(--line);
}

.ac-c-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.ac-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 9px;
  font-weight: 700;
  color: var(--color-accent-ink);
  flex: 0 0 auto;
}

.ac-c-name {
  font-size: 12px;
  font-weight: 600;
}

.ac-c-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--ink);
  padding-left: 26px;
}

/* ----------------------------------------------------------- Bilagor */

.ac-atts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  padding-left: 26px;
}

.ac-att {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  overflow: hidden;
  padding: 0;
}

.ac-att-img {
  cursor: zoom-in;
  line-height: 0;
  max-width: 100%;
}

.ac-att-img img {
  display: block;
  max-width: 160px;
  max-height: 120px;
  object-fit: cover;
}

.ac-att-img:hover {
  border-color: var(--accent);
}

.ac-att-video {
  width: 100%;
  max-width: 240px;
  border-radius: 8px;
  background: var(--color-bg);
}

.ac-att-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  color: var(--ink);
  text-decoration: none;
  font-size: 12px;
  max-width: 100%;
}

.ac-att-file:hover {
  border-color: var(--accent);
}

.ac-att-size {
  color: var(--muted);
  font-size: 10px;
}

/* --------------------------------------------------------- Composer */

.ac-composer {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px 10px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.ac-composer.is-drop {
  outline: 2px dashed var(--accent);
  outline-offset: -4px;
  background: color-mix(in srgb, var(--accent) 10%, var(--panel));
}

.ac-input {
  width: 100%;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--ink);
  resize: none;
  min-height: 44px;
}

.ac-input::placeholder {
  color: var(--muted);
}

.ac-input:focus {
  border-color: var(--accent);
  outline: none;
}

.ac-input-line {
  min-height: 0;
}

.ac-file {
  display: none;
}

.ac-composer-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ac-hint {
  font-size: 10px;
  color: var(--muted);
}

/* --------------------------------------------------- Utkastbilagor */

.ac-draft {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ac-draft[hidden] {
  display: none;
}

.ac-dchip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 4px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.ac-dchip.is-uploading {
  opacity: 0.75;
}

.ac-dchip.is-error {
  border-color: var(--danger);
}

.ac-dthumb {
  width: 40px;
  height: 40px;
  border-radius: 5px;
  object-fit: cover;
  background: var(--color-bg);
  display: block;
  flex: 0 0 auto;
}

.ac-dthumb-file {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.ac-dthumb-file svg {
  width: 18px;
  height: 18px;
}

.ac-dplay {
  position: absolute;
  left: 16px;
  top: 16px;
  color: var(--color-accent-ink);
  pointer-events: none;
}

.ac-dplay svg {
  width: 14px;
  height: 14px;
}

.ac-dname {
  font-size: 11px;
  color: var(--muted);
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ac-derr {
  font-size: 10px;
  color: var(--danger);
}

.ac-dspin {
  width: 12px;
  height: 12px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: ac-spin var(--dur-slower) linear infinite;
  flex: 0 0 auto;
}

@keyframes ac-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ac-dspin {
    animation-duration: var(--dur-pulse);
  }
}

.ac-dx {
  width: 20px;
  height: 20px;
}

.ac-dx svg {
  width: 12px;
  height: 12px;
}

/* --------------------------------------------------------- Nytt-form */

.ac-newform {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 12px 14px;
}

.ac-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}

.ac-label .ac-select {
  font-size: 12px;
  padding: 6px 8px;
}

/* --------------------------------------------------------- Lightbox */

.ac-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  padding: 32px;
  background: color-mix(in oklch, var(--color-bg) 88%, transparent);
  backdrop-filter: blur(2px);
  cursor: zoom-out;
}

.ac-lb-img {
  max-width: 92vw;
  max-height: 84vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: var(--shadow-xl);
}

.ac-lb-name {
  color: var(--color-ink);
  font: 12px/1.4 -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

.ac-lb-close {
  position: absolute;
  top: 14px;
  right: 16px;
  color: var(--color-ink);
  width: 32px;
  height: 32px;
}

/* ------------------------------------------------------------- Toast */

.ac-toast {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--color-surface-2);
  color: var(--ink);
  font-size: 12px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
  pointer-events: none;
  z-index: 20;
}

.ac-toast.is-on {
  opacity: 1;
  transform: none;
}

/* ================================================================== *
 * Närvarorad                                                          *
 * Fristående block — orkestratorn får flytta .ac-people in i         *
 * sidhuvudet, därför bär den sina egna tokens.                         *
 * ================================================================== */

.ac-people {
  /* Tokens ärvs från theme.css. Deklarera dem inte om här. */

  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
  box-sizing: border-box;
  color: var(--ink);
  font: 13px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

/* Tom lista ska inte ta någon plats alls. */
.ac-people[hidden] {
  display: none !important;
}

.ac-pres-avatars {
  display: flex;
  align-items: center;
  padding-left: 6px;
  flex: 0 0 auto;
}

.ac-pres-av {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin-left: -6px;
  padding: 0;
  border: 2px solid var(--panel);
  border-radius: 50%;
  color: var(--color-accent-ink);
  font: inherit;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
  transition: transform var(--dur-fast) var(--ease-out);
}

.ac-pres-av:hover,
.ac-pres-av.is-pinned {
  transform: translateY(-1px);
  z-index: 2;
}

.ac-pres-av.is-more {
  background: var(--panel-2) !important;
  color: var(--muted);
}

.ac-pres-ini {
  pointer-events: none;
}

.ac-pres-tip {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--color-surface-2);
  color: var(--ink);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease-out);
  z-index: 30;
  box-shadow: var(--shadow-md);
}

.ac-pres-av:hover .ac-pres-tip,
.ac-pres-av:focus-visible .ac-pres-tip,
.ac-pres-av.is-pinned .ac-pres-tip {
  opacity: 1;
}

.ac-pres-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  .ac-pres-av,
  .ac-pres-tip {
    transition: none;
  }
}

/* ================================================================== *
 * Handtag (bottenark) och kant-knapp (iPad)                           *
 * Dolda i desktopläge.                                                 *
 * ================================================================== */

.ac-grip,
.ac-edge {
  display: none;
}

.ac-grip {
  width: 100%;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.ac-grip:active {
  cursor: grabbing;
}

.ac-grip-grip {
  display: block;
  color: var(--color-disabled);
  line-height: 0;
}

.ac-grip-grip svg {
  width: 36px;
  height: 4px;
  display: block;
}

.ac-grip-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.ac-grip-title {
  font-weight: 600;
}

.ac-grip-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--color-accent-ink);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ac-grip-sub {
  color: var(--muted);
  font-size: 11px;
}

.ac-edge-btn {
  width: 44px;
  height: 44px;
}

.ac-edge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--color-accent-ink);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ac-edge-label {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

/* ================================================================== *
 * Telefon (< 820 px): svepbart bottenark                              *
 * ================================================================== */

.ac.is-phone {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: auto;
  max-width: 100%;
  height: 55vh; /* JS sätter exakt px per läge */
  min-height: calc(56px + env(safe-area-inset-bottom, 0px));
  max-height: 100vh;
  border-left: 0;
  border-top: 1px solid var(--line);
  border-radius: 16px 16px 0 0;
  box-shadow: var(--shadow-xl);
  z-index: 60;
  overscroll-behavior: contain;
  transition: height var(--dur-slow) cubic-bezier(0.22, 0.61, 0.36, 1), bottom var(--dur-base) var(--ease-out);
}

.ac.is-phone.is-dragging {
  transition: none;
}

@media (prefers-reduced-motion: reduce) {
  .ac.is-phone {
    transition: none;
  }
}

.ac.is-phone .ac-grip {
  display: flex;
}

.ac.is-phone.is-sheet-collapsed .ac-grip {
  height: calc(56px + env(safe-area-inset-bottom, 0px));
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}

.ac.is-phone:not(.is-sheet-collapsed) .ac-grip {
  height: 26px;
  padding: 7px 12px 4px;
}

.ac.is-phone:not(.is-sheet-collapsed) .ac-grip-row {
  display: none;
}

/* Hopfällt: bara handtaget syns. */
.ac.is-phone.is-sheet-collapsed .ac-people,
.ac.is-phone.is-sheet-collapsed .ac-head,
.ac.is-phone.is-sheet-collapsed .ac-filters,
.ac.is-phone.is-sheet-collapsed .ac-body {
  display: none;
}

.ac.is-phone .ac-body {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.ac.is-phone .ac-composer {
  position: sticky;
  bottom: 0;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
}

/* ================================================================== *
 * iPad (820–1099 px): kolumn till höger, kollapsbar till smal kant    *
 * ================================================================== */

.ac.is-tablet {
  transition: width var(--dur-base) var(--ease-out), flex-basis var(--dur-base) var(--ease-out);
}

@media (prefers-reduced-motion: reduce) {
  .ac.is-tablet {
    transition: none;
  }
}

.ac.is-tablet .ac-edge {
  display: flex;
  position: absolute;
  top: 6px;
  left: 4px;
  z-index: 5;
  align-items: center;
  gap: 6px;
}

.ac.is-tablet:not(.is-railed) .ac-head {
  padding-left: 54px;
}

.ac.is-railed {
  overflow: hidden;
  border-radius: 0;
}

.ac.is-railed .ac-edge {
  position: static;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  padding: 8px 0;
}

.ac.is-railed .ac-people,
.ac.is-railed .ac-head,
.ac.is-railed .ac-filters,
.ac.is-railed .ac-body,
.ac.is-railed .ac-toast {
  display: none;
}

/* ================================================================== *
 * Pekvänligt: 44×44 minimum, luftigare rader, scrollbara chips        *
 * ================================================================== */

.ac.is-phone .ac-ibtn,
.ac.is-tablet .ac-ibtn,
.ac.is-coarse .ac-ibtn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
}

.ac.is-phone .ac-btn,
.ac.is-tablet .ac-btn,
.ac.is-coarse .ac-btn {
  min-height: 44px;
  padding: 8px 14px;
  font-size: 14px;
}

.ac.is-phone .ac-dx,
.ac.is-tablet .ac-dx,
.ac.is-coarse .ac-dx {
  width: 44px;
  height: 44px;
}

.ac.is-phone .ac-clear,
.ac.is-tablet .ac-clear,
.ac.is-coarse .ac-clear {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.ac.is-phone .ac-row,
.ac.is-tablet .ac-row,
.ac.is-coarse .ac-row {
  min-height: 60px;
  padding: 12px;
  gap: 10px;
}

.ac.is-phone .ac-row-title,
.ac.is-tablet .ac-row-title,
.ac.is-coarse .ac-row-title {
  font-size: 14px;
}

.ac.is-phone .ac-group-head,
.ac.is-tablet .ac-group-head,
.ac.is-coarse .ac-group-head {
  padding: 10px 12px 6px;
}

/* Chipsen scrollar i sidled i stället för att radbryta. */
.ac.is-phone .ac-fchiprow,
.ac.is-tablet .ac-fchiprow,
.ac.is-coarse .ac-fchiprow {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin: 0 -12px;
  padding: 0 12px 2px;
}

.ac.is-phone .ac-fchiprow::-webkit-scrollbar,
.ac.is-tablet .ac-fchiprow::-webkit-scrollbar,
.ac.is-coarse .ac-fchiprow::-webkit-scrollbar {
  display: none;
}

.ac.is-phone .ac-fchip,
.ac.is-tablet .ac-fchip,
.ac.is-coarse .ac-fchip {
  flex: 0 0 auto;
  scroll-snap-align: start;
  min-height: 44px;
  padding: 0 12px;
  font-size: 12px;
}

/* 16 px hindrar iOS från att zooma in vid fokus. */
.ac.is-phone .ac-input,
.ac.is-tablet .ac-input,
.ac.is-coarse .ac-input,
.ac.is-phone .ac-select,
.ac.is-tablet .ac-select,
.ac.is-coarse .ac-select {
  font-size: 16px;
}

.ac.is-phone .ac-select,
.ac.is-tablet .ac-select,
.ac.is-coarse .ac-select {
  min-height: 44px;
  padding: 6px 10px;
}

.ac.is-phone .ac-pres-av,
.ac.is-tablet .ac-pres-av,
.ac.is-coarse .ac-pres-av {
  width: 44px;
  height: 44px;
  margin-left: -10px;
  font-size: 13px;
}

@media (pointer: coarse) {
  .ac .ac-ibtn,
  .ac .ac-dx {
    width: 44px;
    height: 44px;
  }

  .ac .ac-btn {
    min-height: 44px;
    padding: 8px 14px;
  }

  .ac .ac-row {
    min-height: 60px;
    padding: 12px;
  }

  .ac .ac-fchiprow {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    margin: 0 -12px;
    padding: 0 12px 2px;
  }

  .ac .ac-fchiprow::-webkit-scrollbar {
    display: none;
  }

  .ac .ac-fchip {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 0 12px;
  }

  .ac .ac-input,
  .ac .ac-select {
    font-size: 16px;
  }

  .ac-pres-av {
    width: 44px;
    height: 44px;
    margin-left: -10px;
    font-size: 13px;
  }

  .ac-lb-close {
    width: 44px;
    height: 44px;
  }
}

/* ================================================================== *
 * Bilagor på liten skärm: rutnät som anpassar sig                     *
 * ================================================================== */

.ac.is-phone .ac-atts,
.ac.is-tablet .ac-atts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
  padding-left: 0;
}

.ac.is-phone .ac-c-body,
.ac.is-tablet .ac-c-body {
  padding-left: 0;
}

.ac.is-phone .ac-att-img,
.ac.is-tablet .ac-att-img {
  width: 100%;
}

.ac.is-phone .ac-att-img img,
.ac.is-tablet .ac-att-img img {
  width: 100%;
  max-width: none;
  height: 92px;
  max-height: none;
}

.ac.is-phone .ac-att-video,
.ac.is-tablet .ac-att-video,
.ac.is-phone .ac-att-file,
.ac.is-tablet .ac-att-file {
  grid-column: 1 / -1;
  max-width: 100%;
}

/* ================================================================== *
 * Lightbox på pekskärm: fyller skärmen, svep nedåt för att stänga     *
 * ================================================================== */

.ac-lightbox {
  touch-action: none;
}

.ac-lb-img {
  transition: transform var(--dur-base) var(--ease-out);
}

.ac-lightbox.is-swiping .ac-lb-img {
  transition: none;
}

.ac-lightbox.is-touch {
  padding: 0;
}

.ac-lightbox.is-touch .ac-lb-img {
  max-width: 100vw;
  max-height: 100vh;
  border-radius: 0;
}

.ac-lightbox.is-touch .ac-lb-close {
  width: 44px;
  height: 44px;
  top: calc(10px + env(safe-area-inset-top, 0px));
  right: 10px;
  border-radius: 50%;
  background: color-mix(in oklch, var(--color-surface) 72%, transparent);
  border: 1px solid color-mix(in oklch, var(--color-ink) 14%, transparent);
}

.ac-lightbox.is-touch .ac-lb-name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  text-align: center;
  text-shadow: 0 1px 6px color-mix(in oklch, var(--color-bg) 80%, transparent);
}

@media (prefers-reduced-motion: reduce) {
  .ac-lb-img {
    transition: none;
  }
}
