/* Zweite mobile Verfeinerung: ruhigere Hierarchie und kompaktere Bedienung. */
@media (width <= 640px) {
  body {
    background:
      radial-gradient(circle at 50% -5%, var(--accent-soft), transparent 32rem),
      linear-gradient(var(--accent-grid) 1px, transparent 1px) 0 0 / 36px 36px,
      linear-gradient(90deg, var(--accent-grid) 1px, transparent 1px) 0 0 / 36px 36px,
      var(--bg);
  }

  .topbar {
    background: color-mix(in srgb, var(--bg) 94%, transparent);
    border-bottom-color: color-mix(in srgb, var(--accent) 18%, var(--border-soft));
    box-shadow: 0 12px 30px rgb(0 0 0 / 18%);
    position: relative;
    top: auto;
  }

  .brand {
    width: 100%;
  }

  .brand-mark {
    border-radius: 11px;
    height: 40px;
    width: 40px;
  }

  .brand-text {
    flex: 1;
    min-width: 0;
  }

  .brand-text .toolpath-line {
    margin-top: 4px;
    width: 34px;
  }

  .brand .theme-select-wrap {
    margin-left: auto;
    max-width: 128px;
    min-height: 40px;
    padding: 5px 8px 5px 10px;
  }

  .brand .theme-select-wrap select {
    max-width: 86px;
    min-height: 32px;
  }

  .topbar-right {
    grid-template-areas:
      "search search"
      "role role"
      "account support"
      "report sync";
  }

  .topbar-right .search-input {
    background: var(--surface);
    border-color: var(--border);
    border-radius: 13px;
    grid-area: search;
    min-height: 46px;
    padding-inline: 13px;
  }

  .topbar-right #roleSwitch {
    grid-area: role;
  }

  .topbar-right #accountBtn { grid-area: account; }
  .topbar-right #supportBtn { grid-area: support; }
  .topbar-right #reportBtn { grid-area: report; }

  .has-admin-control .topbar-right {
    grid-template-areas:
      "search search"
      "role role"
      "account admin"
      "support report"
      "sync sync";
  }

  .topbar-right #adminLoginControl {
    grid-area: admin;
    justify-content: center;
    min-height: 44px;
  }

  .topbar-right .sync-pill {
    grid-area: sync;
    justify-self: stretch;
    min-height: 44px;
  }

  #roleSwitch,
  #libraryToggle,
  #typeSwitch {
    border-radius: 13px;
    padding: 4px;
  }

  #roleSwitch .seg-btn,
  #libraryToggle .seg-btn,
  #typeSwitch .seg-btn {
    border-radius: 10px;
    min-height: 40px;
  }

  .info-banner {
    background: linear-gradient(145deg, var(--surface), color-mix(in srgb, var(--surface) 78%, var(--accent)));
    border-left-width: 1px;
    box-shadow: 0 10px 28px rgb(0 0 0 / 16%);
    font-size: 12.5px;
    line-height: 1.55;
  }

  .info-banner .mw-link {
    justify-content: center;
    min-height: 42px;
  }

  .mode-banner {
    line-height: 1.5;
  }

  .printer-banner-left {
    align-items: flex-start;
    flex-wrap: wrap;
    line-height: 1.5;
  }

  .stat-grid {
    gap: 9px;
    margin-bottom: 20px;
  }

  .stat-card {
    background: linear-gradient(150deg, var(--surface), color-mix(in srgb, var(--surface) 90%, var(--accent)));
    border-radius: 14px;
    box-shadow: 0 8px 22px rgb(0 0 0 / 14%);
    min-height: 86px;
  }

  .stat-card .num {
    font-size: 24px;
  }

  .dash-row {
    gap: 12px;
    margin-bottom: 22px;
  }

  .panel,
  .user-section,
  .idea-section,
  .support-section {
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgb(0 0 0 / 14%);
  }

  .panel {
    padding: 15px;
  }

  .panel h3,
  .user-section h3,
  .idea-section h3,
  .support-section h3,
  .section-heading {
    font-size: 15px;
    letter-spacing: .01em;
  }

  .panel h3 {
    align-items: center;
    display: flex;
    gap: 8px;
  }

  .panel h3::after {
    background: linear-gradient(90deg, var(--accent-border), transparent);
    content: "";
    flex: 1;
    height: 1px;
  }

  .queue-list {
    gap: 8px;
    max-height: 280px;
  }

  .queue-item {
    border-radius: 11px;
    min-height: 48px;
    padding: 9px 10px;
  }

  .queue-item .qmove button,
  .icon-btn {
    height: 38px;
    min-height: 38px;
    width: 38px;
  }

  .user-section,
  .idea-section,
  .support-section {
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    margin-bottom: 16px;
    padding: 15px;
  }

  .idea-card,
  .support-card,
  .user-card {
    border-radius: 14px;
  }

  #libraryToggle {
    margin-bottom: 12px !important;
    overflow-x: auto;
    scrollbar-width: none;
  }

  #libraryToggle::-webkit-scrollbar {
    display: none;
  }

  .section-heading {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    margin: 14px 0 10px;
    padding: 11px 12px;
    position: sticky;
    top: 8px;
    z-index: 8;
  }

  .grid {
    gap: 12px;
  }

  .card {
    border-radius: 15px;
    box-shadow: 0 10px 28px rgb(0 0 0 / 16%);
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    min-height: 150px;
  }

  .card-media {
    aspect-ratio: auto;
    border-bottom: 0;
    border-right: 1px solid var(--border-soft);
    grid-column: 1;
    height: 100%;
    min-height: 150px;
  }

  .card-body {
    grid-column: 2;
    min-width: 0;
    padding: 13px 12px 11px;
  }

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

  .card-footer {
    align-items: flex-end;
    flex-wrap: wrap;
  }

  .link-btn {
    max-width: 118px;
  }

  .status-tag {
    bottom: 8px;
    left: 6px;
    max-width: calc(100% - 12px);
  }

  .priority-tag {
    bottom: auto;
    left: 6px;
    right: auto;
    top: 8px;
  }

  .overlay {
    background: linear-gradient(180deg, rgb(8 8 10 / 55%), rgb(8 8 10 / 88%));
  }

  .overlay .modal,
  .overlay .modal.wide {
    border-color: color-mix(in srgb, var(--accent) 24%, var(--border));
    box-shadow: 0 -18px 60px rgb(0 0 0 / 45%), 0 0 0 1px rgb(255 255 255 / 3%);
  }

  .overlay .modal h2 {
    padding-top: 25px;
  }

  .overlay .modal h2::before {
    background: var(--border);
    border-radius: 99px;
    content: "";
    height: 4px;
    left: 50%;
    position: absolute;
    top: 9px;
    transform: translateX(-50%);
    width: 42px;
  }

  .subsection-label {
    align-items: center;
    display: flex;
    gap: 8px;
    margin-top: 22px;
  }

  .subsection-label::after {
    background: linear-gradient(90deg, var(--accent-border), transparent);
    content: "";
    flex: 1;
    height: 1px;
  }

  footer {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  footer > span,
  footer .footer-event-dropdown,
  footer .language-select-wrap,
  footer .footer-admin-login {
    grid-column: 1 / -1;
  }

  footer > button {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    text-decoration: none;
  }
}

@media (width <= 380px) {
  .card {
    grid-template-columns: 96px minmax(0, 1fr);
  }

  .card-media {
    min-height: 160px;
  }

  footer {
    grid-template-columns: 1fr;
  }

  footer > * {
    grid-column: 1 !important;
  }
}
