/* ITSK Forum – Mobile / Tablet (low-power, no animations) */
html { overflow-x: hidden; }
body { overflow-x: hidden; -webkit-text-size-adjust: 100%; }
img, video, iframe, canvas, svg { max-width: 100%; height: auto; }
.post-content img, .post-content video, .post-content iframe,
.ql-editor img, .ql-editor video, .ql-editor iframe.ql-video { max-width: 100% !important; height: auto; }
.post-content pre, .ql-editor pre, .pre-wrap, pre code {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table { max-width: 100%; }

/* Header / burger */
.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  gap: 8px;
  padding-top: 4px;
  padding-bottom: 4px;
}
.header-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.hdr-icon {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; padding: 8px;
  color: var(--muted); text-decoration: none; border-radius: 8px; position: relative;
}
.hdr-icon .badge { position: absolute; top: 4px; right: 2px; }
.nav-burger {
  display: none;
  width: 44px; height: 44px;
  align-items: center; justify-content: center; flex-direction: column; gap: 5px;
  cursor: pointer; border-radius: 8px; border: 1px solid var(--border); background: var(--card);
}
.nav-burger span {
  display: block; width: 20px; height: 2px; background: var(--text); border-radius: 1px;
}
.main-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.main-nav a, .main-nav span {
  color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: 8px; font-size: 0.92rem;
}
.main-nav a:hover { color: var(--text); background: rgba(255,255,255,0.05); }

.footer-meta {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 0; border-top: 1px solid var(--border); margin-top: 40px;
  font-size: 0.9rem; color: var(--muted); flex-wrap: wrap; gap: 12px;
}
.footer-links { padding: 12px 0 28px; text-align: center; color: var(--muted); font-size: 0.85rem; }

/* Forms: prevent iOS zoom */
input, textarea, select, button { font-size: 16px; max-width: 100%; }
textarea { max-width: 100%; width: 100%; }
form input[type="text"], form input[type="password"], form input[type="email"],
form input[type="search"], form input[type="url"], form input:not([type]),
form textarea, form select { width: 100%; max-width: 100%; box-sizing: border-box; }

/* Shoutbox */
#shout-list, .shout-list, .shoutbox #shouts, .shoutbox .messages {
  max-height: 220px; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.shoutbox form, #shout-form { display: flex; flex-wrap: wrap; gap: 8px; }
.shoutbox form input, #shout-form input[type="text"], #shout-form input:not([type]) {
  flex: 1 1 160px; min-width: 0; width: auto;
}
.shoutbox form button, #shout-form button { min-height: 44px; }

/* Chip-Spiel */
.spiel-mobile-note {
  display: none; color: var(--muted); font-size: 0.9rem; margin: 0 0 10px;
  padding: 10px 12px; background: var(--card); border: 1px solid var(--border); border-radius: 8px;
}
.spiel-fs-btn {
  background: #1b1f29; color: #eae8e4; border: 1px solid #2a2f3a;
  border-radius: 8px; padding: 10px 14px; cursor: pointer; min-height: 44px;
}

/* Book controls */
.book-btn { min-height: 44px; min-width: 44px; padding: 10px 12px; }
.book-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; }

/* Admin user cards */
.admin-user-row, .admin-grid .card { overflow-wrap: anywhere; word-break: break-word; }

/* PM bubbles */
.msg-bubble-me { border-color: rgba(77,159,255,0.35); }
.msg-thread .card { max-width: 100%; }

@media (max-width: 900px) {
  .container { padding-left: 14px; padding-right: 14px; }
  .forum-row {
    grid-template-columns: 48px 1fr !important;
  }
  .forum-latest {
    grid-column: 1 / -1;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
    margin-top: 4px;
  }
  .wk-web-layout { grid-template-columns: 1fr !important; }
  .spiel-frame-wrap {
    aspect-ratio: auto;
    min-height: calc(100vh - 160px);
    height: calc(100vh - 160px);
  }
}

@media (max-width: 768px) {
  /* Burger menu */
  .nav-burger { display: inline-flex; }
  .main-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 8px 0 12px;
    border-top: 1px solid var(--border);
    order: 10;
  }
  .nav-toggle:checked ~ .main-nav { display: flex; }
  .main-nav a, .main-nav span {
    min-height: 44px;
    display: flex; align-items: center;
    padding: 12px 14px;
    font-size: 1rem;
  }
  /* hide duplicate icons inside nav on mobile? keep messages only in header-actions */
  header .container { height: auto; min-height: 56px; }

  h1 { font-size: 1.35rem; margin: 18px 0 14px; }
  .forum, .thread, .post, .card, .shoutbox { padding: 14px; }

  .thread-row {
    grid-template-columns: 1fr !important;
    gap: 6px;
  }
  .thread-stats { text-align: left; white-space: normal; }

  .post-actions { gap: 8px; }
  .post-actions .btn-thanks, .post-actions button, .post-actions a.btn-thanks {
    min-height: 44px; padding: 10px 12px;
  }

  .poll-box { padding: 14px; width: 100%; }
  .profile-stats { grid-template-columns: repeat(2, 1fr); }
  .profile-banner { height: 100px; }

  .admin-grid { grid-template-columns: 1fr; }
  .admin-links a { min-height: 44px; display: inline-flex; align-items: center; }

  /* Tables → scroll */
  table { display: block; overflow-x: auto; width: 100%; }
  .table-wrap, .admin-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  .spiel-bar { flex-wrap: wrap; gap: 10px; }
  .spiel-mobile-note { display: block; }
  .spiel-frame-wrap {
    min-height: calc(100vh - 180px);
    height: calc(100vh - 180px);
    border-radius: 8px;
  }

  .wk-toolbar { flex-direction: column; align-items: stretch; }
  .wk-btn { width: 100%; min-height: 44px; text-align: center; }
  .wk-code { font-size: 15px !important; }
  .wk-frame { height: 280px; }

  .footer-meta { flex-direction: column; align-items: flex-start; margin-top: 24px; padding: 16px 0; }
}

@media (max-width: 480px) {
  .container { padding-left: 10px; padding-right: 10px; }
  .logo { font-size: 1.05rem; }
  .forum-row { grid-template-columns: 40px 1fr !important; gap: 10px !important; padding: 12px !important; }
  .forum-icon { width: 40px; height: 40px; }
  .latest-title { max-width: 100% !important; white-space: normal !important; }
  .cat-header { font-size: 0.95rem; }
  .profile-stats { grid-template-columns: 1fr 1fr; }
  .rank-badge, .role-pill { font-size: 0.72rem; }
  /* Book: single page portrait already via usePortrait */
  .pdf-book, .book-stage { width: 100% !important; max-width: 100%; }
  .book-bar .book-btn { flex: 1 1 auto; }
}

/* Quill toolbar wrap */
.ql-toolbar.ql-snow {
  display: flex; flex-wrap: wrap; gap: 2px;
  white-space: normal !important;
}
.ql-toolbar.ql-snow .ql-formats {
  margin-right: 8px !important;
  margin-bottom: 4px;
}
.ql-container.ql-snow { min-height: 140px; }
.ql-editor { min-height: 140px; font-size: 16px; }

/* Avoid sticky submit covering keyboard – keep submit in flow */
form button[type="submit"] { position: static; }

/* Overflow safety for long unbroken strings */
.post-content, .card, .notif-item, .msg-item, .thread-row, .forum-main {
  overflow-wrap: anywhere; word-break: break-word;
}
