/* 바람 입자 캔버스(z-index: 450) 위에 팝업이 표시되도록 z-index 설정
   @layer 밖에 위치해야 non-layered CSS인 MapLibre 스타일보다 우선순위를 가짐 */
.maplibregl-popup {
  z-index: 500;
}

/* 사고 팝업 — @layer 밖에 위치해야 MapLibre 기본 스타일을 덮어씀 */
.incident-popup .maplibregl-popup-content {
  background: transparent;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  border: none;
}
.incident-popup .maplibregl-popup-tip {
  border-top-color: var(--bg-elevated);
  border-bottom-color: var(--bg-elevated);
  border-left-color: transparent;
  border-right-color: transparent;
}

@layer components {
  /* ═══ CCTV 지도 팝업 (어두운 톤) ═══ */
  .cctv-dark-popup .maplibregl-popup-content {
    background: #1a1f2e;
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
  }
  .cctv-dark-popup .maplibregl-popup-tip {
    border-top-color: #1a1f2e;
    border-bottom-color: #1a1f2e;
    border-left-color: transparent;
    border-right-color: transparent;
  }
  .cctv-dark-popup .maplibregl-popup-close-button {
    color: #888;
    font-size: 16px;
    right: 4px;
    top: 2px;
  }
  .cctv-dark-popup .maplibregl-popup-close-button:hover {
    color: #fff;
    background: transparent;
  }

  /* ═══ Incidents 사고 팝업 ✕ 버튼 — 라이트 지도 기준 검은색 고정 ═══ */
  .incident-popup .maplibregl-popup-close-button {
    color: #1a1d21;
    background: transparent;
    width: 16px;
    height: 16px;
    font-size: 16px;
    line-height: 16px;
    top: 6px;
    right: 6px;
  }
  .incident-popup .maplibregl-popup-close-button:hover {
    color: #000;
    background: transparent;
  }

  /* ═══ Scrollbar ═══ */
  .scrollbar-thin {
    scrollbar-width: thin;
    scrollbar-color: var(--stroke-light) transparent;
  }

  .scrollbar-thin::-webkit-scrollbar {
    width: 6px;
    height: 6px;
  }

  .scrollbar-thin::-webkit-scrollbar-track {
    background: transparent;
  }

  .scrollbar-thin::-webkit-scrollbar-thumb {
    background: var(--stroke-light);
    border-radius: 3px;
  }

  .scrollbar-thin::-webkit-scrollbar-thumb:hover {
    background: var(--stroke-default);
  }

  /* ═══ Prediction Input Form ═══ */
  .prd-i {
    width: 100%;
    padding: 6px 10px;
    background: var(--bg-base);
    border: 1px solid var(--stroke-default);
    border-radius: 6px;
    color: var(--fg-default);
    font-family: var(--font-korean);
    font-size: 0.75rem;
    outline: none;
  }

  .prd-i:focus {
    border-color: var(--color-accent);
  }

  .prd-i::placeholder {
    color: var(--fg-disabled);
  }

  /* Date/Time picker custom styling */
  .prd-date-input::-webkit-calendar-picker-indicator,
  .prd-time-input::-webkit-calendar-picker-indicator {
    opacity: 0;
    position: absolute;
    right: 0;
    width: 28px;
    height: 100%;
    cursor: pointer;
  }

  .prd-date-input,
  .prd-time-input {
    font-size: 0.75rem;
    color-scheme: dark;
  }

  .prd-date-input::-webkit-datetime-edit,
  .prd-time-input::-webkit-datetime-edit {
    color: var(--fg-sub);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.3px;
  }

  .prd-date-input::-webkit-datetime-edit-fields-wrapper,
  .prd-time-input::-webkit-datetime-edit-fields-wrapper {
    padding: 0;
  }

  .prd-date-input::-webkit-datetime-edit-year-field,
  .prd-date-input::-webkit-datetime-edit-month-field,
  .prd-date-input::-webkit-datetime-edit-day-field,
  .prd-time-input::-webkit-datetime-edit-hour-field,
  .prd-time-input::-webkit-datetime-edit-minute-field,
  .prd-time-input::-webkit-datetime-edit-ampm-field {
    color: var(--fg-sub);
    background: transparent;
    padding: 1px 2px;
    border-radius: 2px;
  }

  .prd-date-input::-webkit-datetime-edit-year-field:focus,
  .prd-date-input::-webkit-datetime-edit-month-field:focus,
  .prd-date-input::-webkit-datetime-edit-day-field:focus,
  .prd-time-input::-webkit-datetime-edit-hour-field:focus,
  .prd-time-input::-webkit-datetime-edit-minute-field:focus,
  .prd-time-input::-webkit-datetime-edit-ampm-field:focus {
    background: rgba(6, 182, 212, 0.12);
    color: var(--color-accent);
  }

  .prd-date-input::-webkit-datetime-edit-text,
  .prd-time-input::-webkit-datetime-edit-text {
    color: var(--fg-disabled);
    padding: 0 1px;
  }

  /* Time hour/minute select (dark dropdown) */
  select.prd-i.prd-time-select {
    color-scheme: dark;
    -webkit-appearance: menulist !important;
    appearance: menulist !important;
    background: var(--bg-card) !important;
    background-image: none !important;
    padding-right: 4px;
    color: var(--fg-default);
    border-color: var(--stroke-default);
  }

  /* Select Dropdown */
  select.prd-i {
    cursor: pointer;
    padding-right: 30px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: var(--bg-base)
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 9L1 4h10z'/%3E%3C/svg%3E")
      no-repeat right 8px center;
    background-size: 10px;
    transition:
      border-color 0.2s,
      background-image 0.2s;
  }

  select.prd-i:hover {
    border-color: rgba(255, 255, 255, 0.2);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  }

  select.prd-i:focus {
    border-color: var(--color-accent);
    outline: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2306b6d4' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  }

  select.prd-i option {
    background: #1a1f2e;
    color: var(--fg-default);
    padding: 10px;
    font-size: 0.75rem;
    font-family: var(--font-korean);
  }

  select.prd-i option:checked {
    background: linear-gradient(0deg, rgba(6, 182, 212, 0.25) 0%, rgba(30, 58, 138, 0.3) 100%);
    color: var(--color-accent);
    font-weight: 500;
  }

  select.prd-i option:disabled {
    color: var(--fg-disabled);
    font-style: italic;
    opacity: 0.6;
  }

  /* ═══ Combo Dropdown ═══ */
  .combo-wrap {
    position: relative;
    width: 100%;
  }

  .combo-input {
    cursor: pointer !important;
    padding-right: 28px !important;
  }

  .combo-input:hover {
    border-color: var(--stroke-light);
  }

  .combo-arrow {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 8px;
    color: var(--fg-disabled);
    pointer-events: none;
    transition: 0.2s;
  }

  .combo-wrap.open .combo-arrow {
    transform: translateY(-50%) rotate(180deg);
    color: var(--color-accent);
  }

  .combo-wrap.open .combo-input {
    border-color: var(--color-accent);
    background: var(--bg-elevated);
  }

  .combo-list {
    display: none;
    position: absolute;
    top: calc(100% + 3px);
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border: 1px solid var(--stroke-light);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 200;
    max-height: 180px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--stroke-light) transparent;
    animation: comboIn 0.15s ease;
  }

  @keyframes comboIn {
    from {
      opacity: 0;
      transform: translateY(-4px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .combo-wrap.open .combo-list {
    display: block;
  }

  .combo-item {
    padding: 7px 10px;
    font-size: 0.75rem;
    font-family: var(--font-korean);
    color: var(--fg-sub);
    cursor: pointer;
    transition: 0.12s;
    border-bottom: 1px solid rgba(30, 42, 66, 0.5);
  }

  .combo-item:last-child {
    border-bottom: none;
  }

  .combo-item:hover {
    background: rgba(6, 182, 212, 0.08);
    color: var(--fg-default);
  }

  .combo-item.active {
    background: rgba(6, 182, 212, 0.12);
    color: var(--color-accent);
    font-weight: 600;
  }

  /* ═══ Model Chips ═══ */
  .prd-mc {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 5px 4px;
    border-radius: 5px;
    font-size: 0.6875rem;
    font-weight: 600;
    font-family: var(--font-korean);
    cursor: pointer;
    border: 1px solid var(--stroke-default);
    background: var(--bg-base);
    color: rgba(255, 255, 255, 0.5);
    transition: 0.15s;
    user-select: none;
  }

  .prd-mc.on {
    border-color: rgba(6, 182, 212, 0.4);
    background: rgba(6, 182, 212, 0.08);
    color: rgba(255, 255, 255, 0.9);
  }

  /* .prd-mc.on::before {
    content: '✓ ';
    font-size: 0.6875rem;
    color: var(--color-accent);
  } */

  .prd-md {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
  }

  /* ═══ Buttons ═══ */
  .prd-btn {
    width: 100%;
    padding: 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    font-family: var(--font-korean);
  }

  .prd-btn.pri {
    background: transparent;
    border: 1px solid var(--color-accent);
    color: var(--color-accent);
  }

  .prd-btn.sec {
    background: var(--bg-card);
    border: 1px solid var(--stroke-default);
    color: var(--fg-sub);
  }

  /* Map Button */
  .prd-map-btn {
    padding: 6px 8px;
    background: rgba(6, 182, 212, 0.08);
    border: 1px solid rgba(6, 182, 212, 0.2);
    border-radius: 6px;
    color: var(--color-accent);
    font-size: 0.6875rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    font-family: var(--font-korean);
  }

  .prd-map-btn:hover {
    background: rgba(6, 182, 212, 0.15);
  }

  .prd-map-btn.active {
    background: rgba(6, 182, 212, 0.25);
    border-color: rgba(6, 182, 212, 0.6);
    box-shadow: 0 0 0 1px rgba(6, 182, 212, 0.3);
  }

  /* Map Zoom/Reset Controls */
  .map-ctrl-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    transition: all 0.15s;
    background: rgba(15, 21, 36, 0.75);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.85);
  }

  .map-ctrl-btn:hover {
    background: rgba(15, 21, 36, 0.9);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.25);
  }

  [data-theme='light'] .map-ctrl-btn {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: rgba(0, 0, 0, 0.7);
  }

  [data-theme='light'] .map-ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.95);
    color: rgba(0, 0, 0, 0.9);
    border-color: rgba(0, 0, 0, 0.2);
  }

  /* ═══ Coordinate Display ═══ */
  .cod {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(18, 25, 41, 0.7);
    backdrop-filter: blur(8px);
    border: none;
    border-radius: 6px;
    padding: 5px 14px;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 400;
    z-index: 20;
    display: flex;
    gap: 14px;
  }

  .cov {
    color: #ffffff;
    font-weight: 400;
  }

  /* ═══ Weather Info Panel ═══ */
  .wip {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(18, 25, 41, 0.75);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 6px;
    padding: 6px 10px;
    z-index: 20;
    display: flex;
    gap: 12px;
  }

  .wii {
    display: flex;
    flex-direction: column;
    gap: 1px;
    align-items: center;
  }

  .wii-icon {
    font-size: 0.75rem;
    opacity: 0.7;
  }

  .wii-value {
    font-size: 0.6875rem;
    font-weight: 400;
    color: #ffffff;
    font-family: var(--font-mono);
  }

  .wii-label {
    font-size: 0.625rem;
    color: rgba(255, 255, 255, 0.55);
    font-weight: 400;
    font-family: var(--font-korean);
  }

  /* ═══ Timeline Control Panel ═══ */
  .tlb {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 72px;
    background: rgba(15, 21, 36, 0.95);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--stroke-default);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
    z-index: 30;
  }

  .tlc {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
  }

  .tb {
    width: 34px;
    height: 34px;
    border-radius: 6px;
    border: 1px solid var(--stroke-default);
    background: var(--bg-card);
    color: var(--fg-sub);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: 0.2s;
  }

  .tb:hover {
    background: var(--bg-surface-hover);
    color: var(--fg-default);
  }

  .tb.on {
    background: var(--color-accent);
    color: var(--bg-base);
    border-color: var(--color-accent);
  }

  .tlt {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .tlls {
    display: flex;
    justify-content: space-between;
    padding: 0 4px;
  }

  .tll {
    font-size: 0.75rem;
    color: var(--fg-disabled);
    font-family: var(--font-mono);
  }

  .tll.on {
    color: var(--color-accent);
    font-weight: 600;
  }

  .tlsw {
    position: relative;
    height: 24px;
    display: flex;
    align-items: center;
  }

  .tlr {
    width: 100%;
    height: 4px;
    background: var(--stroke-default);
    border-radius: 2px;
    position: relative;
  }

  .tlp {
    position: absolute;
    top: 0;
    left: 0;
    width: 25%;
    height: 100%;
    background: linear-gradient(90deg, var(--color-accent), var(--color-info));
    border-radius: 2px;
    transition: width 0.3s;
  }

  .tlm {
    position: absolute;
    width: 2px;
    height: 10px;
    background: var(--stroke-light);
    top: -3px;
  }

  .tlm.mj {
    height: 14px;
    top: -5px;
    background: var(--fg-disabled);
  }

  .tlbm {
    position: absolute;
    top: -18px;
    transform: translateX(-50%);
    font-size: 12px;
    cursor: pointer;
    filter: drop-shadow(0 0 4px rgba(245, 158, 11, 0.5));
  }

  .tlbm .tlbt {
    display: none;
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(18, 25, 41, 0.95);
    border: 1px solid var(--color-boom);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.75rem;
    color: var(--color-boom);
    white-space: nowrap;
    font-family: var(--font-korean);
  }

  .tlbm:hover .tlbt {
    display: block;
  }

  .tlth {
    position: absolute;
    left: 25%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background: var(--color-accent);
    border: 3px solid var(--bg-base);
    border-radius: 50%;
    cursor: grab;
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.4);
    z-index: 2;
    transition: left 0.3s;
  }

  .tli {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
    min-width: 200px;
  }

  .tlct {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-accent);
    font-family: var(--font-mono);
  }

  .tlss {
    display: flex;
    gap: 14px;
  }

  .tls {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
  }

  .tlsl {
    color: var(--fg-disabled);
    font-family: var(--font-korean);
  }

  .tlsv {
    color: var(--fg-default);
    font-weight: 600;
    font-family: var(--font-mono);
  }

  /* Timeline Action Buttons */
  .tlab {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    margin-left: 16px;
  }

  .tlab-btn {
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--stroke-default);
    background: var(--bg-card);
    color: var(--fg-sub);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-korean);
    transition: 0.2s;
    white-space: nowrap;
  }

  .tlab-btn:hover {
    background: var(--bg-surface-hover);
    color: var(--fg-default);
  }

  .tlab-btn.primary {
    background: linear-gradient(135deg, var(--color-accent), var(--color-info));
    color: #fff;
    border-color: transparent;
  }

  .tlab-btn.primary:hover {
    box-shadow: 0 0 16px rgba(6, 182, 212, 0.3);
  }

  .tlab-btn.warning {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--color-danger);
  }

  .tlab-btn.warning:hover {
    background: rgba(239, 68, 68, 0.15);
  }

  /* ═══ Layer Tree ═══ */
  .layer-tree {
    display: flex;
    flex-direction: column;
  }

  .layer-node {
    display: flex;
    flex-direction: column;
  }

  .layer-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 0.75rem;
    color: var(--fg-sub);
    font-family: var(--font-korean);
  }

  .layer-item:hover {
    background: rgba(255, 255, 255, 0.02);
  }

  .layer-arrow {
    width: 12px;
    font-size: 8px;
    color: var(--fg-disabled);
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
  }

  /* Toggle Switch */
  .layer-toggle {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 18px;
    flex-shrink: 0;
    cursor: pointer;
  }

  .layer-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
  }

  .toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(90, 100, 120, 0.3);
    transition: 0.3s;
    border-radius: 18px;
    border: 1px solid var(--stroke-default);
  }

  .toggle-slider:before {
    position: absolute;
    content: '';
    height: 12px;
    width: 12px;
    left: 2px;
    bottom: 2px;
    background-color: var(--fg-disabled);
    transition: 0.3s;
    border-radius: 50%;
  }

  .layer-toggle input:checked + .toggle-slider {
    background-color: rgba(6, 182, 212, 0.3);
    border-color: var(--color-accent);
  }

  .layer-toggle input:checked + .toggle-slider:before {
    transform: translateX(14px);
    background-color: var(--color-accent);
  }

  .layer-toggle input:disabled + .toggle-slider {
    opacity: 0.3;
    cursor: not-allowed;
  }

  .layer-icon {
    font-size: 14px;
    flex-shrink: 0;
  }

  .layer-name {
    flex: 1;
    font-weight: 500;
  }

  .layer-count {
    font-size: 0.75rem;
    color: var(--fg-disabled);
    font-family: var(--font-mono);
  }

  .layer-children {
    display: flex;
    flex-direction: column;
  }

  /* ═══ Oil Boom ═══ */
  .boom-drawing-indicator {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(245, 158, 11, 0.15);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(245, 158, 11, 0.4);
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-boom);
    font-family: var(--font-korean);
    z-index: 40;
    white-space: nowrap;
    pointer-events: none;
    animation: fadeSlideDown 0.3s ease;
  }

  .boom-eff-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-base);
    border: 1px solid var(--stroke-default);
    border-radius: 3px;
    overflow: hidden;
  }

  .boom-eff-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
  }

  .boom-setting-input {
    width: 56px;
    padding: 3px 6px;
    background: var(--bg-base);
    border: 1px solid var(--stroke-default);
    border-radius: 4px;
    color: var(--color-default);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 400;
    text-align: right;
    outline: none;
    transition: border-color 0.2s;
  }

  .boom-setting-input:focus {
    border-color: var(--color-accent);
  }

  .boom-setting-input::-webkit-inner-spin-button,
  .boom-setting-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }

  .boom-setting-input[type='number'] {
    -moz-appearance: textfield;
  }

  /* ═══ Backtrack Replay ═══ */
  .bt-ship-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: auto;
  }

  .bt-ship-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  }

  .bt-spd-btn {
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid var(--stroke-default);
    background: var(--bg-card);
    color: var(--fg-disabled);
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font-mono);
    transition: 0.15s;
  }

  .bt-spd-btn:hover {
    background: rgba(168, 85, 247, 0.08);
    color: var(--fg-sub);
  }

  .bt-spd-btn.active {
    border-color: var(--color-tertiary);
    background: rgba(168, 85, 247, 0.12);
    color: var(--color-tertiary);
  }

  @keyframes bt-collision-pulse {
    0%,
    100% {
      transform: scale(1);
      opacity: 1;
    }
    50% {
      transform: scale(1.3);
      opacity: 0.6;
    }
  }

  .bt-collision-marker {
    animation: bt-collision-pulse 1s infinite;
  }

  /* ═══ HNS Scenario Card ═══ */
  .hns-scn-card {
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 6px;
    border: 1px solid var(--stroke-default);
    background: var(--bg-card);
    cursor: pointer;
    transition:
      border-color 0.15s,
      background 0.15s;
  }

  .hns-scn-card:hover {
    border-color: rgba(6, 182, 212, 0.3);
    background: rgba(6, 182, 212, 0.04);
  }

  .hns-scn-card.sel {
    border-color: var(--color-accent);
    background: rgba(6, 182, 212, 0.08);
  }

  /* ═══ Analysis Tab ═══ */
  .rsc-atab {
    flex: 1;
    padding: 8px 4px;
    border: none;
    background: transparent;
    color: #8b949e;
    font-family: var(--font-korean);
    font-size: var(--font-size-label-2);
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    border-bottom: 2px solid transparent;
    transition: 0.2s;
  }

  .rsc-atab:hover {
    color: #c9d1d9;
  }

  .rsc-atab.on {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
    background: rgba(6, 182, 212, 0.04);
  }
}

