/* ============================================
   EXPLORE HILLS v5.0 — Premium Mobile-First UI
   Sort moved to drawer, tags wrap 5/row on mobile
   Fixed close button & trigger alignment
   ============================================ */

/* ---------- CSS Variables ---------- */
.te-wrap {
    --te-radius: 14px;
    --te-radius-sm: 10px;
    --te-radius-pill: 100px;
    --te-green: #10b981;
    --te-green-dark: #059669;
    --te-green-light: #ecfdf5;
    --te-green-border: #a7f3d0;
    --te-text: #111827;
    --te-text-secondary: #6b7280;
    --te-text-muted: #9ca3af;
    --te-border: #f3f4f6;
    --te-border-hover: #e5e7eb;
    --te-card-bg: #ffffff;
    --te-surface: #f9fafb;
    --te-shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --te-shadow-md: 0 8px 30px rgba(0,0,0,0.08);
    --te-shadow-lg: 0 20px 60px rgba(0,0,0,0.12);
    --te-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

    max-width: 1360px;
    margin: 0 auto;
    padding: 24px 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
    color: var(--te-text);
    -webkit-font-smoothing: antialiased;
    contain: layout style;
    box-sizing: border-box;
}

.te-wrap *, .te-wrap *::before, .te-wrap *::after {
    box-sizing: border-box;
}

/* ---------- HEADER ---------- */
.te-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.te-header-left {
    min-width: 0;
    flex-shrink: 0;
}

.te-title {
    font-size: 1.65rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--te-text);
    margin: 0;
    line-height: 1.2;
}

.te-count {
    color: var(--te-text-secondary);
    font-size: 0.88rem;
    margin: 4px 0 0;
    font-weight: 500;
}

.te-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* Search */
.te-search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    height: 42px;
    background: var(--te-surface);
    border-radius: var(--te-radius-sm);
    border: 1.5px solid transparent;
    transition: all var(--te-transition);
    min-width: 0;
    flex: 1;
    max-width: 320px;
}

.te-search-wrap:focus-within {
    background: #fff;
    border-color: var(--te-green);
    box-shadow: 0 0 0 3px rgba(16,185,129,0.08);
}

.te-search-icon {
    color: var(--te-text-muted);
    flex-shrink: 0;
    transition: color var(--te-transition);
}

.te-search-wrap:focus-within .te-search-icon {
    color: var(--te-green);
}

.te-search-wrap input {
    border: none;
    background: none;
    outline: none;
    font-size: 0.88rem;
    width: 100%;
    min-width: 0;
    color: var(--te-text);
    font-weight: 500;
}

.te-search-wrap input::placeholder {
    color: var(--te-text-muted);
    font-weight: 400;
}

.te-search-clear {
    background: var(--te-border-hover);
    border: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--te-text-secondary);
    transition: all 0.15s;
    padding: 0;
    flex-shrink: 0;
}

.te-search-clear:hover {
    background: #e5e7eb;
    color: var(--te-text);
}

/* Sort Dropdown (hidden on frontend — replaced by drawer radios) */
.te-sort-wrap {
    flex-shrink: 0;
    display: none;
}

.te-sort-wrap select {
    appearance: none;
    -webkit-appearance: none;
    height: 42px;
    padding: 0 32px 0 14px;
    border: 1.5px solid var(--te-border-hover);
    border-radius: var(--te-radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--te-text-secondary);
    background: #fff url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center;
    cursor: pointer;
    outline: none;
    transition: all var(--te-transition);
}

.te-sort-wrap select:focus {
    border-color: var(--te-green);
    box-shadow: 0 0 0 3px rgba(16,185,129,0.08);
}

/* Settings Gear Button — opens filter drawer */
.te-settings-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 42px;
    width: 42px;
    padding: 0;
    background: var(--te-surface);
    color: var(--te-text-secondary);
    border: 1.5px solid var(--te-border-hover);
    border-radius: var(--te-radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--te-transition);
    position: relative;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.te-settings-btn:hover {
    background: var(--te-green-light);
    border-color: var(--te-green);
    color: var(--te-green-dark);
}

