/* =========================================================
   TraderSite — โทนกรมท่า (ตลาดกลางคืน) + ทอง (XAUUSD)
   ตัวแปรทั้งหมดอยู่ที่ :root แก้ที่เดียวเปลี่ยนทั้งเว็บ
   ========================================================= */

:root {
    --navy: #10233D;
    --navy-2: #1B3557;
    --navy-ink: #E9EEF6;       /* ตัวอักษรบนพื้นกรมท่า */
    --navy-soft: #A9B8CC;
    --gold: #D9A931;
    --gold-ink: #7A5A0C;       /* ทองเข้มสำหรับตัวอักษรบนพื้นสว่าง */
    --gold-wash: #F7EED6;

    --paper: #F4F6F9;
    --surface: #FFFFFF;
    --ink: #16202D;
    --ink-soft: #5A6576;
    --rule: #DCE1E8;
    --accent: #10233D;         /* ปุ่มหลักบนพื้นสว่าง (หลังบ้านใช้ตัวแปรนี้ด้วย) */
    --accent-ink: #FFFFFF;
    --accent-wash: #E7ECF3;
    --link: #1B4B80;
    --up: #14805A;
    --down: #C23C35;

    --font: "Anuphan", "IBM Plex Sans Thai", "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif;
    --font-lo: "Noto Sans Lao", "Phetsarath OT", "Saysettha OT", "Lao UI", sans-serif;
    --measure: 40rem;
    --radius: 10px;
    --radius-sm: 6px;
    --gap: clamp(1rem, 3vw, 2rem);
    --shadow: 0 1px 2px rgba(16, 35, 61, .06), 0 4px 16px rgba(16, 35, 61, .06);
}

@media (prefers-color-scheme: dark) {
    :root {
        --navy: #0A1729;
        --navy-2: #15294A;
        --paper: #0F1B2C;
        --surface: #15243A;
        --ink: #E6EBF2;
        --ink-soft: #9CA9BB;
        --rule: #263852;
        --accent: #D9A931;
        --accent-ink: #10233D;
        --accent-wash: #1B2E4A;
        --link: #8FB8E8;
        --gold-ink: #E6BE5A;
        --gold-wash: #2A2614;
        --up: #46C08C;
        --down: #F07A6E;
        --shadow: none;
    }
}

/* หน้าภาษาลาวใช้ฟอนต์ลาว (Anuphan ไม่มีตัวอักษรลาว) */
html:lang(lo) { --font: var(--font-lo); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font);
    font-size: 1.0625rem;
    line-height: 1.75;          /* อักษรไทย/ลาวมีสระบน-ล่าง ต้องการระยะบรรทัดมาก */
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.35; margin: 0 0 .5em; font-weight: 600; letter-spacing: -.005em; }
h1 { font-size: clamp(1.75rem, 3.4vw, 2.4rem); }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: .22em; }
a:hover { text-decoration-color: var(--gold); text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 3px; }
img { max-width: 100%; height: auto; }

.wrap { width: min(72rem, 100% - 2 * var(--gap)); margin-inline: auto; }

.visually-hidden {
    position: absolute !important; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}
.skip-link { position: absolute; left: -999px; top: 0; background: var(--gold); color: var(--navy); padding: .5rem 1rem; z-index: 10; }
.skip-link:focus { left: 1rem; }

.muted, .empty { color: var(--ink-soft); }
.small { font-size: .88rem; }

/* ---------- ปุ่ม ---------- */

