/* Mood mobile — Центр управления (iOS-style) */

@media (max-width: 1023px) {
  .mood-cc {
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-rail) + 24);
    display: none;
    pointer-events: none;
  }

  .mood-cc.is-open {
    display: block;
    pointer-events: auto;
  }

  .mood-cc__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 10, 16, 0.22);
    opacity: 0;
    transition: opacity 0.38s ease;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
  }

  html[data-theme="light"] .mood-cc__backdrop {
    background: rgba(15, 23, 42, 0.12);
  }

  .mood-cc.is-open .mood-cc__backdrop {
    opacity: 1;
  }

  .mood-cc__panel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    max-height: min(86dvh, 680px);
    padding: calc(env(safe-area-inset-top, 0px) + 6px) 14px 18px;
    border-radius: 0 0 26px 26px;
    background:
      radial-gradient(130% 90% at 50% -20%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 58%),
      color-mix(in srgb, var(--bg-elevated) 97%, #fff);
    -webkit-backdrop-filter: blur(24px) saturate(1.35);
    backdrop-filter: blur(24px) saturate(1.35);
    box-shadow: 0 24px 56px rgba(0, 0, 0, 0.22);
    transform: translateY(-108%);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  html[data-theme="light"] .mood-cc__panel {
    background:
      radial-gradient(130% 90% at 50% -20%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 58%),
      rgba(255, 255, 255, 0.98);
    box-shadow: 0 20px 48px rgba(15, 23, 42, 0.14);
  }

  .mood-cc.is-open .mood-cc__panel {
    transform: translateY(0);
  }

  .mood-cc__drag {
    flex-shrink: 0;
    touch-action: none;
  }

  .mood-cc__handle {
    display: block;
    width: 36px;
    height: 4px;
    margin: 6px auto 12px;
    border-radius: var(--radius-pill);
    background: color-mix(in srgb, var(--text-muted) 40%, transparent);
  }

  .mood-cc__head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 2px 14px;
  }

  .mood-cc__title {
    flex: 1;
    margin: 0;
    font: 800 18px/1.2 var(--font-display);
    color: var(--text);
  }

  .mood-cc__btn {
    flex: none;
    min-height: 38px;
    padding: 0 16px;
    border: none;
    border-radius: 14px;
    background: color-mix(in srgb, var(--surface-2) 88%, transparent);
    color: var(--text-muted);
    font: 700 13px var(--font-sans);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
  }

  .mood-cc__btn--primary {
    background: var(--accent-dim);
    color: var(--accent);
  }

  .mood-cc__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .mood-cc__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    padding-bottom: 10px;
  }

  .mood-cc__widget {
    position: relative;
    min-height: 92px;
    padding: 12px;
    border-radius: 18px;
    background: color-mix(in srgb, var(--surface-2) 86%, var(--bg-elevated));
    color: var(--text);
    text-decoration: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }

  html[data-theme="light"] .mood-cc__widget {
    background: rgba(248, 250, 252, 0.95);
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
  }

  .mood-cc__widget:active:not(.is-dragging) {
    transform: scale(0.98);
  }

  .mood-cc__widget[data-size="2x1"] {
    grid-column: span 2;
  }

  .mood-cc__widget[data-size="3x1"] {
    grid-column: span 3;
  }

  .mood-cc__widget[data-size="3x2"] {
    grid-column: span 3;
    min-height: 148px;
  }

  .mood-cc.is-edit .mood-cc__widget {
    animation: mood-cc-jiggle 0.28s ease-in-out infinite alternate;
  }

  @keyframes mood-cc-jiggle {
    from { transform: rotate(-0.5deg); }
    to { transform: rotate(0.5deg); }
  }

  .mood-cc__widget-inner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex: 1;
    min-height: 0;
  }

  .mood-cc__widget-icon {
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--accent) 16%, var(--surface-2));
    color: var(--accent);
    overflow: hidden;
  }

  .mood-cc__widget-icon svg {
    width: 20px;
    height: 20px;
  }

  .mood-cc__widget-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .mood-cc__widget-icon--profit {
    background: color-mix(in srgb, var(--success) 18%, var(--surface-2));
    color: var(--success-text, var(--success));
  }

  .mood-cc__widget-icon--withdraw {
    background: color-mix(in srgb, #6366f1 16%, var(--surface-2));
    color: #818cf8;
  }

  .mood-cc__widget-icon--logout {
    background: color-mix(in srgb, var(--danger) 16%, var(--surface-2));
    color: var(--danger-text, var(--danger));
  }

  .mood-cc__widget-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .mood-cc__widget-label {
    font: 600 10px/1.2 var(--font-sans);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-dim);
  }

  .mood-cc__widget-title {
    font: 700 14px/1.25 var(--font-sans);
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mood-cc__widget-meta {
    font: 500 11px/1.35 var(--font-sans);
    color: var(--text-muted);
  }

  .mood-cc__widget-value {
    margin-top: 4px;
    font: 800 22px/1.1 var(--font-display);
    color: var(--text);
  }

  .mood-cc__widget-value--pos {
    color: var(--success-text, #34d399);
  }

  .mood-cc__widget-value--neg {
    color: var(--danger-text, #f87171);
  }

  .mood-cc__widget-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    margin-bottom: 6px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    color: var(--accent);
    font: 700 10px/1 var(--font-sans);
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .mood-cc__stat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 10px;
  }

  .mood-cc__stat-cell {
    padding: 8px 10px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--bg) 40%, transparent);
  }

  html[data-theme="light"] .mood-cc__stat-cell {
    background: rgba(241, 245, 249, 0.9);
  }

  .mood-cc__stat-cell-label {
    display: block;
    font: 600 9px/1.2 var(--font-sans);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 4px;
  }

  .mood-cc__stat-cell-value {
    font: 700 13px/1.2 var(--font-sans);
    color: var(--text);
  }

  .mood-cc__widget--compact {
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 14px 10px;
  }

  .mood-cc__widget--compact .mood-cc__widget-inner {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
  }

  .mood-cc__widget--compact .mood-cc__widget-title {
    white-space: normal;
  }

  .mood-cc__widget-actions {
    position: absolute;
    top: 6px;
    right: 6px;
    display: none;
    gap: 4px;
  }

  .mood-cc.is-edit .mood-cc__widget-actions {
    display: flex;
  }

  .mood-cc__widget-act {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 10px;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
  }

  .mood-cc__catalog {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid color-mix(in srgb, var(--border) 45%, transparent);
  }

  .mood-cc__catalog-item {
    min-height: 44px;
    padding: 10px 12px;
    border: none;
    border-radius: 14px;
    background: color-mix(in srgb, var(--accent-dim) 35%, var(--surface-2));
    color: var(--text);
    font: 600 12px/1.3 var(--font-sans);
    text-align: left;
    cursor: pointer;
  }

  .mood-cc__widget.is-dragging {
    opacity: 0.55;
    z-index: 2;
  }

  .mood-cc__widget--ghost {
    opacity: 0.35;
    background: color-mix(in srgb, var(--accent) 12%, transparent);
  }

  @media (prefers-reduced-motion: reduce) {
    .mood-cc__panel,
    .mood-cc__backdrop,
    .mood-cc.is-edit .mood-cc__widget {
      transition: none !important;
      animation: none !important;
    }
  }
}