.te-settings-btn:hover .te-settings-icon {
    transform: rotate(15deg);
}

.te-settings-icon {
    display: block;
    width: 20px;
    height: 20px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23111727' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 7h10'/%3E%3Ccircle cx='18' cy='7' r='1.5'/%3E%3Cpath d='M4 12h6'/%3E%3Ccircle cx='14' cy='12' r='1.5'/%3E%3Cpath d='M4 17h8'/%3E%3Ccircle cx='14' cy='17' r='1.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
    transform: rotate(0deg);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.te-badge {
    background: var(--te-green);
    color: #fff;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 20px;
    font-size: 0.65rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    line-height: 1;
    position: absolute;
    top: -6px;
    right: -6px;
}

/* ---------- QUICK TAG PILLS ---------- */
.te-quick-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--te-border);
}

.te-qtag {
    padding: 7px 16px;
    border-radius: var(--te-radius-pill);
    border: 1.5px solid var(--te-border-hover);
    background: #fff;
    color: var(--te-text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.te-qtag:hover {
    border-color: var(--te-green-border);
    color: var(--te-green-dark);
    background: var(--te-green-light);
}

.te-qtag.active {
    background: var(--te-green);
    border-color: var(--te-green);
    color: #fff;
    box-shadow: 0 2px 8px rgba(16,185,129,0.25);
}

/* ---------- ACTIVE FILTER CHIPS ---------- */
.te-active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
    animation: teFadeIn 0.3s ease;
}

.te-af-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--te-green-light);
    border: 1px solid var(--te-green-border);
    color: var(--te-green-dark);
    border-radius: var(--te-radius-pill);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.te-af-chip:hover {
    background: #d1fae5;
}

.te-af-chip .te-af-x {
    font-size: 14px;
    opacity: 0.6;
    line-height: 1;
}

.te-af-chip:hover .te-af-x {
    opacity: 1;
}

/* ---------- FILTER DRAWER ---------- */
.te-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 420px;
    max-width: 92vw;
    height: 100vh;
    height: 100dvh;
    background: #fff;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: -12px 0 50px rgba(0,0,0,0.12);
    transform: translateX(100%);
    visibility: hidden;
}

.te-drawer.open {
    transform: translateX(0);
    visibility: visible;
}

.te-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.35s;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.te-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* Drawer Header */
.te-drawer-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--te-border);
    flex-shrink: 0;
}

.te-drawer-head h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.te-drawer-head-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.te-clear-all {
    background: none;
    border: none;
    color: var(--te-green);
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 4px 0;
    transition: opacity 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.te-clear-all:hover {
    opacity: 0.7;
}

.te-drawer-close {
    background: var(--te-surface) !important;
    border: none !important;
    width: 36px;
    height: 36px;
    border-radius: var(--te-radius-sm) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--te-text-secondary) !important;
    transition: all 0.2s !important;
    padding: 0 !important;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.te-drawer-close:hover {
    background: var(--te-border-hover) !important;
    color: var(--te-text) !important;
}

/* Drawer Body */
.te-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0 110px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* Filter Groups */
.te-fgroup {
    border-bottom: 1px solid var(--te-border);
}

.te-fgroup.collapsed .te-fgroup-options {
    display: none;
}

.te-fgroup.collapsed .te-fgroup-toggle svg {
    transform: rotate(-90deg);
}

.te-fgroup-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 24px;
    background: none;
    border: none;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--te-text);
    cursor: pointer;
    transition: background 0.15s;
    letter-spacing: -0.01em;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
}

.te-fgroup-toggle:hover {
    background: var(--te-surface);
}

.te-fgroup-toggle svg {
    color: var(--te-text-muted);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.te-fgroup-options {
    padding: 2px 24px 16px;
}

/* Filter Options */
.te-fopt {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--te-radius-sm);
    cursor: pointer;
    transition: background 0.15s;
    margin-bottom: 1px;
    -webkit-tap-highlight-color: transparent;
}

.te-fopt:hover {
    background: var(--te-surface);
}