.button {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    min-height: 2.75rem;
    background: var(--accent); color: var(--accent-ink);
    border: 1px solid transparent; border-radius: 999px;
    padding: .5rem 1.35rem;
    font: inherit; font-weight: 600; line-height: 1.3;
    text-decoration: none; cursor: pointer;
}
.button:hover { filter: brightness(1.12); text-decoration: none; }
.button[disabled] { opacity: .6; cursor: progress; }
.button-gold { background: var(--gold); color: #10233D; }
.button-ghost { background: transparent; color: var(--navy-ink); border-color: rgba(233, 238, 246, .35); }
.button-ghost:hover { border-color: var(--gold); filter: none; }
.button-quiet { background: var(--surface); color: var(--ink); border-color: var(--rule); }
.button-quiet:hover { border-color: var(--ink-soft); filter: none; }
.button-wide { width: 100%; margin-top: .5rem; }

.link-button {
    background: none; border: 0; padding: 0; font: inherit; color: var(--ink-soft);
    cursor: pointer; text-decoration: underline; text-underline-offset: .2em;
}
.link-button:hover { color: var(--ink); }
.link-button.danger { color: var(--down); }
.link-button[disabled] { opacity: .6; cursor: progress; }

/* ---------- Header (พื้นกรมท่า ต่อเนื่องกับ hero) ---------- */

.site-header { background: var(--navy); color: var(--navy-ink); }

.header-inner {
    display: flex; align-items: center; flex-wrap: wrap; gap: .75rem 1.75rem;
    padding-block: .85rem;
}

.brand {
    display: inline-flex; align-items: center; gap: .55rem;
    color: var(--navy-ink); text-decoration: none; font-weight: 700; font-size: 1.2rem; letter-spacing: -.01em;
}
.brand:hover { text-decoration: none; color: #fff; }
.brand-mark { width: 1.6rem; height: 1.6rem; flex: none; }
.brand-mark rect { fill: var(--gold); }
.brand-mark path { stroke: var(--gold); stroke-width: 1.6; stroke-linecap: round; fill: none; }

.main-nav { display: flex; gap: .25rem; flex: 1; overflow-x: auto; scrollbar-width: none; }
.main-nav::-webkit-scrollbar { display: none; }
.main-nav a {
    color: var(--navy-soft); text-decoration: none; white-space: nowrap;
    padding: .35rem .75rem; border-radius: 999px;
}
.main-nav a:hover { color: #fff; background: var(--navy-2); }
.main-nav a.active { color: var(--navy); background: var(--gold); font-weight: 600; }

.site-search { width: min(13rem, 100%); }
.site-search input {
    width: 100%; font: inherit; font-size: .95rem;
    color: var(--navy-ink); background: var(--navy-2);
    border: 1px solid transparent; border-radius: 999px; padding: .4rem .95rem;
}
.site-search input::placeholder { color: var(--navy-soft); }
.site-search input:focus { border-color: var(--gold); outline: none; }

.account-links { display: flex; align-items: center; gap: .9rem; font-size: .95rem; }
.account-links form { margin: 0; }
.account-links a { color: var(--navy-ink); text-decoration: none; font-weight: 600; }
.account-links a:hover { color: var(--gold); }
.account-links .link-button { color: var(--navy-soft); }
.account-links .link-button:hover { color: #fff; }

.lang-switch { display: flex; padding: 2px; border-radius: 999px; background: var(--navy-2); }
.lang-switch a {
    color: var(--navy-soft); text-decoration: none; font-size: .88rem; line-height: 1.4;
    padding: .2rem .6rem; border-radius: 999px;
}
.lang-switch a:lang(lo), .lang-options a:lang(lo) { font-family: var(--font-lo); }
.lang-switch a:hover { color: #fff; }
.lang-switch a[aria-current="true"] { background: var(--navy-ink); color: var(--navy); font-weight: 600; }

.lang-options { list-style: none; padding: 0; display: flex; gap: .75rem; margin: 0 0 1.5rem; }

main { padding-block: var(--gap) calc(var(--gap) * 2.5); }

/* ---------- Hero หน้าแรก: พื้นกรมท่าเต็มความกว้าง + วันที่ตัวใหญ่สีทอง ---------- */

.hero {
    position: relative;
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem clamp(1.5rem, 5vw, 4rem);
    align-items: end;
    margin-top: calc(-1 * var(--gap) - 1px);
    margin-bottom: calc(var(--gap) * 1.75);
    padding-block: clamp(2rem, 6vw, 4rem) clamp(2rem, 5vw, 3.25rem);
    background: var(--navy); color: var(--navy-ink);
    /* ขยายพื้นหลังออกเต็มจอ โดยเนื้อหายังอยู่ในคอลัมน์ */
    box-shadow: 0 0 0 100vmax var(--navy);
    clip-path: inset(0 -100vmax);
}
.hero-body { max-width: 40rem; }
.hero-kind { color: var(--gold); font-weight: 600; margin-bottom: .6rem; }
.hero-kind time { color: var(--navy-soft); font-weight: 400; margin-left: .6rem; }
.hero h1 { font-size: clamp(1.9rem, 4.4vw, 3rem); line-height: 1.28; margin-bottom: .9rem; color: #fff; }
.hero h1 a { color: inherit; text-decoration: none; }
.hero h1 a:hover { text-decoration: underline; text-decoration-color: var(--gold); text-decoration-thickness: 3px; }
.hero-text { color: var(--navy-soft); font-size: 1.12rem; max-width: 36rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.5rem; }

.hero-date { display: grid; justify-items: end; line-height: 1; padding-bottom: .4rem; user-select: none; }
.hero-day {
    font-size: clamp(6rem, 17vw, 12rem); font-weight: 700; letter-spacing: -.05em;
    color: var(--gold); line-height: .8;
}
.hero-month { font-size: clamp(1.2rem, 2.6vw, 1.8rem); font-weight: 600; color: var(--navy-ink); margin-top: .6rem; }
.hero-today { font-size: .95rem; color: var(--navy-soft); margin-top: .35rem; }

/* ---------- หน้าแรก: คอลัมน์ ---------- */

.home-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: calc(var(--gap) * 1.75); align-items: start; }
.home-side { display: grid; gap: calc(var(--gap) * 1.25); }

.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .5rem; }
.section-head h2 { margin: 0; }
.section-head a { font-size: .95rem; white-space: nowrap; }
.side-title { font-size: 1.1rem; margin-bottom: .6rem; }

.empty-panel {
    margin: .5rem 0 0; padding: 1.5rem; text-align: center; color: var(--ink-soft);
    border: 1.5px dashed var(--rule); border-radius: var(--radius);
}

.topic-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.topic-list a {
    display: grid; gap: .1rem; padding: .75rem 1rem;
    background: var(--surface); border: 1px solid var(--rule); border-left: 4px solid var(--gold);
    border-radius: var(--radius-sm); text-decoration: none; color: var(--ink);
}
.topic-list a:hover { border-color: var(--gold); }
.topic-name { font-weight: 600; }
.topic-desc { font-size: .9rem; color: var(--ink-soft); line-height: 1.55; }

.promo { background: var(--navy); color: var(--navy-ink); border-radius: var(--radius); padding: 1.35rem 1.5rem 1.5rem; }
.promo h2 { font-size: 1.15rem; color: #fff; }
.promo p { color: var(--navy-soft); }
.promo-light { background: var(--gold-wash); color: var(--ink); }
.promo-light h2 { color: var(--ink); }
.promo-light p { color: var(--ink-soft); }

/* ---------- รายการบทความ ---------- */

.article-list { list-style: none; margin: 0; padding: 0; }

.article-row {
    display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: .25rem 1.25rem;
    padding-block: 1.1rem; border-bottom: 1px solid var(--rule);
}
.article-row:first-child { padding-top: .5rem; }
.article-row.has-thumb { grid-template-columns: 5.5rem minmax(0, 1fr) 9rem; }
.row-date { color: var(--ink-soft); font-size: .88rem; padding-top: .2rem; }
.row-title { color: var(--ink); font-weight: 600; font-size: 1.12rem; text-decoration: none; line-height: 1.5; }
.row-title:hover { text-decoration: underline; text-decoration-color: var(--gold); text-decoration-thickness: 2px; }
.row-excerpt { color: var(--ink-soft); margin: .3rem 0 0; max-width: var(--measure); line-height: 1.65; }
.row-meta { margin: .45rem 0 0; font-size: .88rem; display: flex; flex-wrap: wrap; gap: .4rem .9rem; align-items: center; }
.row-meta a { color: var(--ink-soft); }
.row-thumb { width: 9rem; aspect-ratio: 16 / 10; object-fit: cover; border-radius: var(--radius-sm); background: var(--accent-wash); }

.article-list.compact .article-row { grid-template-columns: 1fr; padding-block: .7rem; }
.article-list.compact .row-date { display: none; }
.article-list.compact .row-title { font-size: 1rem; font-weight: 500; }

.type {
    font-weight: 600; font-size: .8rem; padding: .05rem .55rem; border-radius: 999px;
    background: var(--accent-wash); color: var(--ink);
}
.type-market_recap { background: var(--gold-wash); color: var(--gold-ink); }
.type-knowledge { background: color-mix(in srgb, var(--up) 14%, transparent); color: var(--up); }
.type-review { color: var(--ink-soft); }

/* ---------- หัวหน้าเพจ ---------- */

.page-head { margin-bottom: calc(var(--gap) * 1.25); max-width: var(--measure); }
.page-intro { font-size: 1.12rem; color: var(--ink-soft); }
.crumbs { display: flex; flex-wrap: wrap; gap: .5rem; font-size: .92rem; color: var(--ink-soft); margin-bottom: .5rem; }
.crumbs a { color: var(--ink-soft); }

.subcats { list-style: none; padding: 0; margin: 1rem 0 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.subcats a {
    display: inline-block; padding: .3rem .9rem; border-radius: 999px; text-decoration: none;
    color: var(--ink); background: var(--surface); border: 1px solid var(--rule);
}
.subcats a:hover { border-color: var(--gold); }

.search-page-form { display: flex; gap: .5rem; margin-top: 1rem; }
.search-page-form input, .field input, .field textarea, .field select {
    font: inherit; color: var(--ink); background: var(--surface);
    border: 1px solid var(--rule); border-radius: var(--radius-sm);
    padding: .55rem .8rem; width: 100%;
}
.search-page-form input:focus, .field input:focus, .field textarea:focus, .field select:focus {
    border-color: var(--navy); outline: 2px solid color-mix(in srgb, var(--gold) 55%, transparent); outline-offset: 0;
}
.result-count { color: var(--ink-soft); }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.5rem; }
.pager-status { color: var(--ink-soft); }

.message-page { max-width: var(--measure); padding-block: 2rem; }

/* ---------- บทความ ---------- */

.article { max-width: var(--measure); }
.article-head { margin-bottom: 1.75rem; }
.article-head h1 { font-size: clamp(1.85rem, 4.2vw, 2.7rem); line-height: 1.3; }
.byline { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; color: var(--ink-soft); font-size: .95rem; }
.ai-note { font-size: .92rem; color: var(--ink-soft); background: var(--accent-wash); border-radius: var(--radius-sm); padding: .6rem .9rem; margin-top: 1rem; }
.cover { display: block; width: 100%; border-radius: var(--radius); margin-bottom: 1.75rem; }

.prose { font-size: 1.1rem; line-height: 1.85; }
.prose h2 { margin-top: 2.25rem; font-size: 1.45rem; }
.prose h3 { margin-top: 1.75rem; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li { margin-bottom: .4rem; }
.prose li::marker { color: var(--gold-ink); }
.prose blockquote { margin: 1.75rem 0; padding: .5rem 0 .5rem 1.1rem; border-left: 4px solid var(--gold); color: var(--ink-soft); }
.prose table {
    width: 100%; border-collapse: collapse; margin: 1.75rem 0; font-size: .98rem; line-height: 1.5;
    display: block; overflow-x: auto; background: var(--surface); border-radius: var(--radius-sm);
}
.prose th, .prose td { text-align: left; padding: .6rem .9rem; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.prose th { font-weight: 600; background: var(--accent-wash); }
.prose img { display: block; border-radius: var(--radius); margin: 1.75rem 0; }
.prose code { background: var(--accent-wash); padding: .1em .35em; border-radius: 4px; font-size: .92em; }

.sources { margin-top: 2.25rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
.sources h2 { font-size: 1.05rem; }
.sources ul { padding-left: 1.2rem; font-size: .95rem; }

.risk-note {
    margin-top: 2rem; padding: 1rem 1.25rem; max-width: var(--measure);
    background: var(--surface); border: 1px solid var(--rule); border-left: 4px solid var(--down);
    border-radius: var(--radius-sm); font-size: .93rem; color: var(--ink-soft);
}
.risk-note p { margin: 0; }

.related { margin-top: calc(var(--gap) * 2); max-width: var(--measure); }

/* ---------- โบรกเกอร์ ---------- */

.disclosure { font-size: .92rem; color: var(--ink-soft); background: var(--gold-wash); border-radius: var(--radius-sm); padding: .65rem .9rem; }

.broker-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 1.25rem; }
.broker { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.35rem 1.5rem; box-shadow: var(--shadow); }
.broker-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.1rem; }
.broker-head h2 { margin: 0; flex: 1; }
.broker-logo { border-radius: var(--radius-sm); object-fit: contain; background: #fff; border: 1px solid var(--rule); }
.broker-rating { margin: 0; color: var(--ink-soft); display: flex; align-items: baseline; gap: .2rem; }
.broker-rating strong { font-size: 1.7rem; color: var(--gold-ink); }

.broker-facts {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: .9rem 1.5rem;
    margin: 0 0 1.1rem; padding: 1rem 1.1rem; background: var(--paper); border-radius: var(--radius-sm);
}
.broker-facts dt { font-size: .85rem; color: var(--ink-soft); }
.broker-facts dd { margin: 0; font-weight: 600; }

.broker-proscons { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem 2rem; margin-bottom: 1.1rem; }
.broker-proscons h3 { margin-bottom: .25rem; }
.broker-proscons div:first-child h3 { color: var(--up); }
.broker-proscons div:nth-child(2) h3 { color: var(--gold-ink); }
.broker-proscons p { color: var(--ink-soft); margin: 0; white-space: pre-line; }

.broker-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.5rem; }

/* ---------- เครื่องคำนวณ Lot ---------- */

.calc { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: calc(var(--gap) * 1.5); align-items: start; margin-bottom: calc(var(--gap) * 1.5); }
.calc-inputs { display: grid; gap: 1.25rem; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.5rem; }
.field label, .field .label { display: block; font-weight: 600; margin-bottom: .35rem; }
.calc-inputs .field input { font-size: 1.2rem; font-weight: 600; max-width: 16rem; }
.hint { font-size: .9rem; color: var(--ink-soft); margin: .4rem 0 0; line-height: 1.6; }

.calc-result {
    position: sticky; top: 1rem;
    background: var(--navy); color: var(--navy-ink); border-radius: var(--radius); padding: 1.75rem;
}
.calc-label { margin: 0; color: var(--navy-soft); }
.calc-lots { font-size: clamp(3.5rem, 9vw, 5.5rem); font-weight: 700; line-height: 1; color: var(--gold); margin: .35rem 0 1.25rem; letter-spacing: -.03em; }
.calc-breakdown { margin: 0 0 1rem; }
.calc-breakdown div { display: flex; justify-content: space-between; gap: 1rem; padding-block: .5rem; border-bottom: 1px solid rgba(233, 238, 246, .14); }
.calc-breakdown dt { color: var(--navy-soft); }
.calc-breakdown dd { margin: 0; font-weight: 600; }
.calc-result .hint { color: var(--navy-soft); }
.calc-error { color: #FFB4AC; font-weight: 600; margin: 0; }
.calc-explain { max-width: var(--measure); }

/* ---------- บัญชีสมาชิก ---------- */

.auth-card {
    max-width: 27rem; margin: 2rem auto; padding: 2rem;
    background: var(--surface); border: 1px solid var(--rule); border-top: 4px solid var(--gold);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.auth-card .field { margin-bottom: 1rem; }
.auth-switch { margin: 1.25rem 0 0; color: var(--ink-soft); }

.form-error {
    background: color-mix(in srgb, var(--down) 9%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--down) 45%, transparent); border-radius: var(--radius-sm);
    padding: .75rem 1rem; margin-bottom: 1rem;
}
.form-error ul { margin: 0; padding-left: 1.2rem; }
.notice-ok {
    background: color-mix(in srgb, var(--up) 10%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--up) 45%, transparent); border-radius: var(--radius-sm); padding: .65rem 1rem;
}

/* ---------- บันทึกเทรด ---------- */

.pos { color: var(--up); }
.neg { color: var(--down); }

.journal-head { display: flex; justify-content: space-between; align-items: start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.journal-head h1 { margin-bottom: .2rem; }
.journal-actions { display: flex; flex-wrap: wrap; gap: .75rem; }
.journal-section { margin-bottom: calc(var(--gap) * 1.5); }

.stat-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
    gap: 1px; margin: 0; background: var(--rule);
    border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden;
}
.stat { background: var(--surface); padding: .95rem 1.1rem; }
.stat dt { font-size: .88rem; color: var(--ink-soft); }
.stat dd { margin: .15rem 0 0; font-size: 1.35rem; font-weight: 700; }
.stat-main { grid-column: span 2; background: var(--navy); }
.stat-main dt { color: var(--navy-soft); }
.stat-main dd { font-size: 2.3rem; line-height: 1.2; }
.stat-main dd.pos { color: #5FD3A0; }
.stat-main dd.neg { color: #FF958A; }
.stat-main dd:not(.pos):not(.neg) { color: #fff; }

.equity-chart {
    display: block; width: 100%; height: 14rem;
    background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
}
.equity-zero { stroke: var(--rule); stroke-width: 1; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.equity-line { fill: none; stroke-width: 2.5; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.equity-line.pos { stroke: var(--up); }
.equity-line.neg { stroke: var(--down); }
.equity-axis { display: flex; justify-content: space-between; font-size: .85rem; color: var(--ink-soft); margin-top: .3rem; }

.journal-breakdowns { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 1.5rem; margin-bottom: calc(var(--gap) * 1.5); }
.journal-breakdowns h2 { font-size: 1.1rem; }

.table-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); }
.journal-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.journal-table th, .journal-table td { text-align: left; padding: .65rem .9rem; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.journal-table th { font-weight: 600; color: var(--ink-soft); font-size: .86rem; background: var(--paper); }
.journal-table tr:last-child td { border-bottom: 0; }
.journal-table .num { text-align: right; }
.journal-table.compact td, .journal-table.compact th { padding: .45rem .75rem; }
.side { font-weight: 600; }
.side-buy { color: var(--up); }
.side-sell { color: var(--down); }
.badge-sync {
    display: inline-block; margin-left: .4rem; padding: 0 .45rem; border-radius: 999px;
    font-size: .74rem; font-weight: 600; background: var(--gold-wash); color: var(--gold-ink);
}

.trade-form { max-width: 48rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 0 1.25rem; }
.trade-form .field { margin-bottom: 1rem; }
.form-note { margin: .5rem 0 1rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
.form-actions { display: flex; align-items: center; gap: 1.5rem; margin-top: 1.5rem; }
.plain-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.plain-fieldset[disabled] input { opacity: .7; }

.segmented { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; overflow: hidden; background: var(--surface); }
.segmented button { font: inherit; font-weight: 600; border: 0; padding: .45rem 1.4rem; background: transparent; color: var(--ink-soft); cursor: pointer; }
.segmented .side-buy[aria-checked="true"] { background: var(--up); color: #fff; }
.segmented .side-sell[aria-checked="true"] { background: var(--down); color: #fff; }

.trade-form .select { width: 100%; }
.checkbox-row { display: flex; align-items: flex-start; gap: .6rem; }
.checkbox-row input { margin-top: .45rem; width: 1.05rem; height: 1.05rem; flex: none; accent-color: var(--navy); }
.checkbox-row label { font-weight: 500; }

/* ---------- เชื่อมบัญชีเทรด ---------- */

.account-list { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .75rem; }
.account-card {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .5rem 1.5rem; align-items: center;
    background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1rem 1.25rem;
}
.account-name { margin: 0; font-weight: 700; }
.account-main p { margin: 0; }
.account-status { display: grid; justify-items: end; gap: .1rem; text-align: right; }
.account-hint { grid-column: 1 / -1; margin: 0; font-size: .92rem; color: var(--ink-soft); }
.account-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem; }
.sync-status { font-weight: 600; }
.sync-active { color: var(--up); }
.sync-pending, .sync-syncing { color: var(--gold-ink); }
.sync-error, .sync-auth_failed { color: var(--down); }

.sync-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: calc(var(--gap) * 1.5); align-items: start; }
.sync-help { display: grid; gap: 1.25rem; }
.sync-help h2 { font-size: 1.05rem; }
.sync-help ol { padding-left: 1.2rem; margin: 0 0 .5rem; }
.sync-help li { margin-bottom: .4rem; }
.security-note { background: var(--navy); color: var(--navy-ink); border-radius: var(--radius); padding: 1.1rem 1.35rem; }
.security-note h2 { color: var(--gold); }
.security-note p { margin: 0; color: var(--navy-soft); }

/* ---------- Footer ---------- */

.site-footer { background: var(--navy); color: var(--navy-soft); font-size: .92rem; }
.footer-inner {
    display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .8fr) minmax(0, 1.6fr); gap: 1.5rem 3rem;
    padding-block: 2.5rem;
}
.footer-brand { font-weight: 700; color: var(--navy-ink); font-size: 1.05rem; margin-bottom: .35rem; }
.footer-nav { display: grid; gap: .35rem; align-content: start; }
.footer-nav a { color: var(--navy-ink); text-decoration: none; }
.footer-nav a:hover { color: var(--gold); }
.footer-legal p { line-height: 1.65; }
.footer-copy { margin: 0; }

/* ---------- Blazor error bar ---------- */

#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; width: 100%; z-index: 1000;
    background: var(--down); color: #fff; padding: .75rem 1.25rem;
}
#blazor-error-ui a { color: #fff; margin-left: 1rem; }
#blazor-error-ui .dismiss { position: absolute; right: 1rem; top: .75rem; }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
    .home-grid, .calc, .sync-grid { grid-template-columns: 1fr; }
    .calc-result { position: static; }
    .footer-inner { grid-template-columns: 1fr 1fr; }
    .footer-legal { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
    .header-inner { gap: .6rem 1rem; }
    .brand { flex: 1; }
    .main-nav { order: 3; flex: 0 0 calc(100% + 1.5rem); margin-inline: -.75rem; padding-inline: .75rem; }
    .site-search { order: 4; flex: 1; width: auto; min-width: 0; }
    .lang-switch { order: 5; }
    .hero { grid-template-columns: 1fr; }
    .hero-date { grid-row: 1; display: flex; align-items: baseline; gap: .6rem; padding: 0; }
    .hero-day { font-size: 4.25rem; line-height: 1; }
    .hero-month, .hero-today { margin: 0; }
    .lang-switch a { padding: .15rem .45rem; font-size: .8rem; }
    .account-links { font-size: .9rem; }
    .article-row.has-thumb { grid-template-columns: 5.5rem minmax(0, 1fr); }
    .row-thumb { display: none; }
    .account-card { grid-template-columns: 1fr; }
    .account-status { justify-items: start; text-align: left; }
}

@media (max-width: 520px) {
    .article-row, .article-row.has-thumb { grid-template-columns: 1fr; gap: .15rem; }
    .search-page-form { flex-direction: column; }
    .stat-main { grid-column: span 1; }
    .footer-inner { grid-template-columns: 1fr; }
    .hero-actions .button { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
    * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
