:root {
    --bg-primary: #0b0f19;
    --bg-secondary: #111827;
    --bg-tertiary: #1a2236;
    --bg-hover: #232d45;
    --border-color: #2a3650;
    --border-light: #374765;
    --text-primary: #f0f2f5;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --accent-gold: #f59e0b;
    --accent-gold-hover: #fbbf24;
    --up-green: #10b981;
    --down-red: #ef4444;
    --info-blue: #3b82f6;
    --terminal-font: 'JetBrains Mono', 'Noto Sans Thai', monospace;
    --body-font: 'Inter', 'Noto Sans Thai', sans-serif;
    --sidebar-width: 240px;
    --widget-width: 300px;
    --header-height: 40px;
    --mobile-header-height: 56px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--body-font);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

button {
    border: none;
    background: none;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

/* ========== Ticker Strip ========== */
.ticker-strip {
    background: #070a10;
    border-bottom: 1px solid var(--border-color);
    height: var(--header-height);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
}

.ticker-inner {
    width: 100%;
    max-width: 1920px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.ticker-label {
    font-family: var(--terminal-font);
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-gold);
    white-space: nowrap;
    letter-spacing: 0.08em;
}

.ticker-label i {
    margin-right: 4px;
}

.ticker-marquee {
    flex: 1;
    overflow: hidden;
    position: relative;
    mask-image: linear-gradient(90deg, transparent, black 5%, black 95%, transparent);
    -webkit-mask-image: linear-gradient(90deg, transparent, black 5%, black 95%, transparent);
}

.ticker-track {
    display: flex;
    gap: 28px;
    white-space: nowrap;
    animation: ticker-scroll 40s linear infinite;
}

.ticker-track:hover {
    animation-play-state: paused;
}

.ticker-item {
    font-size: 12px;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.ticker-item:hover {
    color: var(--text-primary);
}

.ticker-time {
    font-family: var(--terminal-font);
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 70px;
    text-align: right;
}

@keyframes ticker-scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* ========== Mobile Header ========== */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--mobile-header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    z-index: 999;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
}

.mobile-menu-btn,
.mobile-search-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 18px;
    border-radius: 6px;
    transition: all 0.2s;
}

.mobile-menu-btn:hover,
.mobile-search-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.mobile-logo {
    font-family: var(--terminal-font);
    font-size: 20px;
    font-weight: 700;
}

.mobile-logo .logo-mark {
    color: var(--text-primary);
}

.mobile-logo .logo-suffix {
    color: var(--accent-gold);
}

.mobile-search-bar {
    display: none;
    position: fixed;
    top: var(--mobile-header-height);
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 16px;
    z-index: 998;
    transform: translateY(-100%);
    opacity: 0;
    transition: all 0.3s ease;
}

.mobile-search-bar.open {
    transform: translateY(0);
    opacity: 1;
}

.mobile-search-form {
    display: flex;
    gap: 8px;
}