.te-fopt input[type="radio"],
.te-fopt input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid #d1d5db;
    border-radius: 5px;
    flex-shrink: 0;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}

.te-fopt input[type="radio"] {
    border-radius: 50%;
}

.te-fopt input:checked {
    background: var(--te-green);
    border-color: var(--te-green);
    box-shadow: 0 1px 4px rgba(16,185,129,0.2);
}

.te-fopt input:checked::after {
    content: '\2713';
    position: absolute;
    color: #fff;
    font-size: 12px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: 700;
}

.te-fopt input[type="radio"]:checked::after {
    content: '';
    width: 7px;
    height: 7px;
    background: #fff;
    border-radius: 50%;
}

.te-fopt span {
    font-size: 0.87rem;
    color: var(--te-text-secondary);
    font-weight: 500;
    transition: color 0.15s;
    word-break: break-word;
}

.te-fopt input:checked ~ span {
    color: var(--te-text);
    font-weight: 600;
}

/* Sort options styling (radio-based in drawer) */
.te-sort-options {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.te-sort-opt {
    margin-bottom: 0 !important;
}

/* Month Grid */
.te-month-grid.te-fgroup-options {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px !important;
    padding: 8px 20px 16px !important;
}

.te-month-opt {
    justify-content: center !important;
    padding: 8px 4px !important;
}

.te-month-opt span {
    font-size: 0.78rem !important;
    font-weight: 600 !important;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Drawer Footer */
.te-drawer-foot {
    display: none;
}

.te-apply-btn-top {
    margin: 0 0 0 8px;
    min-height: 42px;
}

.te-apply-btn {
    width: 100%;
    padding: 14px;
    background: var(--te-green);
    color: #fff;
    border: none;
    border-radius: var(--te-radius-sm);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--te-transition);
    letter-spacing: -0.01em;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.te-apply-btn:hover {
    background: var(--te-green-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(16,185,129,0.25);
}

.te-apply-btn:active {
    transform: translateY(0);
}

/* ---------- RESULTS GRID ---------- */
.te-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
    gap: 24px;
    min-height: 200px;
}

/* ---------- CARD ---------- */
.te-card {
    display: flex;
    flex-direction: column;
    background: var(--te-card-bg);
    border-radius: var(--te-radius);
    overflow: hidden;
    border: 1px solid var(--te-border);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    animation: teCardIn 0.45s ease backwards;
    will-change: transform;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.te-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--te-shadow-lg);
    border-color: transparent;
}

.te-card .te-card-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 12px 0 0;
    padding: 11px 14px;
    border-radius: var(--te-radius-pill);
    background: var(--te-green);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    width: fit-content;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.te-card:hover .te-card-cta {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(16,185,129,0.18);
}

.te-card-hidden {
    display: none !important;
}

.te-load-more-wrap {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    padding-top: 10px;
}

.te-load-more-btn {
    padding: 12px 22px;
    background: var(--te-green);
    color: #fff;
    border: none;
    border-radius: 999px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
}

.te-load-more-btn:hover {
    background: var(--te-green-dark);
    transform: translateY(-1px);
}

.te-card-img {
    height: 210px;
    background: linear-gradient(135deg, #f0fdf4, #ecfdf5, #d1fae5);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.te-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.te-card:hover .te-card-img img {
    transform: scale(1.06);
}

.te-card-badges {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    z-index: 2;
}

.te-card-grade {
    padding: 4px 12px;
    border-radius: var(--te-radius-pill);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    line-height: 1.4;
}

.te-card-grade.easy {
    background: rgba(16, 185, 129, 0.92);
    color: #fff;
}

.te-card-grade.moderate {
    background: rgba(245, 158, 11, 0.92);
    color: #fff;
}

.te-card-grade.difficult {
    background: rgba(239, 68, 68, 0.92);
    color: #fff;
}

.te-card-duration-badge {
    position: absolute;
    bottom: 12px;
    right: 12px;
    padding: 5px 14px;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #fff;
    border-radius: var(--te-radius-pill);
    font-size: 0.78rem;
    font-weight: 600;
    z-index: 2;
    white-space: nowrap;
}

.te-no-img {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--te-green, #10b981);
    opacity: 0.35;
}

.te-no-img svg {
    width: 25%;
    height: 25%;
    max-width: 64px;
    max-height: 64px;
}

.te-card-body {
    padding: 18px 20px 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.te-card-title {
    font-size: 1.08rem;
    font-weight: 750;
    color: var(--te-text);
    margin: 0 0 6px;
    line-height: 1.35;
    letter-spacing: -0.02em;
    text-align: left;
}

.te-card-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s;
}

.te-card-title a:hover {
    color: var(--te-green);
}

.te-card-excerpt {
    color: var(--te-text-secondary);
    font-size: 0.82rem;
    line-height: 1.6;
    margin: 0 0 14px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-align: left;
}

.te-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 14px;
}

.te-card-tag {
    padding: 3px 10px;
    background: var(--te-surface);
    border-radius: var(--te-radius-pill);
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--te-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    transition: all 0.2s;
    white-space: nowrap;
}

.te-card-tag:hover {
    background: var(--te-green-light);
    color: var(--te-green-dark);
}

.te-card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--te-border);
    font-size: 0.8rem;
    color: var(--te-text-secondary);
    font-weight: 500;
    margin-top: auto;
    text-align: left;
}

