@media (max-width: 1024px) {
  * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    touch-action: pan-y;
    -webkit-text-size-adjust: 100%;
  }
  
  html, body {
    overflow-x: hidden;
    background: #000000;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }
  
  input, textarea, select {
    font-size: 16px !important;
  }
  
  .container {
    width: 100%;
    padding: 0;
    margin: 0;
    background: #000000;
  }
  
  /* ===== HEADER OHNE GRAUEN HINTERGRUND ===== */
  .header-bar {
    background: transparent !important;
    backdrop-filter: none !important;
    padding: 0 12px;
    height: 36px;
    border-bottom: none !important;
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
  }
  
  .header-content {
    display: grid;
    grid-template-columns: 60px 1fr 60px;
    align-items: center;
    height: 36px;
    width: 100%;
  }
  
  .left-section {
    justify-self: start;
    display: flex;
    align-items: center;
  }
  
  .center-section {
    justify-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .right-section {
    justify-self: end;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .main-title,
  #status {
    font-size: 20px !important;
    font-weight: 300 !important;
    color: rgba(255, 255, 255, 0.4) !important;
    letter-spacing: 1px !important;
    line-height: 1 !important;
  }
  
  .main-title::after {
    display: none;
  }
  
  .logout-btn {
    font-size: 11px;
    padding: 0;
    background: transparent;
    border: none;
    color: #007AFF;
  }
  
  .logout-btn:active {
    opacity: 0.6;
  }
  
  .itsh-logo-wrapper {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
  }
  
  .itsh-logo {
    width: 26px;
    height: 26px;
    object-fit: contain;
  }
  
  /* ===== CONTROLS ===== */
  .statistics-section {
    background: #000000;
    padding: 8px 12px 12px;
    overflow: hidden;
  }
  
  .filter-buttons-section {
    margin-bottom: 8px;
  }
  
  .filter-button-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    height: 26px;
    background: rgba(28, 28, 30, 1);
    border-radius: 7px;
    padding: 2px;
  }
  
  .filter-button {
    height: 22px;
    border-radius: 5px;
    background: transparent;
    border: none;
    transition: background 0.25s;
  }
  
  .filter-button.active {
    background: rgba(58, 58, 60, 1);
  }
  
  .filter-button span {
    font-size: 11px;
    font-weight: 400;
    color: rgba(235, 235, 245, 0.6);
  }
  
  .filter-button.active span {
    font-weight: 600;
    color: #FFFFFF;
  }
  
  .filter-info-compact {
    text-align: center;
    padding: 4px 0 0;
  }
  
  .filter-info-compact span {
    font-size: 10px;
    color: rgba(235, 235, 245, 0.6);
  }
  
  /* ===== STATS 2x2 MIT HOHER SPEZIFITÄT ===== */
  .statistics-section .stats-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    grid-template-rows: repeat(2, 1fr) !important;
    gap: 6px !important;
    margin-top: 10px !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden !important;
    padding: 0 !important;
  }

  .statistics-section .stat-card {
    background: rgba(28, 28, 30, 1) !important;
    border-radius: 8px !important;
    padding: 8px 8px !important;
    min-height: 55px !important;
    width: 100% !important;
    max-width: none !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 1 !important;
  }

  .statistics-section .stat-label {
    font-size: 8px !important;
    color: rgba(235, 235, 245, 0.6) !important;
    margin-bottom: 3px !important;
    line-height: 1.3 !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    text-align: center !important;
    width: 100% !important;
    padding: 0 4px !important;
    word-break: break-word !important;
    max-height: 24px !important;
  }

  .statistics-section .stat-value {
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #FFFFFF;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    width: 100% !important;
    text-align: center !important;
  }
  
  .add-trade-bar {
    height: 40px;
    background: rgba(28, 28, 30, 1);
    border-radius: 12px;
    margin-top: 10px;
  }
  
  .add-trade-bar span {
    font-size: 14px;
    color: #007AFF;
  }
  
  /* ===== TRADES ===== */
  #tradesContainer {
    padding: 12px;
    gap: 10px;
  }
  
  .trade-card-wrapper {
    height: auto;
    overflow: hidden;
  }
  
  .trade-front, .trade-back {
    height: auto;
    min-height: 220px;
    background: rgba(28, 28, 30, 1);
    border-radius: 16px;
    overflow: hidden;
  }
  
  .trade-back {
    position: relative !important;
    padding: 0 !important;
    display: block !important;
  }
  
  .trade-content {
    padding: 6px;
    overflow: hidden;
  }
  
  /* ===== COIN HEADER ===== */
  .trade-info {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    padding-bottom: 5px;
    border-bottom: 0.5px solid rgba(84, 84, 86, 0.3);
  }
  
  .coin-section {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
    min-width: 0;
  }
  
  .coin-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    flex-shrink: 0;
  }
  
  .coin-details {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
  }
  
  .coin-details h3 {
    font-size: 10px;
    font-weight: 600;
    color: #FFFFFF;
    margin: 0;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  .coin-details p {
    font-size: 8px;
    color: rgba(235, 235, 245, 0.6);
    margin: 0;
  }
  
  .trade-time {
    display: block !important;
    text-align: center;
    padding: 4px 0;
    margin-top: 6px;
    font-size: 8px !important;
    font-weight: 500 !important;
    color: rgba(235, 235, 245, 0.9) !important;
    background: rgba(44, 44, 46, 0.3);
    border-radius: 4px;
  }
  
  /* ===== METRICS GRID ===== */
  .trade-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    width: 100%;
    overflow: hidden;
    padding-bottom: 0 !important;
    border-bottom: none !important;
    margin-bottom: 6px;
  }
  
  .metric {
    background: rgba(44, 44, 46, 0.6);
    border-radius: 5px;
    padding: 3px;
    min-height: 32px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1px;
    overflow: hidden;
  }
  
  .metric-label {
    font-size: 6px;
    font-weight: 700;
    color: rgba(235, 235, 245, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.1px;
    line-height: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
    width: 100%;
  }
  
  .metric-value {
    font-size: 8px;
    font-weight: 600;
    color: #FFFFFF;
    letter-spacing: -0.05px;
    line-height: 1.1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
    width: 100%;
  }
  
  .tp-value {
    color: #34C759 !important;
  }
  
  .sl-info {
    color: rgba(235, 235, 245, 0.6) !important;
  }
  
  .sl-trigger {
    color: #FF3B30 !important;
  }
  
  .time-bar {
    display: block !important;
    text-align: center;
    padding: 4px 0;
    margin-top: 2px;
    font-size: 8px;
    font-weight: 500;
    color: rgba(235, 235, 245, 0.9) !important;
    background: rgba(44, 44, 46, 0.3);
    border-radius: 4px;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  .time-bar span {
    font-size: 8px;
    font-weight: 500;
    color: rgba(235, 235, 245, 0.9) !important;
  }
  
  .trade-content .time-bar,
  .trade-front .time-bar {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  .note-indicator {
    right: 20px !important;
    bottom: 30px !important;
    width: 8px !important;
    height: 8px !important;
    background: #FF9F0A !important;
    z-index: 100 !important;
  }
  
  /* ===== DROPDOWNS KLEIN ===== */
  .metric:has(.side-dropdown),
  .metric:has(.status-dropdown) {
    min-height: 36px;
  }
  
  .side-dropdown, .status-dropdown {
    width: 100%;
    height: 20px;
    background: rgba(58, 58, 60, 0.6);
    border: none;
    border-radius: 4px;
    font-size: 7px !important;
    font-weight: 600;
    color: #FFFFFF;
    padding: 0 3px;
    -webkit-appearance: none;
    appearance: none;
    margin-top: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
  }
  
  .side-dropdown::after,
  .status-dropdown::after {
    display: none;
  }
  
  .side-dropdown.side-long {
    color: #34C759;
  }
  
  .side-dropdown.side-short {
    color: #FF3B30;
  }
  
  .status-dropdown.status-filled {
    color: #34C759;
  }
  
  .status-dropdown.status-cancelled {
    color: #FF3B30;
  }
  
  .status-dropdown.status-partial {
    color: #FF9F0A;
  }
  
  .status-dropdown.status-new,
  .status-dropdown.status-pending {
    color: #007AFF;
  }
  
  /* ===== DELETE BUTTON X OBEN LINKS OHNE LEISTE ===== */
  .delete-btn {
    position: absolute !important;
    top: 6px !important;
    left: 6px !important;
    width: 18px !important;
    height: 18px !important;
    background: none !important;
    backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    color: #FF3B30 !important;
    font-size: 18px !important;
    opacity: 1 !important;
    z-index: 10;
    line-height: 1;
    padding: 0 !important;
    font-weight: 300;
    box-shadow: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  
  .delete-btn::before,
  .delete-btn::after {
    display: none !important;
  }
  
  .trade-card-wrapper:hover .delete-btn {
    opacity: 1;
    background: none !important;
  }
  
  /* ===== NOTES ===== */
  .notes-back-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: rgba(58, 58, 60, 0.8);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 10px;
    color: #007AFF;
    font-size: 11px;
    z-index: 10;
  }
  
  .notes-section {
    position: relative;
    height: 100%;
    padding-bottom: 88px; /* Angepasst für zwei link-bar-Elemente untereinander */
  }
  
  .notes-textarea {
    background: rgba(44, 44, 46, 0.6);
    border: none;
    border-radius: 12px;
    color: #FFFFFF;
    font-size: 16px !important;
    padding: 8px;
    width: calc(100% - 12px);
    height: calc(100% - 120px); /* Angepasst für zwei link-bar-Elemente */
    margin: 32px 6px 0 6px;
    resize: none;
    display: block;
  }
  
  .link-bar-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(18, 18, 18, 0.95);
    border-top: 0.5px solid rgba(84, 84, 86, 0.3);
    border-radius: 0 0 14px 14px;
    padding: 8px;
    display: flex;
    flex-direction: column; /* Vertikale Anordnung auf Mobilgeräten */
    gap: 8px;
    z-index: 10;
  }
  
  .link-bar {
    display: flex;
    align-items: center;
    gap: 5px;
    width: 100%; /* Volle Breite für jede link-bar */
  }
  
  .link-input, .link-display {
    flex: 1;
    background: rgba(44, 44, 46, 0.6);
    border: none;
    border-radius: 8px;
    color: #FFFFFF;
    font-size: 16px !important;
    padding: 5px 6px;
    height: 26px;
  }
  
  .link-display {
    color: #007AFF;
  }
  
  .link-btn {
    width: 26px;
    height: 26px;
    background: #007AFF;
    border: none;
    border-radius: 8px;
    color: #FFFFFF;
    font-size: 11px;
  }
  
  .link-btn.edit-btn {
    background: #FF9F0A;
  }
  
  /* ===== MODALS ===== */
  .filter-dropdown-modal {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
  }
  
  .filter-dropdown-content,
  .form-container {
    background: rgba(28, 28, 30, 1);
    border-radius: 14px;
    width: 90%;
    margin: 20% auto;
  }
  
  .filter-dropdown-header {
    border-bottom: 0.5px solid rgba(84, 84, 86, 0.3);
    padding: 16px;
  }
  
  .filter-dropdown-header h3 {
    font-size: 17px;
    font-weight: 600;
    color: #FFFFFF;
  }
  
  .filter-close {
    color: #007AFF;
    font-size: 17px;
  }
  
  .filter-option {
    background: transparent;
    border-bottom: 0.5px solid rgba(84, 84, 86, 0.3);
    padding: 14px 16px;
    font-size: 15px;
    color: #FFFFFF;
  }
  
  .filter-option.selected {
    background: rgba(58, 58, 60, 0.3);
    color: #007AFF;
  }
  
  .reset-filter-btn {
    width: 100%;
    height: 44px;
    background: #FF3B30;
    border: none;
    border-radius: 10px;
    color: #FFFFFF;
    font-size: 15px;
    font-weight: 600;
    margin-top: 12px;
  }
  
  .editable {
    cursor: pointer;
    border-radius: 3px;
    padding: 1px 2px;
    margin: -1px -2px;
  }
  
  .editable:active {
    background: rgba(58, 58, 60, 0.3);
  }
  
  .edit-input {
    background: rgba(44, 44, 46, 0.9);
    border: 2px solid #007AFF;
    border-radius: 5px;
    color: #FFFFFF;
    font-size: 16px !important;
    width: 100%;
    padding: 2px 4px;
  }
  
  .autocomplete-suggestions {
    position: absolute;
    background: rgba(28, 28, 30, 1);
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    max-height: 160px;
    overflow-y: auto;
    z-index: 1000;
    margin-top: 4px;
  }
  
  .autocomplete-suggestions div,
  .suggestion-item {
    padding: 8px 10px;
    border-bottom: 0.5px solid rgba(84, 84, 86, 0.3);
    font-size: 11px;
    color: #FFFFFF;
  }
  
  button, .filter-button, .add-trade-bar {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  
  ::-webkit-scrollbar {
    width: 2px;
  }
  
  ::-webkit-scrollbar-thumb {
    background: rgba(235, 235, 245, 0.2);
  }
}

/* ===== PARTIKEL FÜR MOBILE - SCHWARZ & BUNT ===== */
@media (max-width: 1024px) {
  
  #particles-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: -1 !important;
    overflow: hidden !important;
    background: #000000 !important;
    pointer-events: none !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  .particle {
    position: absolute !important;
    background-color: #FFD700 !important;
    border-radius: 50% !important;
    opacity: 0.30 !important;
    animation: float 6s ease-in-out infinite !important;
    pointer-events: none !important;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.4) !important;
  }

  .particle.variant-1 {
    background-color: #FFA500 !important;
    animation-duration: 8s !important;
    opacity: 0.28 !important;
    box-shadow: 0 0 12px rgba(255, 165, 0, 0.5) !important;
  }

  .particle.variant-2 {
    background-color: #00FF7F !important;
    animation-duration: 10s !important;
    opacity: 0.25 !important;
    box-shadow: 0 0 10px rgba(0, 255, 127, 0.4) !important;
  }

  .particle.variant-3 {
    background-color: #00CED1 !important;
    animation-duration: 12s !important;
    opacity: 0.22 !important;
    box-shadow: 0 0 10px rgba(0, 206, 209, 0.4) !important;
  }

  @keyframes float {
    0%, 100% {
      transform: translateY(0px) translateX(0px) rotate(0deg);
      opacity: 0;
    }
    10% {
      opacity: 0.25 !important;
    }
    50% {
      transform: translateY(-30px) translateX(15px) rotate(180deg);
      opacity: 0.45 !important;
    }
    90% {
      opacity: 0.20 !important;
    }
  }

  .container {
    position: relative !important;
    z-index: 1 !important;
    background: transparent !important;
  }

  .header-bar,
  .statistics-section,
  #tradesContainer,
  .trade-card-wrapper {
    position: relative !important;
    z-index: 2 !important;
  }
}

/* ===== TABLETS - 2x2 BEIBEHALTEN ===== */
@media (max-width: 1024px) and (min-width: 769px) {
  .main-title,
  #status {
    font-size: 22px !important;
  }
  
  .trade-metrics {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .statistics-section .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    grid-template-rows: repeat(2, 1fr) !important;
    gap: 6px !important;
  }
  
  .statistics-section .stat-card {
    min-height: 50px !important;
    padding: 8px 10px !important;
  }
  
  .statistics-section .stat-label {
    font-size: 9px !important;
  }
  
  .statistics-section .stat-value {
    font-size: 14px !important;
  }
  
  .metric {
    padding: 4px;
    min-height: 34px;
  }
  
  .metric-label {
    font-size: 7px;
  }
  
  .metric-value {
    font-size: 9px;
  }
}