@layer utilities {
  .font-mono {
    font-family: var(--font-mono);
  }

  .font-korean {
    font-family: var(--font-korean);
  }

  /* ═══ Animations ═══ */
  @keyframes fadeIn {
    from {
      opacity: 0;
      transform: translateY(8px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  @keyframes pulse-dot {
    0%,
    100% {
      opacity: 1;
      transform: scale(1);
    }
    50% {
      opacity: 0.5;
      transform: scale(0.8);
    }
  }

  @keyframes pulse-border {
    0%,
    100% {
      border-color: rgba(239, 68, 68, 0.2);
    }
    50% {
      border-color: rgba(239, 68, 68, 0.5);
    }
  }

  @keyframes fadeSlideDown {
    from {
      opacity: 0;
      transform: translateY(-8px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .animate-fadeIn {
    animation: fadeIn 0.5s ease both;
  }

  .animate-pulse-dot {
    animation: pulse-dot 1.5s infinite;
  }

  .animate-pulse-border {
    animation: pulse-border 2s infinite;
  }

  /* ═══ Layer Tree 3-Level ═══ */
  .lyr-g1 {
    margin-bottom: 2px;
  }

  .lyr-h1 {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 8px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
    font-size: 12px;
    font-weight: 700;
    color: var(--fg-default);
    font-family: var(--font-korean);
  }

  .lyr-h1:hover {
    background: rgba(255, 255, 255, 0.04);
  }

  .lyr-h1 .lyr-arr {
    font-size: 8px;
    color: var(--fg-disabled);
    transition: transform 0.2s;
    width: 12px;
    text-align: center;
  }

  .lyr-h1 .lyr-arr.open {
    transform: rotate(90deg);
  }

  .lyr-h1-cnt {
    margin-left: auto;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--fg-disabled);
    font-family: var(--font-mono);
  }

  .lyr-c1 {
    padding-left: 6px;
    overflow: hidden;
    transition: max-height 0.25s ease;
  }

  .lyr-c1.collapsed {
    max-height: 0 !important;
    overflow: hidden;
  }

  .lyr-g2 {
    margin-bottom: 1px;
  }

  .lyr-h2 {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    cursor: pointer;
    border-radius: 3px;
    transition: background 0.15s;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--fg-sub);
    font-family: var(--font-korean);
  }

  .lyr-h2:hover {
    background: rgba(255, 255, 255, 0.03);
  }

  .lyr-h2 .lyr-arr {
    font-size: 7px;
    color: var(--fg-disabled);
    transition: transform 0.2s;
    width: 10px;
    text-align: center;
  }

  .lyr-h2 .lyr-arr.open {
    transform: rotate(90deg);
  }

  .lyr-h2-cnt {
    margin-left: auto;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--fg-disabled);
    font-family: var(--font-mono);
  }

  .lyr-c2 {
    padding-left: 10px;
    overflow: hidden;
    transition: max-height 0.25s ease;
  }

  .lyr-c2.collapsed {
    max-height: 0 !important;
    overflow: hidden;
  }

  .lyr-t {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--fg-sub);
    transition:
      color 0.15s,
      background 0.15s;
    font-family: var(--font-korean);
    border-radius: 3px;
  }

  .lyr-t:hover {
    color: var(--fg-default);
    background: rgba(255, 255, 255, 0.02);
  }

  .lyr-cnt {
    margin-left: auto;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--fg-disabled);
    font-family: var(--font-mono);
    flex-shrink: 0;
  }

  /* Color Swatch */
  .lyr-csw {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
    border: 1.5px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition:
      transform 0.15s,
      box-shadow 0.15s;
    position: relative;
  }
  .lyr-csw::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    border-radius: 1px;
    background: linear-gradient(
      135deg,
      #ef4444 25%,
      #3b82f6 25%,
      #3b82f6 50%,
      #22c55e 50%,
      #22c55e 75%,
      #eab308 75%
    );
    opacity: 0.6;
  }
  .lyr-csw.has-color::after {
    display: none;
  }

  .lyr-csw:hover {
    transform: scale(1.2);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.25);
  }

  /* Color Picker Popup */
  .lyr-cpop {
    position: absolute;
    right: 20px;
    top: -6px;
    z-index: 300;
    background: var(--bg-surface);
    border: 1px solid var(--stroke-default);
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    display: none;
    width: 190px;
  }

  .lyr-cpop.show {
    display: block;
    animation: lyrPopIn 0.2s ease-out;
  }

  @keyframes lyrPopIn {
    from {
      opacity: 0;
      transform: translateY(-4px) scale(0.95);
    }
    to {
      opacity: 1;
      transform: translateY(0) scale(1);
    }
  }

  .lyr-cpr {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
  }

  .lyr-cpr-i {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: 0.15s;
  }

  .lyr-cpr-i:hover {
    transform: scale(1.15);
    border-color: rgba(255, 255, 255, 0.3);
  }

  .lyr-cpr-i.sel {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.3);
  }

  .lyr-ccustom {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
  }

  .lyr-ccustom label {
    font-size: 0.6875rem;
    color: var(--fg-disabled);
    font-family: var(--font-korean);
  }

  .lyr-ccustom input[type='color'] {
    width: 24px;
    height: 20px;
    border: 1px solid var(--stroke-default);
    border-radius: 3px;
    cursor: pointer;
    padding: 0;
    background: transparent;
  }

  /* Layer Style Box */
  .lyr-style-box {
    margin-top: 10px;
    padding: 10px 8px;
    background: var(--bg-base);
    border: 1px solid var(--stroke-default);
    border-radius: var(--radius-sm);
  }
  .lyr-style-label {
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--fg-disabled);
    font-family: var(--font-korean);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
  }
  .lyr-style-row {
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .lyr-style-row + .lyr-style-row {
    margin-top: 6px;
  }
  .lyr-style-name {
    font-size: 0.75rem;
    color: var(--fg-disabled);
    font-family: var(--font-korean);
    min-width: 32px;
  }
  .lyr-style-slider {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: var(--stroke-default);
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    cursor: pointer;
    accent-color: var(--color-accent);
  }
  .lyr-style-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-accent);
    cursor: pointer;
  }
  .lyr-style-val {
    font-size: 0.6875rem;
    color: var(--fg-disabled);
    font-family: var(--font-mono);
    min-width: 28px;
    text-align: right;
  }

  /* Toggle Switch (Layer Tree) */
  .lyr-sw {
    width: 28px;
    height: 16px;
    background: var(--bg-base);
    border-radius: 8px;
    position: relative;
    border: 1px solid var(--stroke-default);
    transition: 0.2s;
    flex-shrink: 0;
    cursor: pointer;
  }

  .lyr-sw::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 10px;
    height: 10px;
    background: var(--fg-disabled);
    border-radius: 50%;
    transition: 0.2s;
  }

  .lyr-sw.on {
    background: rgba(6, 182, 212, 0.3);
    border-color: var(--color-accent);
  }

  .lyr-sw.on::after {
    left: 14px;
    background: var(--color-accent);
  }

  .lyr-sw:disabled {
    opacity: 0.4;
    cursor: not-allowed;
  }

  /* ═══ Light Theme Overrides ═══ */

  /* CCTV popup */
  [data-theme='light'] .cctv-dark-popup .maplibregl-popup-content {
    background: #ffffff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--stroke-default);
  }
  [data-theme='light'] .cctv-dark-popup .maplibregl-popup-tip {
    border-top-color: #ffffff;
    border-bottom-color: #ffffff;
  }
  [data-theme='light'] .cctv-dark-popup .maplibregl-popup-close-button {
    color: var(--fg-disabled);
  }
  [data-theme='light'] .cctv-dark-popup .maplibregl-popup-close-button:hover {
    color: var(--fg-default);
  }

  /* Date/Time picker color-scheme */
  [data-theme='light'] .prd-date-input,
  [data-theme='light'] .prd-time-input {
    color-scheme: light;
  }
  [data-theme='light'] select.prd-i.prd-time-select {
    color-scheme: light;
  }

  /* Select option */
  [data-theme='light'] select.prd-i option {
    background: #ffffff;
  }
  [data-theme='light'] select.prd-i option:checked {
    background: linear-gradient(0deg, rgba(6, 182, 212, 0.15) 0%, rgba(6, 182, 212, 0.08) 100%);
  }

  /* Select hover border */
  [data-theme='light'] select.prd-i:hover {
    border-color: var(--stroke-light);
  }

  /* Model chip text */
  [data-theme='light'] .prd-mc {
    color: var(--fg-disabled);
  }
  [data-theme='light'] .prd-mc.on {
    color: var(--fg-default);
  }

  /* Coordinate display */
  [data-theme='light'] .cod {
    background: rgba(255, 255, 255, 0.85);
    color: var(--fg-sub);
  }
  [data-theme='light'] .cov {
    color: var(--fg-default);
  }

  /* Weather info panel */
  [data-theme='light'] .wip {
    background: rgba(255, 255, 255, 0.85);
  }
  [data-theme='light'] .wii-value {
    color: var(--fg-default);
  }
  [data-theme='light'] .wii-label {
    color: var(--fg-sub);
  }

  /* Timeline control panel */
  [data-theme='light'] .tlb {
    background: rgba(255, 255, 255, 0.95);
  }

  /* Timeline boom tooltip */
  [data-theme='light'] .tlbm .tlbt {
    background: rgba(255, 255, 255, 0.95);
  }

  /* Combo item border */
  [data-theme='light'] .combo-item {
    border-bottom: 1px solid var(--stroke-light);
  }
  [data-theme='light'] .combo-list {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  }
}