.te-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.te-meta-item svg {
    width: 14px;
    height: 14px;
    color: var(--te-text-muted);
    flex-shrink: 0;
}

/* ---------- STATES ---------- */
.te-loading {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    padding: 80px 20px;
}

.te-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--te-border);
    border-top-color: var(--te-green);
    border-radius: 50%;
    animation: teSpin 0.7s linear infinite;
}

.te-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 20px;
    animation: teFadeIn 0.4s ease;
}

.te-empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    color: var(--te-text-muted);
    opacity: 0.7;
}

.te-empty-icon svg {
    width: 48px;
    height: 48px;
}

.te-empty h3 {
    color: var(--te-text);
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 6px;
}

.te-empty p {
    color: var(--te-text-muted);
    font-size: 0.9rem;
    margin: 0;
}

/* ============================================
   BUTTON SHORTCODE STYLE
   ============================================ */

.eh-btn-wrap {
    display: inline-block;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
}

.eh-trigger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 28px;
    background: var(--te-green, #10b981);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: -0.01em;
    box-shadow: 0 4px 14px rgba(16,185,129,0.25);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    vertical-align: middle;
}

.eh-trigger-btn:hover {
    background: var(--te-green-dark, #059669);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(16,185,129,0.35);
}

.eh-trigger-btn:active {
    transform: translateY(0);
}

.eh-trigger-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.eh-trigger-btn .eh-btn-text {
    line-height: 1;
    display: inline-block;
}

/* Modal */
.eh-modal {
    position: fixed;
    inset: 0;
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.35s;
}

.eh-modal.open {
    opacity: 1;
    visibility: visible;
}

.eh-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.eh-modal-content {
    position: relative;
    background: #fff;
    border-radius: 20px;
    width: 94vw;
    max-width: 1200px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 80px rgba(0,0,0,0.2);
    transform: scale(0.92) translateY(20px);
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
    z-index: 1;
    -webkit-overflow-scrolling: touch;
}

.eh-modal.open .eh-modal-content {
    transform: scale(1) translateY(0);
}

.eh-modal-content .te-wrap {
    padding: 20px;
    max-height: 90vh;
    overflow-y: auto;
}

/* ============================================
   MODAL CLOSE BUTTON — Fixed alignment
   ============================================ */
.eh-modal-close {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 20001;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.95);
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    flex-shrink: 0;
}

.eh-modal-close:hover {
    background: #ef4444;
    color: #fff;
    transform: rotate(90deg);
}

.eh-modal-close:active {
    transform: scale(0.9) rotate(90deg);
}

.eh-modal-close svg {
    width: 20px;
    height: 20px;
}

/* ============================================
   ICON SHORTCODE STYLE (header search icon)
   ============================================ */

.eh-icon-wrap {
    display: inline-flex;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
}

.eh-icon-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: transparent;
    color: inherit;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    position: relative;
}