/* ===== LANDSCAPE - 2x2 BEIBEHALTEN ===== */
@media (max-width: 768px) and (orientation: landscape) {
  .main-title,
  #status {
    font-size: 18px !important;
  }
  
  .statistics-section .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    grid-template-rows: repeat(2, 1fr) !important;
    gap: 5px !important;
  }
  
  .statistics-section .stat-card {
    min-height: 42px !important;
  }
  
  .statistics-section .stat-label {
    font-size: 7px !important;
  }
  
  .statistics-section .stat-value {
    font-size: 11px !important;
  }
  
  .trade-metrics {
    grid-template-columns: repeat(5, 1fr);
    gap: 2px;
  }
  
  .metric {
    padding: 2px;
    min-height: 28px;
  }
  
  .metric-label {
    font-size: 5px;
  }
  
  .metric-value {
    font-size: 7px;
  }
}

/* ===== iOS SAFE AREA ===== */
@supports (padding: env(safe-area-inset-top)) {
  .header-bar {
    padding-top: max(6px, env(safe-area-inset-top)) !important;
    padding-bottom: 6px !important;
    height: auto !important;
  }
  
  .statistics-section {
    padding-left: max(12px, env(safe-area-inset-left)) !important;
    padding-right: max(12px, env(safe-area-inset-right)) !important;
  }
  
  #tradesContainer {
    padding-left: max(12px, env(safe-area-inset-left)) !important;
    padding-right: max(12px, env(safe-area-inset-right)) !important;
    padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
  }
}

/* ===== FONTS ===== */
@media (max-width: 1024px) {
  body, button, input, select, textarea {
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
  }

  .form-title {
    font-size: 20px !important;
    color: #FFFFFF !important;
    background: none !important;
    -webkit-background-clip: initial !important;
    -webkit-text-fill-color: initial !important;
    text-shadow: none !important;
  }
}