/* ══════════════════════════════════════
       기록 패널
    ══════════════════════════════════════ */
    .history-panel {
      display: none;
      flex-direction: column;
      height: 100%;
    }
    .history-panel.visible { display: flex; }

    /* 탭 */
    .history-tabs {
      display: flex;
      border-bottom: 1px solid var(--border);
      padding: 0 4px;
      flex-shrink: 0;
    }
    .history-tab {
      flex: 1;
      padding: 16px 0 14px;
      font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
      font-size: 17px;
      font-weight: 600;
      color: var(--text-tertiary);
      text-align: center;
      cursor: pointer;
      border: none;
      background: transparent;
      position: relative;
      transition: color 0.2s;
    }
    .history-tab.active { color: var(--text); }
    .history-tab.active::after {
      content: '';
      position: absolute;
      bottom: -1px; left: 12%; right: 12%;
      height: 3px;
      background: var(--primary);
      border-radius: 3px 3px 0 0;
    }
    .tab-dot {
      display: inline-block;
      width: 7px; height: 7px;
      background: #FF6B6B;
      border-radius: 50%;
      margin-left: 5px;
      vertical-align: middle;
      position: relative;
      top: -2px;
    }

    /* 안내 배너 */
    .history-notice {
      margin: 0 14px;
      padding: 10px 14px;
      background: #FFFBF0;
      border: 1px solid #FDEBBF;
      border-radius: 10px;
      font-size: 13px;
      color: #A07840;
      line-height: 1.5;
      flex-shrink: 0;
    }

    /* 스크롤 영역 */
    .history-scroll {
      flex: 1;
      overflow-y: auto;
      padding: 12px 14px 100px;
    }

    /* 카드 그리드 */
    .history-grid {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 10px;
    }

    /* 개별 카드 */
    .letter-card {
      background: #fff;
      border-radius: 14px;
      border: 1.5px solid var(--border);
      overflow: hidden;
      cursor: pointer;
      transition: all 0.2s ease;
      position: relative;
      animation: cardIn 0.3s ease backwards;
    }
    .letter-card:hover { border-color: var(--mysky); box-shadow: 0 4px 12px rgba(32,178,170,0.1); transform: translateY(-2px); }
    .letter-card.selected-card { border-color: var(--mysky); box-shadow: 0 0 0 2px rgba(32,178,170,0.2); }

    @keyframes cardIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }
    .letter-card:nth-child(1){animation-delay:0.04s}
    .letter-card:nth-child(2){animation-delay:0.08s}
    .letter-card:nth-child(3){animation-delay:0.12s}
    .letter-card:nth-child(4){animation-delay:0.16s}
    .letter-card:nth-child(5){animation-delay:0.20s}

    /* 뱃지 */
    .card-badge {
      position: absolute;
      top: 7px; right: 7px;
      padding: 3px 8px;
      border-radius: 20px;
      font-size: 11px;
      font-weight: 600;
      letter-spacing: -0.1px;
      z-index: 2;
      white-space: nowrap;
    }
    .badge-writing  { background: #FF6B6B; color: #fff; }
    .badge-auto     { background: rgba(32,178,170,0.12); color: var(--primary); border: 1px solid rgba(32,178,170,0.3); }
    .badge-manual   { background: rgba(80,130,220,0.1); color: #4A82D8; border: 1px solid rgba(80,130,220,0.25); }

    /* 카드 썸네일 */
    .card-thumb {
      width: 100%;
      aspect-ratio: 7/9;
      background: linear-gradient(160deg, #FAF8F5 0%, #F3EFE9 100%);
      display: flex;
      align-items: center;
      justify-content: center;
      position: relative;
      overflow: hidden;
    }
    .card-thumb::before {
      content: '';
      position: absolute;
      top: 12px; bottom: 12px; left: 10px; right: 10px;
      background: #fff;
      border-radius: 6px;
      box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    }
    .card-thumb-lines {
      position: absolute;
      top: 36px; left: 18px; right: 18px;
      bottom: 18px;
      display: flex;
      flex-direction: column;
      gap: 7px;
    }
    .thumb-line {
      height: 3px;
      border-radius: 2px;
      background: #E8E3DC;
      flex-shrink: 0;
    }
    .thumb-line:nth-child(1)  { width: 88%; }
    .thumb-line:nth-child(2)  { width: 95%; }
    .thumb-line:nth-child(3)  { width: 82%; }
    .thumb-line:nth-child(4)  { width: 90%; }
    .thumb-line:nth-child(5)  { width: 75%; }
    .thumb-line:nth-child(6)  { width: 92%; }
    .thumb-line:nth-child(7)  { width: 60%; }
    .thumb-line:nth-child(8)  { width: 85%; }
    .thumb-line:nth-child(9)  { width: 50%; }
    /* 단락 구분처럼 간격 조금 벌리기 */
    .thumb-line:nth-child(4)  { margin-top: 4px; }
    .thumb-line:nth-child(8)  { margin-top: 4px; }
    .thumb-icon {
      position: absolute;
      top: 10px; left: 50%; transform: translateX(-50%);
      font-size: 16px;
      z-index: 1;
    }
    .card-delete {
      position: absolute;
      bottom: 7px; right: 7px;
      width: 28px; height: 28px;
      background: rgba(255,255,255,0.9);
      border: 1px solid #E8E2D8;
      border-radius: 7px;
      display: flex; align-items: center; justify-content: center;
      cursor: pointer;
      transition: all 0.15s;
      z-index: 2;
    }
    .card-delete:hover { background: #FEE; border-color: #F9A8A8; }
    .card-delete svg { width: 15px; height: 15px; stroke: #9BA8B7; }
    .card-delete:hover svg { stroke: #E57373; }

    /* 카드 하단 정보 */
    .card-info {
      padding: 8px 8px 9px;
    }
    .card-stats {
      display: flex;
      align-items: center;
      gap: 6px;
      margin-bottom: 5px;
      flex-wrap: nowrap;
    }
    .stat-item {
      display: flex;
      align-items: center;
      gap: 2px;
      flex-shrink: 0;
    }
    .stat-item svg {
      width: 11px;
      height: 11px;
      flex-shrink: 0;
    }
    .stat-item span { font-size: 11px; font-weight: 600; }
    /* 편지 - 민트 */
    .stat-letter { color: #17918B; }
    .stat-letter svg { stroke: #17918B; }
    /* 사진 - 블루 */
    .stat-photo  { color: #2E86C1; }
    .stat-photo  svg { stroke: #2E86C1; }
    /* 스티커 - 핑크 */
    .stat-sticker{ color: #C0417A; }
    .stat-sticker svg { stroke: #C0417A; }
    .card-time {
      font-size: 13px;
      font-weight: 600;
      color: var(--text-secondary);
    }

    /* 호버 돋보기 오버레이 */
    .card-hover-overlay {
      position: absolute;
      inset: 0;
      background: rgba(255,255,255,0.45);
      display: flex;
      align-items: center;
      justify-content: center;
      opacity: 0;
      transition: opacity 0.2s ease;
      border-radius: inherit;
      z-index: 3;
      pointer-events: none;
    }
    .letter-card:hover .card-hover-overlay { opacity: 1; }
    .magnifier-icon {
      width: 64px; height: 64px;
      background: #fff;
      border-radius: 50%;
      display: flex; align-items: center; justify-content: center;
      box-shadow: 0 4px 16px rgba(0,0,0,0.13);
      transform: scale(0.8);
      transition: transform 0.2s ease;
    }
    .letter-card:hover .magnifier-icon { transform: scale(1); }
    .magnifier-icon svg { width: 34px; height: 34px; }

    /* 왼쪽패널 하단픽스 버튼 - 공통으로 쓴다  */
    .history-actions {
      position: absolute;
      bottom: 0; left: 0; right: 0;
      padding: 10px 14px 14px;
      background: #fff;
      display: flex;
      gap: 8px;
      flex-shrink: 0;
      border-top: 1px solid var(--border);
      z-index: 10;
    }
    .action-btn {
      flex: 1;
      padding: 10px 6px;
      border-radius: 10px;
      font-size: 13px;
      font-weight: 500;
      cursor: pointer;
      border: none;
      text-align: center;
    }
    .action-btn-ghost {
      background: var(--bg-secondary);
      color: var(--text-secondary);
      border: 1px solid var(--border);
    }
    .action-btn-ghost:hover { background: #f0f0f0; }
    .action-btn-danger {
      background: #FFF0F0;
      color: #E57373;
      border: 1px solid #FFCDD2;
    }
    .action-btn-danger:hover { background: #FFE5E5; border-color: #EF9A9A; }

    /* 빈 상태 */
    .history-empty {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: 48px 24px;
      color: var(--text-tertiary);
      text-align: center;
      gap: 10px;
    }
    .history-empty-icon { font-size: 40px; opacity: 0.5; }
    .history-empty-text { font-size: 15px; font-weight: 500; color: var(--text-secondary); }
    .history-empty-sub { font-size: 13px; color: var(--text-tertiary); line-height: 1.6; }