.mobile-search-form input {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

.mobile-search-form input:focus {
    border-color: var(--accent-gold);
}

.mobile-search-form button {
    width: 42px;
    background: var(--accent-gold);
    color: #000;
    border-radius: 6px;
    font-size: 16px;
}

/* ========== Layout ========== */
.terminal-layout {
    display: flex;
    min-height: 100vh;
    padding-top: var(--header-height);
}

/* ========== Sidebar ========== */
.terminal-sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: var(--header-height);
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-brand {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
}

.brand-link {
    display: flex;
    align-items: baseline;
    gap: 4px;
    flex-wrap: wrap;
}

.brand-mark {
    font-family: var(--terminal-font);
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.03em;
}

.brand-name {
    font-family: var(--terminal-font);
    font-size: 22px;
    font-weight: 700;
    color: var(--accent-gold);
    letter-spacing: -0.03em;
}

.brand-tag {
    font-family: var(--terminal-font);
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.12em;
    padding: 2px 6px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    margin-left: auto;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    position: relative;
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(245, 158, 11, 0.08);
    color: var(--accent-gold);
    border-left-color: var(--accent-gold);
}

.nav-icon {
    width: 20px;
    text-align: center;
    font-size: 14px;
    color: inherit;
}

.nav-bullet {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.5;
}

.nav-item.active .nav-bullet {
    opacity: 1;
    background: var(--accent-gold);
}

.nav-item.child {
    padding-left: 38px;
    font-size: 12px;
    color: var(--text-muted);
}

.nav-item.child .nav-bullet {
    width: 4px;
    height: 4px;
    opacity: 0.35;
}

.nav-item.child:hover {
    color: var(--text-secondary);
    background: var(--bg-tertiary);
}

.nav-item.child.active {
    background: rgba(245, 158, 11, 0.05);
    color: var(--accent-gold);
}

.nav-item.child.active .nav-bullet {
    opacity: 1;
    background: var(--accent-gold);
}

.nav-group {
    display: flex;
    flex-direction: column;
}

.nav-item.parent {
    justify-content: space-between;
    padding-right: 14px;
}

.nav-chevron {
    margin-left: auto;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.25s ease, color 0.2s;
    cursor: pointer;
    border-radius: 4px;
}

.nav-chevron:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-group.open .nav-chevron {
    transform: rotate(90deg);
    color: var(--accent-gold);
}

.nav-children {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    display: flex;
    flex-direction: column;
}

.nav-group.open .nav-children {
    max-height: 500px;
}

.nav-group.no-children .nav-chevron {
    display: none;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: rgba(0,0,0,0.15);
}

.lang-switcher {
    margin-bottom: 14px;
}

.lang-label {
    display: block;
    font-family: var(--terminal-font);
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    margin-bottom: 8px;
}

.lang-links {
    display: flex;
    gap: 6px;
}

.lang-link {
    font-family: var(--terminal-font);
    font-size: 11px;
    font-weight: 600;
    padding: 5px 8px;
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.lang-link:hover,
.lang-link.active {
    background: var(--accent-gold);
    color: #000;
    border-color: var(--accent-gold);
}

.market-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--terminal-font);
    font-size: 11px;
    color: var(--text-secondary);
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-dot.online {
    background: var(--up-green);
    box-shadow: 0 0 8px var(--up-green);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ========== Main Content ========== */
.terminal-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    margin-right: var(--widget-width);
    min-height: calc(100vh - var(--header-height));
    padding: 24px;
}

/* ========== Widgets ========== */
.terminal-widgets {
    width: var(--widget-width);
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    position: fixed;
    right: 0;
    top: var(--header-height);
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
    padding: 20px;
}

.widget {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.widget-title {
    font-family: var(--terminal-font);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.08em;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.widget-title i {
    color: var(--accent-gold);
    font-size: 12px;
}

.widget-search-form {
    display: flex;
    gap: 8px;
}

.widget-search-form input {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 9px 12px;
    color: var(--text-primary);
    font-size: 12px;
    outline: none;
}

.widget-search-form input:focus {
    border-color: var(--accent-gold);
}

.widget-search-form button {
    width: 36px;
    background: var(--accent-gold);
    color: #000;
    border-radius: 6px;
    font-size: 13px;
    transition: background 0.2s;
}

.widget-search-form button:hover {
    background: var(--accent-gold-hover);
}

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

.market-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: var(--terminal-font);
    font-size: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.market-row:last-child {
    border-bottom: none;
}

.market-symbol {
    color: var(--text-secondary);
    min-width: 60px;
    font-weight: 600;
}

.market-price {
    color: var(--text-primary);
    text-align: right;
    flex: 1;
}

.market-change {
    text-align: right;
    min-width: 70px;
    font-weight: 600;
}

.market-change.up {
    color: var(--up-green);
}

.market-change.down {
    color: var(--down-red);
}

.hot-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hot-link {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 12px;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.hot-link:hover {
    color: var(--text-primary);
}

.hot-rank {
    font-family: var(--terminal-font);
    font-size: 11px;
    font-weight: 700;
    color: var(--accent-gold);
    min-width: 20px;
}

.hot-title {
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-pill {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 5px 10px;
    border-radius: 4px;
    transition: all 0.2s;
}

.tag-pill:hover {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
    background: rgba(245, 158, 11, 0.08);
}

/* ========== Footer ========== */
.terminal-footer {
    background: #070a10;
    border-top: 1px solid var(--border-color);
    margin-left: var(--sidebar-width);
    margin-right: var(--widget-width);
    padding: 14px 24px;
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    font-family: var(--terminal-font);
    font-size: 11px;
    color: var(--text-muted);
}

.footer-brand {
    color: var(--accent-gold);
    font-weight: 600;
}

.footer-divider {
    margin: 0 8px;
}

/* ========== Common Components ========== */
.section-header {
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
}

.section-title {
    font-family: var(--terminal-font);
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.01em;
}

.section-title::before {
    content: '';
    width: 4px;
    height: 22px;
    background: var(--accent-gold);
    border-radius: 2px;
}

.section-desc {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 8px;
    line-height: 1.5;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--accent-gold);
    color: #000;
    font-size: 12px;
    font-weight: 600;
    padding: 9px 16px;
    border-radius: 6px;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: var(--accent-gold-hover);
    transform: translateY(-1px);
}

/* Grid layouts */
.grid-2,
.grid-3,
.grid-4 {
    display: grid;
    gap: 20px;
}

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

/* Prev / Next navigation */
.prev-next-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 28px;
}

.prev-next-nav .card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 80px;
}

.prev-next-nav .card:only-child {
    grid-column: span 2;
}

/* Cards */
.card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.25s;
}

.card:hover {
    border-color: var(--border-light);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.08);
}