.eh-icon-trigger:hover {
    background: rgba(16,185,129,0.1);
    color: var(--te-green, #10b981);
}

.eh-icon-trigger:active {
    background: rgba(16,185,129,0.2);
    transform: scale(0.92);
}

.eh-icon-trigger svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

/* Icon with badge counter */
.eh-icon-trigger .te-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    font-size: 0.6rem;
    padding: 0 4px;
    background: var(--te-green, #10b981);
    color: #fff;
    border-radius: 20px;
    display: none;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    line-height: 1;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ============================================
   COMPACT MODE
   ============================================ */

.te-wrap--compact .te-header {
    margin-bottom: 14px;
}

.te-wrap--compact .te-title {
    font-size: 1.2rem;
}

.te-wrap--compact .te-search-wrap input {
    width: 100%;
    min-width: 0;
}

.te-wrap--compact .te-quick-tags {
    margin-bottom: 14px;
    padding-bottom: 14px;
    gap: 5px;
}

.te-wrap--compact .te-qtag {
    padding: 5px 12px;
    font-size: 0.75rem;
}

.te-wrap--compact .te-grid {
    gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.te-wrap--compact .te-card-img {
    height: 170px;
}

.te-wrap--compact .te-card-body {
    padding: 14px 16px 16px;
}

.te-wrap--compact .te-card-title {
    font-size: 0.95rem;
}

/* ---------- ANIMATIONS ---------- */
@keyframes teSpin {
    to { transform: rotate(360deg); }
}

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

@keyframes teCardIn {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   RESPONSIVE — TABLET
   ============================================ */
@media (min-width: 769px) and (max-width: 1024px) {
    .te-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   RESPONSIVE — MOBILE (<=768px)
   ============================================ */
@media (max-width: 768px) {

    /* Container */
    .te-wrap {
        padding: 14px 12px;
    }

    /* Header: title + count above search + gear on mobile */
    .te-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 14px;
    }

    .te-header-left {
        width: 100%;
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .te-header-left .te-title {
        font-size: 1.3rem;
        text-align: left;
        line-height: 1.2;
    }

    .te-header-left .te-count {
        text-align: left;
        font-size: 0.78rem;
    }

    .te-header-right {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
        flex-wrap: wrap;
    }

    .te-search-wrap {
        flex: 1 1 auto;
        min-width: 0;
        width: calc(100% - 54px);
    }

    .te-settings-btn {
        flex: 0 0 auto;
    }

    /* Search: flexible width, takes remaining space */
    .te-search-wrap {
        flex: 1 1 auto;
        max-width: none;
        min-width: 0;
        height: 44px;
        padding: 0 12px;
    }

    /* Hide sort in header on mobile (it's in the drawer now) */
    .te-sort-wrap {
        display: none !important;
    }

    .te-search-clear {
        width: 28px;
        height: 28px;
    }

    /* Gear button: prominent on mobile */
    .te-settings-btn {
        width: 44px;
        height: 44px;
        background: var(--te-green-light);
        border-color: var(--te-green-border);
        color: var(--te-green-dark);
        border-radius: 50%;
        box-shadow: 0 2px 8px rgba(16,185,129,0.15);
        flex-shrink: 0;
    }
    .te-settings-btn:active {
        background: var(--te-green);
        color: #fff;
        border-color: var(--te-green);
    }
    .te-settings-btn:active svg {
        transform: rotate(60deg);
    }

    /* Quick tags: wrap in grid, 5 per row */
    .te-quick-tags {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 6px;
        padding-bottom: 14px;
        margin-bottom: 14px;
        overflow-x: visible;
        flex-wrap: unset;
        -webkit-overflow-scrolling: auto;
        scrollbar-width: auto;
    }

    .te-quick-tags::-webkit-scrollbar {
        display: auto;
    }

    .te-qtag {
        flex-shrink: 1;
        padding: 8px 4px;
        font-size: 0.7rem;
        text-align: center;
        justify-content: center;
        width: 100%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Active chips: better wrapping */
    .te-active-filters {
        gap: 5px;
    }

    .te-af-chip {
        font-size: 0.72rem;
        padding: 5px 10px;
    }

    /* Card grid: single column */
    .te-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    /* Cards: optimized for mobile */
    .te-card {
        border-radius: 12px;
    }

    .te-card:hover {
        transform: none;
        box-shadow: var(--te-shadow-md);
    }

    .te-card-img {
        height: 180px;
    }

    .te-card-body {
        padding: 14px 14px 16px;
    }

    .te-card-title {
        font-size: 1rem;
        line-height: 1.3;
    }

    .te-card-excerpt {
        font-size: 0.8rem;
        line-height: 1.55;
        -webkit-line-clamp: 2;
    }

    .te-card-tags {
        gap: 4px;
        margin-bottom: 10px;
    }

    .te-card-tag {
        font-size: 0.65rem;
        padding: 2px 8px;
    }

    .te-card-meta {
        gap: 8px;
        padding-top: 10px;
        font-size: 0.75rem;
    }

    .te-load-more-wrap {
        padding: 12px 0 20px;
    }

    .te-drawer-head-actions {
        justify-content: flex-end;
        flex-wrap: wrap;
        gap: 10px;
    }

    .te-apply-btn-top {
        width: 100%;
        min-width: 0;
        margin: 0;
    }

    .te-clear-all,
    .te-drawer-close {
        flex: 1 1 auto;
        min-width: 0;
    }

    .te-drawer-close {
        justify-content: center;
    }

    .te-meta-item svg {
        width: 13px;
        height: 13px;
    }

    .te-card-badges {
        top: 8px;
        left: 8px;
        gap: 4px;
    }

    .te-card-grade {
        padding: 3px 10px;
        font-size: 0.65rem;
    }

    .te-card-duration-badge {
        bottom: 8px;
        right: 8px;
        padding: 4px 10px;
        font-size: 0.72rem;
    }

    /* Drawer: full-width on mobile */
    .te-drawer {
        width: 100vw;
        max-width: 100vw;
        right: 0;
    }

    .te-drawer.open {
        transform: translateX(0);
    }

    .te-drawer-head {
        padding: 18px 16px;
        padding-top: max(18px, env(safe-area-inset-top, 18px));
    }

    .te-drawer-head h3 {
        font-size: 1.05rem;
    }

    .te-drawer-close {
        width: 40px;
        height: 40px;
    }

    .te-fgroup-toggle {
        padding: 14px 16px;
        font-size: 0.88rem;
        min-height: 48px;
    }

    .te-fgroup-options {
        padding: 2px 16px 14px;
    }

    .te-fopt {
        padding: 10px 10px;
        gap: 10px;
        min-height: 44px;
        border-radius: 8px;
    }

    .te-fopt input[type="radio"],
    .te-fopt input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }

    .te-month-grid.te-fgroup-options {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 5px !important;
        padding: 6px 14px 14px !important;
    }

    .te-month-opt {
        min-height: 44px;
    }

    .te-drawer-foot {
        padding: 14px 16px;
        padding-bottom: max(14px, env(safe-area-inset-bottom, 14px));
    }

    .te-apply-btn {
        padding: 14px;
        font-size: 0.95rem;
        min-height: 48px;
        border-radius: 12px;
    }

    /* ============================================
       MODAL ON MOBILE — Full screen, fixed close
       ============================================ */
    .eh-modal-content {
        width: 100vw;
        max-width: 100vw;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
        transform: translateY(100%);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .eh-modal.open .eh-modal-content {
        transform: translateY(0);
    }

    .eh-modal-content .te-wrap {
        padding: 14px 12px;
        max-height: none;
        overflow-y: visible;
        padding-top: max(14px, env(safe-area-inset-top, 14px));
    }

    /* Close button: fixed top-right, always aligned, safe area aware */
    .eh-modal-close {
        position: fixed;
        top: max(12px, env(safe-area-inset-top, 12px));
        right: 12px;
        z-index: 20002;
        width: 40px;
        height: 40px;
        background: rgba(255,255,255,0.95);
        box-shadow: 0 2px 12px rgba(0,0,0,0.18);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .eh-modal-close svg {
        width: 18px;
        height: 18px;
    }

    /* Trigger button on mobile */
    .eh-trigger-btn {
        padding: 12px 22px;
        font-size: 0.9rem;
        border-radius: 10px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 48px;
    }

    /* Icon trigger on mobile */
    .eh-icon-trigger {
        width: 48px;
        height: 48px;
        min-height: 48px;
    }

    .eh-icon-trigger svg {
        width: 24px;
        height: 24px;
    }

    /* Compact mode on mobile */
    .te-wrap--compact .te-title {
        font-size: 1.1rem;
    }

    .te-wrap--compact .te-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .te-wrap--compact .te-card-img {
        height: 160px;
    }

    .te-wrap--compact .te-card-body {
        padding: 12px 14px 14px;
    }

    /* Sort options in drawer: touch-friendly */
    .te-sort-options .te-fopt {
        min-height: 44px;
    }
}

/* ============================================
   VERY SMALL SCREENS (<=480px)
   ============================================ */
@media (max-width: 480px) {
    .te-wrap {
        padding: 10px 8px;
    }

    .te-header {
        gap: 8px;
        margin-bottom: 12px;
    }

    .te-header-left .te-title {
        font-size: 1.15rem;
    }

    .te-search-wrap {
        height: 42px;
        padding: 0 10px;
        gap: 6px;
    }

    .te-search-wrap input {
        font-size: 0.85rem;
    }

    /* Quick tags: still 5 per row, slightly smaller */
    .te-quick-tags {
        grid-template-columns: repeat(5, 1fr);
        gap: 4px;
        margin-bottom: 12px;
        padding-bottom: 12px;
    }

    .te-qtag {
        padding: 7px 2px;
        font-size: 0.65rem;
        letter-spacing: -0.01em;
    }

    .te-card-img {
        height: 160px;
    }

    .te-card-body {
        padding: 12px 12px 14px;
    }

    .te-card-title {
        font-size: 0.95rem;
    }

    .te-card-excerpt {
        font-size: 0.78rem;
        -webkit-line-clamp: 2;
    }

    .te-card-meta {
        font-size: 0.72rem;
        gap: 6px;
    }

    .te-month-grid.te-fgroup-options {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    .eh-trigger-btn {
        padding: 10px 18px;
        font-size: 0.85rem;
        gap: 6px;
        min-height: 44px;
    }

    /* Drawer */
    .te-drawer-head {
        padding: 16px 14px;
        padding-top: max(16px, env(safe-area-inset-top, 16px));
    }

    .te-fgroup-toggle {
        padding: 12px 14px;
    }

    .te-fgroup-options {
        padding: 2px 14px 12px;
    }

    .te-fopt {
        padding: 8px 8px;
    }

    .te-drawer-foot {
        padding: 12px 14px;
        padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
    }

    /* Modal close: ensure safe area */
    .eh-modal-close {
        width: 36px;
        height: 36px;
        top: max(8px, env(safe-area-inset-top, 8px));
        right: 8px;
    }

    .eh-modal-close svg {
        width: 16px;
        height: 16px;
    }

    .eh-modal-content .te-wrap {
        padding: 10px 8px;
        padding-top: max(10px, env(safe-area-inset-top, 10px));
    }
}

/* ============================================
   ADMIN COLUMNS (Pages list table)
   ============================================ */
@media screen and (max-width: 782px) {
    /* Make admin columns scrollable on mobile */
    .wp-list-table .column-eh_region,
    .wp-list-table .column-eh_grade,
    .wp-list-table .column-eh_season,
    .wp-list-table .column-eh_tags {
        display: table-cell;
    }
}

/* ---------- PRINT ---------- */
@media print {
    .te-drawer, .te-overlay, .eh-modal { display: none !important; }
    .te-settings-btn { display: none !important; }
    .te-search-wrap, .te-sort-wrap { display: none !important; }
    .te-quick-tags { display: none !important; }
    .te-active-filters { display: none !important; }
    .te-card { break-inside: avoid; box-shadow: none; border: 1px solid #ddd; }
}