* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
    background: 
        radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(120, 219, 255, 0.2) 0%, transparent 50%),
        linear-gradient(135deg, #1a0f0a 0%, #2d1b13 25%, #000000 50%, #1a0f0a 75%, #2d1b13 100%);
    background-size: 400% 400%;
    background-attachment: scroll;
    animation: colorShift 3s ease-in-out infinite;
    min-height: 100vh;
    height: auto;
    color: #f5f5f5;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

@keyframes colorShift {
    0% {
        background-position: 0% 50%;
    }
    25% {
        background-position: 100% 50%;
    }
    50% {
        background-position: 100% 100%;
    }
    75% {
        background-position: 0% 100%;
    }
    100% {
        background-position: 0% 50%;
    }
}
.container { 
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 20px;
    position: relative;
}
.header { 
    background: rgba(0, 0, 0, 0.8) !important; 
    background-color: rgba(0, 0, 0, 0.8) !important; 
    padding: 15px; 
    border-radius: 15px; 
    margin-bottom: 15px; 
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); 
    border: 1px solid rgba(204, 85, 0, 0.2);
}
.header-content { display: flex; justify-content: space-between; align-items: center; gap: 20px; position: relative; }
.header-text { flex: 1; text-align: center; }
.header h1 { font-size: 1.8rem; color: #ff6b35; margin-bottom: 3px; }
.header p { color: #cccccc; font-size: 0.9rem; }
.refresh-status { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    margin-top: 8px; 
    font-size: 0.8rem; 
    color: #ff6b35; 
}
.refresh-indicator { 
    animation: spin 2s linear infinite; 
    font-size: 1rem; 
}
@keyframes spin { 
    0% { transform: rotate(0deg); } 
    100% { transform: rotate(360deg); } 
}
.search-section { flex: 0 0 320px; }
.search-container { display: flex; gap: 10px; margin-bottom: 15px; }
.search-input { flex: 1; padding: 12px 15px; border: 2px solid #666666; border-radius: 8px; font-size: 14px; outline: none; transition: border-color 0.3s ease; background: #2c2c2c; color: #f5f5f5; }
.search-input:focus { border-color: #ff6b35; }
.search-btn { padding: 12px 20px; background: #ff6b35; color: white; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: bold; transition: background-color 0.3s ease; }
.search-btn:hover { background: #e55a2b; }
.keyword-count { margin-bottom: 10px; }
.keyword-count-display { background: linear-gradient(135deg, #ff6b35 0%, #2c2c2c 100%); color: white; padding: 12px; border-radius: 10px; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,0.3); }
.keyword-count-display.no-results { background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%); }
.count-number { font-size: 1.8rem; font-weight: bold; margin-bottom: 4px; text-shadow: 0 2px 4px rgba(0,0,0,0.3); }
.count-label { font-size: 0.95rem; opacity: 0.9; font-weight: 500; }
.count-loading { background: #2c2c2c; color: #ff6b35; padding: 15px; border-radius: 8px; text-align: center; font-weight: bold; }
.search-results { max-height: 400px; overflow-y: auto; }
.search-summary { background: rgba(0,0,0,0.6); padding: 15px; border-radius: 8px; margin-bottom: 15px; border: 1px solid rgba(204,85,0,0.2); }
.search-summary h3 { color: #ff6b35; margin-bottom: 5px; font-size: 1.1rem; }
.search-count { color: #cccccc; font-size: 0.9rem; margin: 0; }
.search-posts { display: flex; flex-direction: column; gap: 10px; }
.search-post { background: rgba(0,0,0,0.6); padding: 15px; border-radius: 8px; border-left: 4px solid #ff6b35; border: 1px solid rgba(255,107,53,0.2); }
.search-post-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.search-post-date { color: #cccccc; font-size: 0.8rem; }
.search-post-text { margin-bottom: 8px; line-height: 1.4; color: #f5f5f5; }
.search-post-stats { color: #cccccc; font-size: 0.8rem; }
.search-loading, .search-error, .search-no-results { text-align: center; padding: 20px; color: #cccccc; font-style: italic; }
.search-error { color: #e74c3c; }
.search-more { text-align: center; padding: 10px; color: #cccccc; font-style: italic; font-size: 0.9rem; }
mark { background: #ff6b35; color: white; padding: 2px 4px; border-radius: 3px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-card { 
    background: rgba(0,0,0,0.8); 
    padding: 25px; 
    border-radius: 15px; 
    text-align: center; 
    box-shadow: 0 8px 25px rgba(0,0,0,0.5); 
    border: 1px solid rgba(204,85,0,0.2); 
    transition: transform 0.3s ease;
}
.stat-card:hover { 
    transform: translateY(-5px);
}
.stat-number { font-size: 2.5rem; font-weight: bold; color: #ff6b35; margin-bottom: 10px; }
.stat-label { color: #cccccc; font-size: 1rem; text-transform: uppercase; letter-spacing: 1px; }
.section { background: rgba(0,0,0,0.8); padding: 25px; border-radius: 15px; margin-bottom: 20px; box-shadow: 0 8px 25px rgba(0,0,0,0.5); border: 1px solid rgba(204,85,0,0.2); }
.section h2 { color: #ff6b35; margin-bottom: 20px; }
.loading { text-align: center; padding: 40px; color: #ff6b35; font-size: 1.2rem; }

/* Additional styles for better dark theme consistency */
::placeholder { color: #999999; }
input[type="text"] { color: #f5f5f5; }
input[type="text"]::placeholder { color: #999999; }

/* Fix input field text color for sentiment analysis sections - MUST OVERRIDE GLOBAL STYLES */
.post-content-input,
input.post-content-input,
textarea.post-content-input {
  color: #000000 !important;
  background: #ffffff !important;
}

.post-content-input::placeholder,
input.post-content-input::placeholder,
textarea.post-content-input::placeholder {
  color: #999999 !important;
}

.post-content-input:focus,
input.post-content-input:focus,
textarea.post-content-input:focus {
  color: #000000 !important;
  background: #ffffff !important;
}

/* Also override for input type="text" with class post-content-input */
input[type="text"].post-content-input {
  color: #000000 !important;
  background: #ffffff !important;
}

input[type="text"].post-content-input::placeholder {
  color: #999999 !important;
}

/* Authentication styles */
.user-info {
    position: absolute;
    top: 10px;
    left: 10px;
    color: #ffffff;
    font-size: 0.8rem;
    background: rgba(0, 41, 0, 0.274);
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid rgba(0, 41, 0, 0.82);
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.logout-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    margin-top: 35px;
    padding: 6px 12px;
    background: rgba(0, 41, 0, 0.274);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.3s ease;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(5, 0, 0, 0.313);
}

.logout-btn:hover {
    background: hsla(120, 2%, 20%, 0.489);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px hsla(120, 2%, 20%, 0.489);
}

/* ======================= */
/* Top Keywords Analysis Styles */
/* ======================= */
.keywords-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 20px;
}

.analyze-btn {
    padding: 12px 24px;
    background: linear-gradient(135deg, #ff6b35 0%, #e55a2b 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255,107,53,0.3);
}

.analyze-btn:hover {
    background: linear-gradient(135deg, #e55a2b 0%, #d44a1a 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.keywords-info {
    flex: 1;
    text-align: right;
}

.keywords-info-text {
    color: #cccccc;
    font-size: 0.9rem;
    font-style: italic;
}

.top-keywords-results {
    max-height: 600px;
    overflow-y: auto;
}

.top-keywords-summary {
    background: rgba(0,0,0,0.6);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid rgba(204,85,0,0.2);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.top-keywords-summary h3 {
    color: #ff6b35;
    margin-bottom: 15px;
    font-size: 1.3rem;
    text-align: center;
}

.keywords-stats {
    display: flex;
    justify-content: space-around;
    gap: 20px;
}

.stat-item {
    text-align: center;
    flex: 1;
}

.stat-label {
    display: block;
    color: #cccccc;
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.stat-value {
    display: block;
    color: #ff6b35;
    font-size: 1.2rem;
    font-weight: bold;
}

.keywords-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.keyword-item {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(0, 0, 0, 0.235);
    padding: 15px 20px;
    border-radius: 10px;
    border: 1px solid rgba(204,85,0,0.2);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.keyword-item:hover {
    background: rgba(0,0,0,0.8);
    border-color: rgba(204,85,0,0.4);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

.keyword-rank {
    font-size: 1.2rem;
    font-weight: bold;
    color: #ff6b35;
    min-width: 30px;
    text-align: center;
}

.keyword-content {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.keyword-word {
    font-size: 1.1rem;
    font-weight: bold;
    color: #f5f5f5;
    text-transform: capitalize;
}

.keyword-count {
    color: #ff6b35;
    font-weight: bold;
    font-size: 1rem;
}

.keyword-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(204,85,0,0.1);
    border-radius: 0 0 10px 10px;
}

.keyword-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff6b35 0%, #e55a2b 100%);
    border-radius: 0 0 10px 10px;
    transition: width 0.8s ease;
}

/* Multi-Keyword Counter Styles */
.multi-keyword-inputs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

/* Multi-Keyword Trend Styles */
.multi-keyword-trend-controls {
    margin-bottom: 20px;
}

/* Trend controls */
.trend-controls {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

/* View switch styling */
.view-switch {
    display: flex;
    align-items: center;
    gap: 10px;
}

.switch-label {
    font-weight: 600;
    color: #ff6b35;
    font-size: 0.9rem;
}

.switch-container {
    display: flex;
    background: rgba(255, 107, 53, 0.1);
    border-radius: 8px;
    padding: 4px;
    border: 1px solid rgba(255, 107, 53, 0.3);
}

.switch-option {
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.3s ease;
    color: #cccccc;
    background: transparent;
    border: none;
    position: relative;
}

.switch-option:hover {
    background: rgba(255, 107, 53, 0.2);
    color: #ffffff;
}

input[type="radio"] {
    display: none;
}

input[type="radio"]:checked + .switch-option {
    background: #ff6b35;
    color: #000000;
    font-weight: 600;
}

input[type="radio"]:checked + .switch-option::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 4px;
    background: #000000;
    border-radius: 50%;
}

.multi-trend-chart-wrapper {
    position: relative;
    width: 100%;
    height: 400px;
    background: rgba(0,0,0,0.3);
    border-radius: 10px;
    border: 1px solid rgba(204,85,0,0.2);
    padding: 15px;
}

/* Multi-trend chart grid styling - same as single trend chart */
.multi-trend-chart-wrapper canvas,
.multi-trend-chart-wrapper svg {
    background: transparent !important;
}

/* Grid lines for multi-trend chart */
.multi-trend-chart-wrapper .grid line,
.multi-trend-chart-wrapper .tick line,
.multi-trend-chart-wrapper .domain {
    stroke: rgba(255, 255, 255, 0.2) !important;
    stroke-width: 1px !important;
}

.multi-trend-chart-wrapper .grid .tick line {
    stroke: rgba(255, 255, 255, 0.3) !important;
    stroke-width: 1px !important;
}

/* Background grid pattern for multi-trend chart */
.multi-trend-chart-wrapper {
    background: 
        linear-gradient(to right, rgba(255,255,255,0.1) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255,255,255,0.1) 1px, transparent 1px) !important;
    background-size: 25px 25px !important;
}

/* Chart text styling for multi-trend */
.multi-trend-chart-wrapper text,
.multi-trend-chart-wrapper .axis text,
.multi-trend-chart-wrapper .tick text {
    fill: #ffffff !important;
    color: #ffffff !important;
    font-size: 12px !important;
}

/* Chart axes for multi-trend */
.multi-trend-chart-wrapper .axis line,
.multi-trend-chart-wrapper .axis path {
    stroke: rgba(255, 255, 255, 0.4) !important;
    stroke-width: 1px !important;
}

.loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ff6b35;
    font-size: 1.1rem;
    font-weight: bold;
    text-align: center;
    z-index: 10;
}

.no-data-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #cccccc;
    font-size: 1rem;
    text-align: center;
    font-style: italic;
    z-index: 10;
}

.hidden {
    display: none;
}

.multi-keyword-inputs input {
    flex: 1;
    min-width: 150px;
    padding: 12px 15px;
    border: 2px solid #666666;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s ease;
    background: #2c2c2c;
    color: #f5f5f5;
}

.multi-keyword-inputs input:focus {
    border-color: #ff6b35;
}

.multi-keyword-inputs button {
    padding: 12px 20px;
    background: #ff6b35;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: background-color 0.3s ease;
    white-space: nowrap;
}

.multi-keyword-inputs button:hover {
    background: #e55a2b;
}

.multi-keyword-results {
    max-height: 600px;
    overflow-y: auto;
}

.multi-keyword-summary {
    background: rgba(0,0,0,0.6);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    border-left: 4px solid #cc5500;
    border: 1px solid rgba(204,85,0,0.2);
}

.multi-keyword-summary h3 {
    color: #ff6b35;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.keyword-stats {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.keyword-stat {
    background: rgba(255, 107, 53, 0.1);
    padding: 10px 15px;
    border-radius: 8px;
    border: 1px solid #ff6b35;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 120px;
}

.keyword-name {
    color: #ff6b35;
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.keyword-count {
    color: #f5f5f5;
    font-size: 1.1rem;
    font-weight: bold;
}

.keyword-section {
    background: rgba(0,0,0,0.6);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 15px;
    border-left: 4px solid #cc5500;
    border: 1px solid rgba(204,85,0,0.2);
}

.keyword-section h4 {
    color: #ff6b35;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.posts-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.multi-keyword-post {
    background: rgba(0, 0, 0, 0.6);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid rgba(204,85,0,0.2);
}

.post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.post-header strong {
    color: #ff6b35;
}

.post-date {
    color: #cccccc;
    font-size: 0.8rem;
}

.post-text {
    margin-bottom: 8px;
    line-height: 1.4;
    color: #f5f5f5;
}

.post-stats {
    color: #cccccc;
    font-size: 0.8rem;
}

.more-posts {
    text-align: center;
    color: #ff6b35;
    font-style: italic;
    margin-top: 10px;
    font-size: 0.9rem;
}

/* Scrollbar styling for dark theme */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #2c2c2c; }
::-webkit-scrollbar-thumb { background: #ff6b35; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #e55a2b; }

/* Chart grid lines styling - seperti Google Trends */
.chart-container,
.chart-area,
canvas,
svg {
    background: transparent !important;
}

/* Garis grid horizontal dan vertikal */
.chart-container .grid line,
.chart-container .tick line,
.chart-container .domain {
    stroke: rgba(255, 255, 255, 0.2) !important;
    stroke-width: 1px !important;
}

/* Garis grid yang lebih jelas */
.chart-container .grid .tick line {
    stroke: rgba(255, 255, 255, 0.3) !important;
    stroke-width: 1px !important;
}

/* Background grid pattern */
.chart-container {
    background: 
        linear-gradient(to right, rgba(255,255,255,0.1) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255,255,255,0.1) 1px, transparent 1px) !important;
    background-size: 25px 25px !important;
}

/* Chart text styling */
.chart-container text,
.chart-container .axis text,
.chart-container .tick text {
    fill: #ffffff !important;
    color: #ffffff !important;
    font-size: 12px !important;
}

/* Chart axes */
.chart-container .axis line,
.chart-container .axis path {
    stroke: rgba(255, 255, 255, 0.4) !important;
    stroke-width: 1px !important;
}

/* ============================================ */
/* COMPREHENSIVE MOBILE RESPONSIVE DESIGN */
/* ============================================ */

/* Tablet and below (768px) */
@media (max-width: 768px) {
  .container {
    padding: 15px;
    max-width: 100%;
  }

  .header {
    padding: 15px;
    margin-bottom: 15px;
  }

  .header-content {
    flex-direction: column;
    gap: 15px;
    align-items: stretch;
  }

  .header-text {
    text-align: center;
  }

  .header h1 {
    font-size: 1.5rem;
    margin-bottom: 5px;
  }

  .header p {
    font-size: 0.85rem;
  }

  .refresh-status {
    font-size: 0.75rem;
    justify-content: center;
  }

  .search-section {
    flex: 1;
    max-width: 100%;
  }

  .search-container {
    flex-direction: column;
    gap: 10px;
  }

  .search-input {
    width: 100%;
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 14px;
  }

  .search-btn {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    min-height: 44px; /* Touch-friendly */
  }

  .keyword-count-display {
    padding: 15px;
  }

  .count-number {
    font-size: 1.5rem;
  }

  .count-label {
    font-size: 0.85rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 20px;
  }

  .stat-card {
    padding: 20px;
  }

  .stat-number {
    font-size: 2rem;
  }

  .stat-label {
    font-size: 0.9rem;
  }

  .section {
    padding: 20px;
    margin-bottom: 15px;
  }

  .section h2 {
    font-size: 1.3rem;
    margin-bottom: 15px;
  }

  /* Sentiment Analysis Mobile */
  .sentiment-container {
    padding: 20px;
  }

  .post-content-input {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 14px;
    min-height: 120px;
  }

  .analyze-sentiment-btn {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    min-height: 44px; /* Touch-friendly */
    margin-top: 10px;
  }

  .analyze-btn {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    min-height: 44px;
  }

  /* Keywords Controls */
  .keywords-controls {
    flex-direction: column;
    gap: 15px;
  }

  .keywords-info {
    text-align: center;
  }

  .keywords-info-text {
    font-size: 0.85rem;
  }

  /* Multi-Keyword Inputs */
  .multi-keyword-inputs {
    flex-direction: column;
    gap: 10px;
  }

  .multi-keyword-inputs input {
    width: 100%;
    min-width: 100%;
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 14px;
    min-height: 44px;
  }

  .multi-keyword-inputs button {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    min-height: 44px;
  }

  /* Trend Controls */
  .trend-controls {
    flex-direction: column;
    gap: 15px;
  }

  .view-switch {
    width: 100%;
    justify-content: center;
  }

  /* Chart Containers */
  .chart-container,
  #sentimentTimelineChart,
  #multiTrendChart {
    width: 100% !important;
    height: 300px !important;
    max-height: 300px !important;
  }

  .multi-trend-chart-wrapper {
    height: 300px !important;
    padding: 10px;
  }

  /* Timeline Chart */
  #sentiment-timeline-chart-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #sentimentTimelineChart {
    min-width: 100%;
  }

  /* Tables */
  #keyword-sentiment-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #keyword-sentiment-table {
    font-size: 0.85rem;
    min-width: 600px;
  }

  #keyword-sentiment-table th,
  #keyword-sentiment-table td {
    padding: 10px 8px;
    font-size: 0.85rem;
  }

  /* User Info */
  .user-info {
    position: relative;
    top: 0;
    left: 0;
    margin-bottom: 10px;
    font-size: 0.75rem;
    padding: 8px;
  }

  .logout-btn {
    position: relative;
    top: 0;
    left: 0;
    margin-top: 5px;
    width: 100%;
    padding: 10px;
    font-size: 0.85rem;
  }

  /* Result Items */
  .result-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
  }

  .result-label {
    font-size: 0.9rem;
  }

  .sentiment-value {
    font-size: 1rem;
    padding: 8px 12px;
  }

  /* Keyword Items */
  .keyword-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 15px;
  }

  .keyword-content {
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }

  .keyword-word {
    font-size: 1rem;
  }

  .keyword-count {
    font-size: 0.9rem;
  }

  /* Timeline Inputs */
  #timeline-keyword-input {
    width: 100%;
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 12px;
    min-height: 44px;
    margin-bottom: 10px;
  }

  #load-sentiment-timeline-btn,
  #load-weekly-timeline-btn {
    width: 100%;
    margin-bottom: 10px;
    padding: 14px;
    font-size: 16px;
    min-height: 44px;
  }

  /* Switch Options */
  .switch-container {
    width: 100%;
    justify-content: center;
  }

  .switch-option {
    flex: 1;
    padding: 10px;
    font-size: 0.85rem;
    min-height: 44px;
  }
}

/* Mobile phones (480px and below) */
@media (max-width: 480px) {
  .container {
    padding: 10px;
  }

  .header {
    padding: 12px;
    margin-bottom: 12px;
  }

  .header h1 {
    font-size: 1.2rem;
    line-height: 1.3;
  }

  .header p {
    font-size: 0.8rem;
    line-height: 1.4;
  }

  .refresh-status {
    font-size: 0.7rem;
    flex-wrap: wrap;
    justify-content: center;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stat-card {
    padding: 15px;
  }

  .stat-number {
    font-size: 1.8rem;
  }

  .stat-label {
    font-size: 0.85rem;
  }

  .section {
    padding: 15px;
    margin-bottom: 12px;
  }

  .section h2 {
    font-size: 1.1rem;
    margin-bottom: 12px;
  }

  .sentiment-container {
    padding: 15px;
  }

  .post-content-input {
    padding: 12px;
    font-size: 16px;
    min-height: 100px;
  }

  .analyze-sentiment-btn,
  .analyze-btn {
    padding: 12px;
    font-size: 16px;
  }

  .count-number {
    font-size: 1.3rem;
  }

  .count-label {
    font-size: 0.8rem;
  }

  /* Chart Containers - Smaller on phones */
  .chart-container,
  #sentimentTimelineChart,
  #multiTrendChart {
    height: 250px !important;
    max-height: 250px !important;
  }

  .multi-trend-chart-wrapper {
    height: 250px !important;
    padding: 8px;
  }

  /* Tables - Even more compact */
  #keyword-sentiment-table {
    font-size: 0.75rem;
    min-width: 500px;
  }

  #keyword-sentiment-table th,
  #keyword-sentiment-table td {
    padding: 8px 6px;
    font-size: 0.75rem;
  }

  /* Timeline Summary */
  #timeline-summary {
    font-size: 0.85rem;
    padding: 8px;
  }

  /* Keyword Stats */
  .keyword-stats {
    flex-direction: column;
    gap: 10px;
  }

  .keyword-stat {
    width: 100%;
    min-width: 100%;
  }

  /* Top Keywords Summary */
  .top-keywords-summary h3 {
    font-size: 1.1rem;
  }

  .keywords-stats {
    flex-direction: column;
    gap: 10px;
  }

  .stat-item {
    width: 100%;
  }

  /* Search Posts */
  .search-post {
    padding: 12px;
  }

  .search-post-text {
    font-size: 0.9rem;
    line-height: 1.5;
  }

  .search-post-date,
  .search-post-stats {
    font-size: 0.75rem;
  }

  /* Multi-keyword Post */
  .multi-keyword-post {
    padding: 12px;
  }

  .post-text {
    font-size: 0.9rem;
    line-height: 1.5;
  }

  .post-date,
  .post-stats {
    font-size: 0.75rem;
  }
}

/* Very small phones (360px and below) */
@media (max-width: 360px) {
  .container {
    padding: 8px;
  }

  .header h1 {
    font-size: 1.1rem;
  }

  .header p {
    font-size: 0.75rem;
  }

  .section h2 {
    font-size: 1rem;
  }

  .stat-number {
    font-size: 1.5rem;
  }

  .chart-container,
  #sentimentTimelineChart,
  #multiTrendChart {
    height: 200px !important;
    max-height: 200px !important;
  }

  .multi-trend-chart-wrapper {
    height: 200px !important;
  }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
  .chart-container,
  #sentimentTimelineChart,
  #multiTrendChart {
    height: 250px !important;
    max-height: 250px !important;
  }

  .multi-trend-chart-wrapper {
    height: 250px !important;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Touch-friendly improvements for all mobile devices */
@media (hover: none) and (pointer: coarse) {
  /* Ensure all buttons are touch-friendly */
  button,
  .search-btn,
  .analyze-btn,
  .analyze-sentiment-btn,
  .switch-option,
  .view-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 16px;
    font-size: 16px;
    -webkit-tap-highlight-color: rgba(255, 107, 53, 0.3);
  }

  /* Improve input touch targets */
  input[type="text"],
  textarea,
  .search-input,
  .post-content-input {
    min-height: 44px;
    font-size: 16px; /* Prevents zoom on iOS */
    -webkit-tap-highlight-color: rgba(255, 107, 53, 0.2);
  }

  /* Remove hover effects on touch devices */
  .stat-card:hover {
    transform: none;
  }

  .keyword-item:hover {
    transform: none;
    background: rgba(0, 0, 0, 0.235);
  }

  /* Improve scrolling */
  .search-results,
  .top-keywords-results,
  .multi-keyword-results {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
}

/* Touch scrolling — allow vertical pan on page */
@media (hover: none) and (pointer: coarse) {
  html, body {
    overflow-y: auto !important;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    background-attachment: scroll !important;
  }
}

/* Hide only the bottom axis line */
#multiTrendChart canvas {
    border: none !important;
}

/* ============================================ */
/* ENHANCED MOBILE DESIGN IMPROVEMENTS */
/* ============================================ */

/* Additional mobile improvements for better UX */
@media (max-width: 768px) {
  /* View buttons - better mobile layout */
  .view-btn {
    padding: 10px 12px;
    font-size: 0.8rem;
    min-height: 44px;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Timeline section improvements */
  #sentiment-timeline-section {
    padding: 15px;
  }

  #sentiment-timeline-section h2 {
    font-size: 1.2rem;
    margin-bottom: 15px;
  }

  /* Timeline chart container */
  #sentiment-timeline-chart-container {
    position: relative;
    width: 100%;
    height: 300px;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    border: 1px solid rgba(204, 85, 0, 0.2);
  }

  /* Timeline summary mobile */
  #timeline-summary {
    font-size: 0.9rem;
    padding: 12px;
    margin-top: 10px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
  }

  /* Better spacing for sections */
  .section {
    margin-bottom: 15px;
  }

  /* Search results better scrolling */
  .search-results {
    max-height: 400px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  /* Top keywords results */
  .top-keywords-results {
    max-height: 500px;
    -webkit-overflow-scrolling: touch;
  }

  /* Multi keyword results */
  .multi-keyword-results {
    max-height: 500px;
    -webkit-overflow-scrolling: touch;
  }

  /* Switch container better mobile layout */
  .switch-container {
    display: flex;
    width: 100%;
    gap: 4px;
    padding: 4px;
  }

  .switch-option {
    flex: 1;
    text-align: center;
    padding: 10px 8px;
    font-size: 0.75rem;
  }

  /* Better form group spacing */
  .form-group {
    margin-bottom: 15px;
  }

  /* Sentiment result items */
  .sentiment-result-item {
    padding: 12px;
    margin-bottom: 10px;
  }
}

/* Mobile phones (480px and below) - Enhanced */
@media (max-width: 480px) {
  /* View buttons - smaller text on phones */
  .view-btn {
    padding: 8px 10px;
    font-size: 0.7rem;
    min-height: 40px;
  }

  /* Timeline chart - smaller on phones */
  #sentiment-timeline-chart-container {
    height: 250px;
    padding: 8px;
  }

  /* Better header spacing */
  .header-content {
    gap: 12px;
  }

  /* Search section full width */
  .search-section {
    width: 100%;
  }

  /* Stats grid single column */
  .stats-grid {
    gap: 10px;
  }

  /* Section padding reduced */
  .section {
    padding: 12px;
  }

  /* Chart wrapper smaller */
  .multi-trend-chart-wrapper {
    padding: 5px;
  }

  /* Switch options - wrap if needed */
  .switch-container {
    flex-wrap: wrap;
  }

  .switch-option {
    min-width: calc(50% - 2px);
    font-size: 0.7rem;
    padding: 8px 6px;
  }

  /* Timeline inputs full width */
  #timeline-keyword-input {
    margin-bottom: 8px;
  }

  #load-sentiment-timeline-btn,
  #load-weekly-timeline-btn {
    margin-bottom: 8px;
  }
}

/* Very small phones (360px and below) - Enhanced */
@media (max-width: 360px) {
  /* View buttons - even smaller */
  .view-btn {
    padding: 6px 8px;
    font-size: 0.65rem;
    min-height: 38px;
  }

  /* Timeline chart - minimal height */
  #sentiment-timeline-chart-container {
    height: 200px;
    padding: 5px;
  }

  /* Switch options - full width on very small */
  .switch-container {
    flex-direction: column;
  }

  .switch-option {
    width: 100%;
    min-width: 100%;
  }

  /* Header text smaller */
  .header h1 {
    font-size: 1rem;
  }

  .header p {
    font-size: 0.7rem;
  }

  /* Section headings */
  .section h2 {
    font-size: 0.95rem;
  }
}

/* Landscape mobile - Better chart height */
@media (max-width: 768px) and (orientation: landscape) {
  #sentiment-timeline-chart-container {
    height: 280px;
  }

  .multi-trend-chart-wrapper {
    height: 280px;
  }

  /* Stats grid 4 columns in landscape */
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
  }

  .stat-card {
    padding: 12px;
  }

  .stat-number {
    font-size: 1.5rem;
  }

  .stat-label {
    font-size: 0.75rem;
  }
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
  /* iOS Safari specific styles */
  input[type="text"],
  textarea,
  .search-input,
  .post-content-input {
    font-size: 16px !important; /* Prevents zoom on iOS */
    -webkit-appearance: none;
    border-radius: 8px;
  }

  button,
  .search-btn,
  .analyze-btn {
    -webkit-appearance: none;
    border-radius: 8px;
  }

  /* Better scrolling on iOS */
  .search-results,
  .top-keywords-results,
  .multi-keyword-results {
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
  }
}

/* Android specific fixes */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
  /* Android Chrome specific */
  input[type="text"],
  textarea {
    font-size: 16px; /* Prevents zoom */
  }
}

/* Better touch targets for all interactive elements */
@media (hover: none) and (pointer: coarse) {
  html, body {
    touch-action: pan-y !important;
  }
  a,
  button,
  .search-btn,
  .analyze-btn,
  .analyze-sentiment-btn,
  .switch-option,
  .view-btn,
  input[type="button"],
  input[type="submit"] {
    min-height: 44px;
    min-width: 44px;
    touch-action: pan-y;
    -webkit-tap-highlight-color: rgba(255, 107, 53, 0.3);
  }

  /* Better spacing for touch */
  .search-container {
    gap: 12px;
  }

  .multi-keyword-inputs {
    gap: 12px;
  }

  /* Remove hover transforms on touch */
  .stat-card:hover {
    transform: none;
  }

  .keyword-item:hover {
    transform: none;
  }

  /* Better scroll areas */
  .search-results,
  .top-keywords-results,
  .multi-keyword-results,
  #sentiment-timeline-chart-container {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
  }
}

/* Prevent text selection on buttons (better UX) */
button,
.view-btn,
.switch-option,
.search-btn,
.analyze-btn {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Better focus states for accessibility */
button:focus,
input:focus,
textarea:focus,
.view-btn:focus,
.switch-option:focus {
  outline: 2px solid #ff6b35;
  outline-offset: 2px;
}

/* Smooth transitions for mobile */
@media (prefers-reduced-motion: no-preference) {
  button,
  .view-btn,
  .switch-option,
  .stat-card,
  .keyword-item {
    transition: all 0.2s ease;
  }
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