.card-image {
    aspect-ratio: 16/9;
    overflow: hidden;
    background: var(--bg-secondary);
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s;
}

.card:hover .card-image img {
    transform: scale(1.04);
}

.card-body {
    padding: 16px;
}

.card-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 10px;
    font-family: var(--terminal-font);
}

.card-category {
    color: var(--accent-gold);
    font-weight: 600;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.45;
    color: var(--text-primary);
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s;
}

.card:hover .card-title {
    color: var(--accent-gold-hover);
}

.card-excerpt {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Article list item */
.list-item {
    display: flex;
    gap: 18px;
    padding: 18px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.list-thumb {
    width: 180px;
    height: 110px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-tertiary);
}

.list-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s;
}

.list-item:hover .list-thumb img {
    transform: scale(1.04);
}

.list-content {
    flex: 1;
    min-width: 0;
}

.list-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-family: var(--terminal-font);
}

.list-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.45;
    color: var(--text-primary);
    margin-bottom: 8px;
    transition: color 0.2s;
}

.list-item:hover .list-title {
    color: var(--accent-gold);
}

.list-excerpt {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 32px;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    min-width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    font-family: var(--terminal-font);
    font-size: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 6px;
    transition: all 0.2s;
}

.pagination a:hover {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

.pagination .active {
    background: var(--accent-gold);
    border-color: var(--accent-gold);
    color: #000;
    font-weight: 600;
}

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

/* ========== Article Content ========== */
.article-content {
    font-size: 15px;
    line-height: 1.85;
    color: var(--text-secondary);
}

.article-content h2,
.article-content h3,
.article-content h4 {
    color: var(--text-primary);
    font-weight: 600;
    margin: 1.8em 0 0.8em;
    line-height: 1.3;
}

.article-content h2 {
    font-size: 1.5em;
    padding-bottom: 0.4em;
    border-bottom: 1px solid var(--border-color);
}

.article-content h3 {
    font-size: 1.25em;
}

.article-content p {
    margin-bottom: 1.2em;
}

.article-content a {
    color: var(--accent-gold);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.article-content a:hover {
    color: var(--accent-gold-hover);
}

.article-content ul,
.article-content ol {
    margin-bottom: 1.2em;
    padding-left: 1.5em;
}

.article-content li {
    margin-bottom: 0.5em;
}

.article-content img {
    max-width: 100%;
    border-radius: 8px;
    margin: 1.5em 0;
}

.article-content blockquote {
    border-left: 3px solid var(--accent-gold);
    padding: 1em 1.2em;
    background: var(--bg-tertiary);
    margin: 1.5em 0;
    color: var(--text-primary);
    font-style: italic;
}

.article-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
    font-size: 14px;
}

.article-content th,
.article-content td {
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    text-align: left;
}

.article-content th {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-weight: 600;
}

.article-content code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--terminal-font);
    font-size: 0.9em;
}

/* ========== Page Specific ========== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    color: var(--border-light);
}

.empty-state h3 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* ========== Responsive ========== */
@media (max-width: 1280px) {
    .terminal-widgets {
        display: none;
    }

    .terminal-main {
        margin-right: 0;
    }

    .terminal-footer {
        margin-right: 0;
    }

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

@media (max-width: 1024px) {
    .terminal-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        top: var(--mobile-header-height);
    }

    .terminal-sidebar.open {
        transform: translateX(0);
    }

    .terminal-layout {
        padding-top: var(--mobile-header-height);
    }

    .ticker-strip,
    .terminal-main,
    .terminal-footer {
        margin-left: 0;
    }

    .terminal-main {
        padding: 16px;
    }

    .mobile-header,
    .mobile-search-bar {
        display: flex;
    }

    .ticker-strip {
        position: relative;
        top: 0;
        display: none;
    }

    .list-thumb {
        width: 120px;
        height: 80px;
    }

    .list-title {
        font-size: 15px;
    }

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

@media (max-width: 640px) {
    .list-item {
        flex-direction: column;
        gap: 12px;
    }

    .list-thumb {
        width: 100%;
        height: auto;
        aspect-ratio: 16/9;
    }

    .section-title {
        font-size: 16px;
    }

    .card-title {
        font-size: 14px;
    }

    .grid-2,
    .grid-3,
    .grid-4,
    .prev-next-nav {
        grid-template-columns: 1fr;
    }

    .prev-next-nav .card,
    .prev-next-nav .card:only-child {
        grid-column: span 1;
        text-align: left !important;
    }

    .footer-inner {
        flex-direction: column;
        text-align: center;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* Selection */
::selection {
    background: var(--accent-gold);
    color: #000;
}

/* Focus */
a:focus-visible,
button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--accent-gold);
    outline-offset: 2px;
}