/* ========================================
   IdeaBoxi — Global Styles
   ======================================== */

:root {
    /* ===== Color Tokens — Soft Premium AI Workspace ===== */
    --bg: #F6F9FF;
    --bg-soft: #EEF5FF;
    --surface: #FFFFFF;
    --surface-2: #F8FAFD;
    --border: #E2E8F0;
    --border-soft: #EDF2F8;

    --text: #0F172A;
    --text-secondary: #475569;
    --text-tertiary: #94A3B8;
    --text-muted: #64748B;

    --primary: #183B75;          /* navy — buttons, brand */
    --primary-hover: #122E5C;
    --primary-text: #FFFFFF;
    --accent-blue: #2563EB;      /* bright blue for active/links */
    --accent-blue-soft: #DBE7FD;

    --pink: #EC4899;
    --pink-soft: #FCE7F3;

    --success: #10B981;
    --success-soft: #D1FAE5;
    --warning: #F59E0B;
    --warning-soft: #FEF3C7;
    --danger: #EF4444;
    --danger-soft: #FEE2E2;

    /* legacy aliases (รักษาความเข้ากันได้กับโค้ดเก่า) */
    --pink-light: var(--pink-soft);
    --sky: var(--accent-blue-soft);

    /* ===== Radius ===== */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-pill: 999px;

    /* ===== Shadow ===== */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-sm: 0 2px 6px rgba(15, 23, 42, .05);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, .07);
    --shadow-lg: 0 16px 48px rgba(15, 23, 42, .10);

    /* ===== Layout ===== */
    --sidebar-w: 240px;
    --utility-h: 64px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Sarabun', 'Prompt', 'Inter', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    line-height: 1.55;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   APP LAYOUT — Sidebar + Main (Modern SaaS)
   ======================================== */
.app-layout {
    display: flex;
    min-height: 100vh;
    background: var(--bg);
}

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    margin-left: var(--sidebar-w);
}

.app-content {
    flex: 1;
    padding: 24px 32px 40px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

/* ========================================
   SIDEBAR
   ======================================== */
.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border-soft);
    display: flex;
    flex-direction: column;
    z-index: 50;
}

.sb-brand {
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--border-soft);
}
.sb-brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
}
.sb-brand-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent-blue) 100%);
    color: #fff;
    font-weight: 700;
    font-style: italic;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(37, 99, 235, .25);
}
.sb-brand-name {
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -.01em;
}

.sb-nav {
    flex: 1;
    overflow-y: auto;
    padding: 10px 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.sb-nav::-webkit-scrollbar { width: 6px; }
.sb-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.sb-nav-group {
    padding: 4px 0 8px;
}
.sb-nav-group + .sb-nav-group {
    margin-top: 4px;
    border-top: 1px solid var(--border-soft);
    padding-top: 10px;
}
/* sb-manage อยู่นอก nav — ติดล่างสุดของ sidebar */
/* (CSS หลักอยู่ใกล้กับ .sb-collapse-btn แล้ว) */
.sb-group-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-tertiary);
    padding: 0 10px 6px;
}
.sb-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: background .12s, color .12s;
}
.sb-link:hover {
    background: var(--bg-soft);
    color: var(--text);
}
.sb-link.is-active {
    background: var(--accent-blue-soft);
    color: var(--primary);
    font-weight: 600;
}
.sb-link-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}
.sb-link-icon svg {
    width: 18px;
    height: 18px;
}
.sb-link-meta {
    font-size: 10px;
    font-weight: 400;
    color: var(--text-tertiary);
    margin-left: 2px;
}

/* ปุ่ม collapse sidebar */
.sb-brand {
    display: flex;
    align-items: center;
}
.sb-collapse-btn {
    display: none; /* แสดงเฉพาะ desktop ≥961px */
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background .12s, color .12s;
    margin-left: auto;
    padding: 0;
}
.sb-collapse-btn:hover {
    background: var(--bg-soft);
    color: var(--text);
}
/* ไอคอนหมุน 180° เมื่อ collapsed (chevron-left → chevron-right) */
body.sb-collapsed .sb-collapse-btn svg {
    transform: rotate(180deg);
}

/* Manage section — ติดล่างสุด ออกนอก nav */
.sb-manage {
    flex-shrink: 0;
    border-top: 1px solid var(--border-soft);
    padding: 8px 10px;
}
.sb-manage .sb-group-label {
    padding: 4px 8px 6px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

.sb-storage {
    margin: 8px 12px;
    padding: 12px 14px;
    background: linear-gradient(135deg, var(--bg-soft) 0%, #F0F5FE 100%);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
}
.sb-storage-head {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}
.sb-storage-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.sb-storage-num {
    font-size: 13px;
    color: var(--text);
    margin-bottom: 8px;
}
.sb-storage-num strong { font-weight: 700; }
.sb-storage-of { color: var(--text-tertiary); }
.sb-storage-bar {
    width: 100%;
    height: 6px;
    background: rgba(15, 23, 42, .06);
    border-radius: 3px;
    overflow: hidden;
}
.sb-storage-fill {
    height: 100%;
    border-radius: 3px;
    transition: width .3s;
}
.sb-storage-pct {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
    margin-bottom: 8px;
}
.sb-storage-btn {
    display: block;
    text-align: center;
    text-decoration: none;
    background: var(--surface);
    color: var(--primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    transition: border-color .12s, color .12s;
}
.sb-storage-btn:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.sb-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-top: 1px solid var(--border-soft);
}
.sb-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue) 0%, var(--pink) 100%);
    color: #fff;
    font-weight: 700;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}
.sb-user-info {
    flex: 1;
    min-width: 0;
}
.sb-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sb-user-email {
    font-size: 11px;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sb-user-logout {
    color: var(--text-tertiary);
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    transition: background .12s, color .12s;
}
.sb-user-logout:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

.app-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .35);
    z-index: 49;
    opacity: 0;
    transition: opacity .2s;
}
.app-sidebar-backdrop.is-open {
    display: block;
    opacity: 1;
}

/* ========================================
   UTILITY BAR (Top of main content)
   ======================================== */
.util-bar {
    height: var(--utility-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border-soft);
    padding: 0 32px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 40;
}
.util-mobile-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--text);
    border-radius: var(--radius-sm);
}
.util-mobile-toggle:hover { background: var(--bg-soft); }

.util-search {
    flex: 1;
    max-width: 480px;
    position: relative;
}
.util-search input {
    width: 100%;
    height: 38px;
    padding: 0 14px 0 38px;
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    font-size: 13.5px;
    color: var(--text);
    transition: border-color .12s, background .12s;
}
.util-search input:focus {
    outline: none;
    border-color: var(--accent-blue);
    background: var(--surface);
}
.util-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
    display: flex;
}
.util-search-icon svg { width: 16px; height: 16px; }
.util-search-kbd {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: var(--text-tertiary);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 6px;
    pointer-events: none;
}

.util-spacer { flex: 1; }

.util-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.util-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .12s, color .12s, border-color .12s;
    position: relative;
    text-decoration: none;
}
.util-icon-btn:hover {
    background: var(--accent-blue-soft);
    color: var(--accent-blue);
    border-color: transparent;
}
.util-icon-btn svg { width: 18px; height: 18px; }
.util-icon-btn .badge-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 7px;
    height: 7px;
    background: var(--pink);
    border-radius: 50%;
    border: 2px solid var(--surface);
}

/* ========================================
   PAGE HEADER
   ======================================== */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.page-title {
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 4px;
    letter-spacing: -.01em;
}
.page-subtitle {
    font-size: 13.5px;
    color: var(--text-muted);
    margin: 0;
}
.page-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* Toolbar ใน page header (แทน util-bar สำหรับ projects.php) */
.page-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: nowrap; /* ป้องกัน wrap */
}
/* ปุ่มใน toolbar ห้าม wrap ข้อความ */
.page-toolbar .btn {
    white-space: nowrap;
    flex-shrink: 0;
}
/* select ใน toolbar: กำหนด width ชัดเจน */
.page-toolbar select.form-control {
    width: auto;
    flex-shrink: 0;
}
.page-search {
    position: relative;
    display: flex;
    align-items: center;
}
.page-search-icon {
    position: absolute;
    left: 10px;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    pointer-events: none;
}
.page-search-icon svg { width: 15px; height: 15px; }
.page-search input {
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    height: 36px;
    padding: 0 12px 0 34px;
    font-size: 13px;
    color: var(--text);
    width: 180px;
    transition: border-color .15s, width .2s;
    outline: none;
    position: relative;
    z-index: 1;
    pointer-events: auto;
}
.page-search input:focus {
    border-color: var(--accent-blue);
    width: 240px;
}
.page-search input::placeholder { color: var(--text-tertiary); }
.page-icon-btn {
    width: 36px;
    height: 36px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color .12s, color .12s, background .12s;
    flex-shrink: 0;
}
.page-icon-btn:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    background: var(--accent-blue-soft);
}

/* ========================================
   CSS Clouds
   ======================================== */

/* cloud shape base */
.cloud {
    position: absolute;
    background: rgba(255, 255, 255, 0.82);
    border-radius: 60px;
    pointer-events: none;
    filter: blur(0.5px);
}
.cloud::before,
.cloud::after {
    content: '';
    position: absolute;
    background: rgba(255, 255, 255, 0.82);
    border-radius: 50%;
}

/* cloud sizes */
.cloud-lg { width: 160px; height: 44px; }
.cloud-lg::before { width: 70px; height: 70px; top: -38px; left: 25px; }
.cloud-lg::after  { width: 50px; height: 50px; top: -26px; right: 28px; }

.cloud-md { width: 110px; height: 32px; }
.cloud-md::before { width: 50px; height: 50px; top: -28px; left: 18px; }
.cloud-md::after  { width: 36px; height: 36px; top: -18px; right: 20px; }

.cloud-sm { width: 72px; height: 22px; }
.cloud-sm::before { width: 32px; height: 32px; top: -18px; left: 12px; }
.cloud-sm::after  { width: 24px; height: 24px; top: -12px; right: 12px; }

/* float animation */
@keyframes cloudFloat {
    0%   { transform: translateX(0); }
    50%  { transform: translateX(12px); }
    100% { transform: translateX(0); }
}
@keyframes cloudFloat2 {
    0%   { transform: translateX(0); }
    50%  { transform: translateX(-10px); }
    100% { transform: translateX(0); }
}
.cloud-float  { animation: cloudFloat  8s ease-in-out infinite; }
.cloud-float2 { animation: cloudFloat2 11s ease-in-out infinite; }
.cloud-float3 { animation: cloudFloat  14s ease-in-out infinite; }

/* ========================================
   Auth Pages (Login / Register)
   ======================================== */

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(800px 600px at 15% 25%, rgba(96, 165, 250, .18), transparent 60%),
        radial-gradient(700px 500px at 85% 75%, rgba(236, 72, 153, .14), transparent 60%),
        radial-gradient(900px 600px at 50% 100%, rgba(167, 139, 250, .14), transparent 60%),
        linear-gradient(165deg, #F0F6FF 0%, #FFFFFF 50%, #FAF5FF 100%);
}

.auth-card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-soft);
    padding: 40px 36px;
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 2;
}

.auth-logo {
    text-align: center;
    margin-bottom: 28px;
}

.auth-logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent-blue) 100%);
    color: #fff;
    font-style: italic;
    font-weight: 700;
    font-size: 30px;
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 24px rgba(37, 99, 235, .25);
    font-size: 24px;
    margin-bottom: 12px;
}

.auth-card h1 {
    font-size: 22px;
    margin: 0 0 4px;
    text-align: center;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: border-color .15s, box-shadow .15s, background .15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.form-control::placeholder { color: var(--text-tertiary); }

.form-hint {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
    font-family: inherit;
    text-decoration: none;
    text-align: center;
    color: var(--text);
    background: var(--surface);
}

.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 2px 6px rgba(24, 59, 117, .18);
}
.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(24, 59, 117, .28);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12.5px;
    border-radius: var(--radius-sm);
}

.alert {
    padding: 11px 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.alert-danger {
    background: var(--danger-soft);
    color: #7F1D1D;
    border-color: rgba(239, 68, 68, .25);
}

.alert-success {
    background: var(--success-soft);
    color: #064E3B;
    border-color: rgba(16, 185, 129, .25);
}

.auth-footer {
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
    padding-top: 16px;
    margin-top: 16px;
    border-top: 1px solid var(--border);
}

.auth-footer a,
.link {
    color: var(--primary);
    text-decoration: none;
}

.auth-footer a:hover,
.link:hover {
    text-decoration: underline;
}

.text-right {
    text-align: right;
}

.text-error {
    color: var(--danger);
}

/* ========================================
   Forgot password link
   ======================================== */

.forgot-password {
    text-align: right;
    margin-top: -8px;
    margin-bottom: 16px;
}

.forgot-password a {
    font-size: 12px;
    color: var(--primary);
    text-decoration: none;
}

/* ========================================
   Navbar (LEGACY — ซ่อนเพราะใช้ sidebar แทน)
   ======================================== */
.navbar, .navbar-mobile-menu { display: none !important; }

/* ========================================
   Navbar (เก็บไว้ใน HTML แต่ไม่แสดง)
   ======================================== */

.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    padding: 0 24px;
    height: 56px;
    background: #EBF3FF;
    border-bottom: 1px solid var(--border);
}

/* 3 โซน: brand flex:1 ซ้าย | center absolute กลาง | user flex:1 ขวา */
.navbar-brand { flex: 1; }
.navbar-user  { flex: 1; display: flex; align-items: center; justify-content: flex-end; gap: 8px; }

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-brand-link {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: inherit;
}
.navbar-brand-link:hover .navbar-title {
    color: var(--primary);
}

.navbar-logo {
    font-size: 20px;
}

.navbar-title {
    font-weight: 700;
    font-size: 16px;
    color: var(--text);
    letter-spacing: -0.3px;
}

/* navbar-user กำหนดใน block ข้างบนแล้ว */

.navbar-username {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Storage indicator ใน navbar */
/* Help button */
.help-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 50%;
    font-weight: 700;
    font-size: 14px;
    border: 1.5px solid var(--border);
    color: var(--text-secondary);
    line-height: 1;
}
.help-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Help Modal */
.help-modal-box {
    max-width: 420px;
}
.help-section {
    margin-bottom: 16px;
}
.help-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-tertiary);
    margin: 0 0 8px;
}
.help-badge-new {
    display: inline-block;
    background: #fef3c7;
    color: #b45309;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    margin-bottom: 8px;
}
.help-highlight {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: var(--bg-secondary);
    border: 1.5px solid var(--primary);
    border-radius: 8px;
    padding: 10px 14px;
}
.help-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 0;
    border-bottom: 1px solid var(--border);
}
.help-row:last-child { border-bottom: none; }
.help-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    border: 1.5px solid var(--border);
    border-bottom-width: 3px;
    border-radius: 5px;
    padding: 1px 7px;
    font-size: 12px;
    font-weight: 600;
    font-family: monospace;
    color: var(--text-primary);
    white-space: nowrap;
    box-shadow: 0 1px 0 var(--border);
}
.help-desc {
    font-size: 13px;
    color: var(--text-secondary);
    flex: 1;
}
.help-desc small {
    font-size: 11px;
    color: var(--text-tertiary);
}
.help-tip {
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.storage-indicator {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    cursor: default;
}

.storage-label {
    font-size: 11px;
    color: var(--text-tertiary);
    white-space: nowrap;
}

.storage-bar {
    width: 80px;
    height: 3px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
}

.storage-bar-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.3s;
}

/* ========================================
   Buttons เพิ่มเติม
   ======================================== */

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-ghost {
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    font-weight: 500;
}

.btn-ghost:hover {
    background: var(--bg-soft);
    color: var(--text);
    border-color: var(--border);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.btn-danger:hover {
    background: #DC2626;
    border-color: #DC2626;
}

.btn-danger:hover {
    background: #c43b3a;
}

/* ========================================
   Dashboard Layout
   ======================================== */

.main-content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 24px;
}

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

.dashboard-title {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
}

.search-bar {
    margin-bottom: 24px;
}

.search-bar .form-control {
    max-width: 360px;
    background: var(--surface);
}

/* Search + Filter แถวเดียวกัน */
.search-filter-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.search-input {
    flex: 0 0 320px;
    background: var(--surface);
    height: 40px;
}

/* ========================================
   Project Grid & Cards
   ======================================== */

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 18px;
    align-items: stretch;
}

.project-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-soft);
    border-left: 4px solid transparent;
    padding: 18px 20px;
    cursor: pointer;
    transition: box-shadow .18s, transform .12s, border-color .15s, background .12s;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: var(--shadow-xs);
    position: relative;
}

.project-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    background: linear-gradient(160deg, #FAFCFF 0%, var(--surface) 100%);
    border-color: var(--border);
}

.card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 28px;
}

.card-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: .01em;
}

.badge-status {
    background: var(--accent-blue-soft);
    color: var(--primary);
}

.badge-pin {
    background: var(--warning-soft);
    color: var(--warning);
    font-size: 12px;
    padding: 3px 8px;
}

/* Status badge variants */
.badge-status-idea     { background: #EDE9FE; color: #5B21B6; }
.badge-status-active   { background: var(--accent-blue-soft); color: var(--primary); }
.badge-status-done     { background: var(--success-soft); color: #065F46; }
.badge-status-archived { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }

.card-actions {
    opacity: 0;
    transition: opacity 0.15s;
}

.project-card:hover .card-actions {
    opacity: 1;
}

/* ปุ่ม three-dots บนการ์ด */
.btn-card-menu {
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    transition: background .12s, border-color .12s, color .12s;
    padding: 0;
}
.btn-card-menu:hover {
    background: var(--bg-soft);
    border-color: var(--border);
    color: var(--text);
}

/* card footer separator */
.card-sep {
    color: var(--text-tertiary);
    font-size: 11px;
}

/* Card Context Menu — body-level, position: fixed */
.card-ctx-menu {
    display: none;
    position: fixed;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.14);
    z-index: 9999;
    min-width: 148px;
    overflow: hidden;
}

.card-ctx-menu.open {
    display: block;
}

.card-dd-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 9px 14px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    transition: background 0.1s;
}

.card-dd-item:hover {
    background: var(--bg);
}

.card-dd-delete {
    color: var(--danger);
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1;
    transition: background 0.1s;
}

.icon-btn:hover {
    background: var(--bg);
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    color: var(--text);
    line-height: 1.4;
    word-break: break-word;
}

.card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.5;
    flex: 1;
}

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

.priority-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.priority-label {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
}

.card-date {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-left: auto;
}

/* ========================================
   Empty State
   ======================================== */

.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state h2 {
    font-size: 18px;
    margin: 0 0 8px;
    color: var(--text);
}

.empty-state p {
    margin: 0 0 24px;
    font-size: 14px;
}

/* ========================================
   Modal
   ======================================== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
    animation: fadeIn .15s ease-out;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

.modal-box {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 28px;
    width: 100%;
    max-width: 520px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-soft);
    animation: slideUp .2s ease-out;
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.modal-sm { max-width: 400px; }

.modal-md {
    max-width: 560px;
}

.modal-lg {
    max-width: 820px;
}

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

.modal-header h2 {
    font-size: 17px;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.modal-close:hover {
    background: var(--bg);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.required {
    color: var(--danger);
}

/* ========================================
   Toast
   ======================================== */

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--text);
    color: #fff;
    padding: 10px 20px;
    border-radius: 99px;
    font-size: 13px;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
    z-index: 300;
    white-space: nowrap;
}

.toast-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-error {
    background: var(--danger);
}

/* ========================================
   Editor Page Layout
   ======================================== */

body.editor-page {
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

body.editor-page .navbar {
    flex-shrink: 0;
}

.navbar-sep {
    color: var(--text-tertiary);
    margin: 0 2px;
    font-size: 13px;
}

.navbar-project-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ชื่อ section ใน breadcrumb ของ editor page */
.navbar-section-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--primary);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    border: 1px solid transparent;
    transition: border-color 0.15s, background 0.15s;
}

.navbar-section-name:hover {
    border-color: var(--border);
    background: var(--bg);
}

.navbar-section-input {
    font-size: 13px;
    font-weight: 500;
    color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: 4px;
    padding: 2px 6px;
    outline: none;
    width: 180px;
    background: var(--surface);
}

/* ========================================
   Project Breadcrumb Strip (ใต้ navbar ใน editor page)
   ======================================== */
.project-breadcrumb {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0 16px;
    height: 48px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-soft);
    font-size: 13px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 40;
    box-shadow: var(--shadow-xs);
}
.breadcrumb-home { display: none; } /* เอาออกแล้ว */
.breadcrumb-sep {
    display: inline-flex;
    align-items: center;
    color: var(--text-tertiary);
    flex-shrink: 0;
    opacity: 0.5;
}
/* ชื่อโปรเจค — outline pill */
.breadcrumb-project {
    font-weight: 600;
    color: var(--text);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12.5px;
    padding: 3px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface);
    line-height: 1.4;
    flex-shrink: 0;
}
/* ชื่อหัวข้อ — text pill เรียบ, คลิกได้ */
.breadcrumb-section {
    font-size: 12.5px;
    color: var(--text-secondary);
    font-weight: 500;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    padding: 3px 8px;
    border-radius: var(--radius-pill);
    border: 1px solid transparent;
    transition: border-color .12s, background .12s, color .12s;
}
.breadcrumb-section:hover {
    border-color: var(--border);
    background: var(--bg-soft);
    color: var(--text);
}
.breadcrumb-export {
    margin-left: auto;
    font-size: 11.5px;
    color: var(--text-secondary);
    opacity: 0.7;
    transition: opacity .12s, color .12s;
}
.breadcrumb-export:hover { opacity: 1; color: var(--primary); }
.breadcrumb-del {
    opacity: 0.5;
    transition: opacity .12s, color .12s;
}
.breadcrumb-del:hover { opacity: 1; color: var(--danger); }
.breadcrumb-help {
    opacity: 0.7;
    transition: opacity .12s;
    position: relative;
    z-index: 1;
    pointer-events: auto;
}
.breadcrumb-help:hover { opacity: 1; }
.breadcrumb-section-input {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: var(--radius-pill);
    padding: 0 10px;
    outline: none;
    width: 180px;
    height: 26px;           /* ล็อคความสูง — ไม่ดัน breadcrumb ขึ้น */
    line-height: 26px;
    background: var(--surface);
    box-sizing: border-box;
}

/* ไอคอนบ้าน */
.navbar-home {
    font-size: 18px;
    text-decoration: none;
    line-height: 1;
    transition: opacity 0.15s;
}

.navbar-home:hover {
    opacity: 0.7;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.back-link {
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
}

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

.tab-bar-spacer {
    flex: 1; /* ดัน save indicator + ปุ่มไปชิดขวา */
}
.save-indicator {
    font-size: 12px;
    color: var(--text-tertiary);
    align-self: center;
    white-space: nowrap;
    padding-right: 6px;
}

.save-indicator.saving { color: var(--warning); }
.save-indicator.saved  { color: var(--success); }
.save-indicator.error  { color: var(--danger); }

/* Editor layout: sidebar + main */
.editor-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ===== Sidebar (section list) ===== */
.editor-sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border-soft);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-soft);
    position: sticky;
    top: 0;
    background: var(--surface-2);
    z-index: 1;
}

.sidebar-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: .06em;
}

.sidebar-empty {
    font-size: 13px;
    color: var(--text-tertiary);
    padding: 24px 16px;
    text-align: center;
}

/* (เดิม: เมฆ decorative — ลบออกเพื่อเป็น modern workspace) */

.section-list {
    list-style: none;
    margin: 0;
    padding: 6px 0;
}

.section-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px 8px 16px;
    cursor: pointer;
    border-radius: 0;
    transition: background 0.1s;
    gap: 6px;
}

.section-item:hover {
    background: var(--bg-soft);
}

.section-item.active {
    background: var(--accent-blue-soft);
    border-right: 3px solid var(--accent-blue);
}

.section-item-title {
    font-size: 13px;
    color: var(--text);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.section-item.active .section-item-title {
    color: var(--primary);
    font-weight: 500;
}

.section-item-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.1s;
    flex-shrink: 0;
}

.section-item:hover .section-item-actions {
    opacity: 1;
}

/* ===== Editor Main ===== */
.editor-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
}

.editor-titlebar {
    padding: 10px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.editor-section-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    color: var(--text);
    flex: 1;
}

/* ปุ่ม "+ Tab" บน titlebar */
.btn-add-tab {
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--primary);
    background: rgba(74, 108, 247, 0.08);
    border: 1px solid rgba(74, 108, 247, 0.25);
    border-radius: 99px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
    flex-shrink: 0;
}

/* ========================================
   Tab Bar (Sub-tabs within section)
   ======================================== */

.tab-bar {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    padding: 8px 16px 0;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border-soft);
    overflow-x: auto;
    flex-shrink: 0;
    scrollbar-width: none;
}

.tab-bar::-webkit-scrollbar {
    display: none;
}

/* Chrome-style tab */
.tab-item {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px 7px 13px;
    cursor: pointer;
    font-size: 12.5px;
    color: var(--text-secondary);
    white-space: nowrap;
    background: var(--bg);
    border: 1px solid var(--border-soft);
    border-bottom: none;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    position: relative;
    bottom: 0;
    user-select: none;
    transition: background .12s, color .12s;
}

.tab-item:hover {
    background: var(--surface);
    color: var(--text);
}

/* active tab */
.tab-item.active {
    background: var(--surface);
    color: var(--primary);
    font-weight: 600;
    border-color: var(--border-soft);
    border-bottom-color: var(--surface);
    margin-bottom: -1px;
    padding-bottom: 8px;
}

.tab-label {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ไอคอน type บน tab */
.tab-type-badge {
    font-size: 12px;
    flex-shrink: 0;
    line-height: 1;
    opacity: 0.7;
}

.tab-item.active .tab-type-badge {
    opacity: 1;
}

/* checklist tab — ทำ emoji เป็นโทนเทา */
.tab-item.tab-type-checklist .tab-type-badge {
    filter: grayscale(1);
}

.tab-item.tab-type-checklist.active {
    background: #ffffff;
}

/* ปุ่ม ··· ใน tab */
.tab-menu-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-tertiary);
    padding: 1px 5px;
    border-radius: 4px;
    line-height: 1;
    letter-spacing: 1px;
    opacity: 0;
    transition: opacity 0.1s, background 0.1s;
    flex-shrink: 0;
}

.tab-item:hover .tab-menu-btn,
.tab-item.active .tab-menu-btn {
    opacity: 1;
}

.tab-menu-btn:hover {
    background: rgba(0,0,0,0.08);
    color: var(--text);
}

/* ปุ่ม + Tab ใน tab bar — ชิดขวาด้วย margin-left: auto */
.tab-add-btn {
    margin-left: auto;
    flex-shrink: 0;
    align-self: center;
    background: none;
    border: 1px dashed var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 12px;
    padding: 4px 10px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    margin-bottom: 4px;
}

.tab-add-btn:hover {
    background: var(--primary-light, rgba(74,108,247,0.08));
    color: var(--primary);
    border-color: var(--primary);
}

/* Context menu — append ใน body, position: fixed ไม่โดน editor บัง */
.tab-ctx-menu {
    display: none;
    position: fixed;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.14);
    z-index: 9999;
    min-width: 152px;
    overflow: hidden;
}

.tab-ctx-menu.open {
    display: block;
}

.tab-dd-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 9px 14px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    transition: background 0.1s;
}

.tab-dd-item:hover {
    background: var(--bg);
}

.tab-dd-delete {
    color: var(--danger);
}

/* ปุ่ม "+" เพิ่ม tab ใน tab bar */
.tab-add-btn {
    padding: 6px 10px;
    font-size: 16px;
    font-weight: 300;
    color: var(--text-tertiary);
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    align-self: center;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
    line-height: 1;
}

.tab-add-btn:hover {
    color: var(--primary);
    background: rgba(74, 108, 247, 0.08);
}

/* ปุ่ม 📎 ไฟล์แนบใน tab bar */
.tab-attach-btn {
    margin-left: 4px;
    align-self: center;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 6px;
    color: var(--text-secondary);
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
    margin-bottom: 4px;
}

.tab-attach-btn:hover {
    background: rgba(74, 108, 247, 0.08);
    color: var(--primary);
}

/* ชื่อ Section ใน tab bar (ซ้ายสุด) */
.tab-section-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    padding: 3px 8px;
    border-radius: 5px;
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
    align-self: center;
    transition: border-color 0.15s, background 0.15s;
}

.tab-section-label:hover {
    background: var(--bg);
    border-color: var(--border);
}

.tab-section-input {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    border: 1px solid var(--primary);
    border-radius: 5px;
    padding: 3px 8px;
    outline: none;
    width: 140px;
    align-self: center;
    flex-shrink: 0;
}

/* เส้นขั้น ระหว่างชื่อ section กับ tabs */
.tab-bar-sep {
    width: 1px;
    height: 18px;
    background: var(--border);
    margin: 0 6px;
    flex-shrink: 0;
    align-self: center;
}

/* ปุ่มลบ section ใน tab bar (ขวาสุด) */
.tab-del-section-btn {
    margin-left: 4px;
    align-self: center;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 15px;
    padding: 4px 8px;
    border-radius: 6px;
    color: var(--text-tertiary);
    opacity: 0.5;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
    flex-shrink: 0;
}

.tab-del-section-btn:hover {
    opacity: 1;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

.editor-wrapper {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ซ่อน raw textarea ก่อน TinyMCE init — TinyMCE จะ set display:none เองหลัง init */
.editor-wrapper > textarea {
    visibility: hidden;
    height: 0;
    padding: 0;
    border: 0;
    display: block;
    width: 0;
}

/* TinyMCE เต็ม wrapper */
.editor-wrapper .tox-tinymce {
    border: none !important;
    height: 100% !important;
}

/* ========================================
   Tab Type Picker (ใน modal)
   ======================================== */

.tab-type-picker {
    display: flex;
    gap: 8px;
}

.tab-type-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    transition: border-color 0.15s, background 0.15s, color 0.15s;
    font-family: inherit;
}

.tab-type-icon {
    font-size: 22px;
}

.tab-type-btn:hover {
    border-color: var(--primary);
    color: var(--text);
}

.tab-type-btn.active {
    border-color: var(--primary);
    background: rgba(74, 108, 247, 0.07);
    color: var(--primary);
    font-weight: 600;
}

/* ========================================
   Checklist UI
   ======================================== */

.checklist-wrap {
    padding: 24px 32px;
    max-width: 680px;
    margin: 0 auto;
    height: calc(100vh - 96px);
    overflow-y: auto;
}

.checklist-list {
    list-style: none;
    padding: 0;
    margin: 0 0 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    transition: background 0.1s, border-color 0.1s;
    cursor: default;
}

.checklist-item:hover {
    background: var(--bg);
    border-color: var(--border);
}

.checklist-item.dragging {
    opacity: 0.4;
}

.checklist-item.drag-over {
    border-color: var(--primary);
    background: rgba(74, 108, 247, 0.05);
}

.checklist-drag-handle {
    cursor: grab;
    color: var(--text-tertiary);
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
    flex-shrink: 0;
    user-select: none;
}

.checklist-drag-handle:active {
    cursor: grabbing;
}

.checklist-cb {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--primary);
}

.checklist-text {
    flex: 1;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    outline: none;
    border-bottom: 1px solid transparent;
    min-height: 1.5em;
    word-break: break-word;
}

.checklist-text:focus {
    border-bottom-color: var(--primary);
}

.checklist-item.checked .checklist-text {
    text-decoration: line-through;
    color: var(--text-tertiary);
}

.checklist-del {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-tertiary);
    font-size: 12px;
    padding: 2px 5px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.1s, background 0.1s;
    flex-shrink: 0;
}

.checklist-item:hover .checklist-del {
    opacity: 1;
}

.checklist-del:hover {
    background: rgba(220, 53, 69, 0.1);
    color: var(--danger);
}

.checklist-add-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
}

.checklist-add-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
}

.checklist-add-input:focus {
    border-color: var(--primary);
}

.checklist-add-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: var(--primary);
    transition: background 0.15s;
    flex-shrink: 0;
}

.checklist-add-btn:hover {
    background: rgba(74, 108, 247, 0.08);
}

.checklist-summary {
    margin-top: 16px;
    font-size: 12px;
    color: var(--text-tertiary);
    text-align: right;
}

/* ========================================
   Section Sidebar — Drag Reorder
   ======================================== */

.section-item[draggable="true"] {
    cursor: grab;
}

.section-item[draggable="true"]:active {
    cursor: grabbing;
}

.section-item.dragging {
    opacity: 0.4;
}

.section-item.drag-over {
    border-color: var(--primary) !important;
    background: rgba(74, 108, 247, 0.06) !important;
}

/* ========================================
   Attachment Modal
   ======================================== */

/* ============================================================
   Attach Strip — แถบไฟล์แนบใต้ editor
   ============================================================ */
.attach-strip {
    flex-shrink: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 0 16px;
    height: 40px;
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

.attach-strip-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.attach-strip-chips {
    flex: 1;
    display: flex;
    gap: 6px;
    overflow: hidden;
    min-width: 0;
}

.attach-chip {
    font-size: 11px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 8px;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: border-color 0.15s, color 0.15s;
}

.attach-chip:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.attach-strip-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 3px 10px;
    font-size: 11px;
    cursor: pointer;
    color: var(--text-secondary);
    white-space: nowrap;
    transition: border-color 0.15s, color 0.15s;
}

.attach-strip-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ============================================================
   Sidebar — section item attach badge
   ============================================================ */
.section-attach-badge {
    font-size: 11px;
    opacity: 0.55;
    flex-shrink: 0;
    margin-left: 2px;
}

/* Drop Zone */
.attach-dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 20px 16px 12px;
    text-align: center;
    margin-bottom: 12px;
    transition: border-color 0.15s, background 0.15s;
    cursor: default;
}

.attach-dropzone.drag-over {
    border-color: var(--primary);
    background: rgba(74, 108, 247, 0.05);
}

.attach-drop-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.attach-drop-icon {
    font-size: 24px;
}

.attach-hint {
    margin: 8px 0 0;
    font-size: 11px;
    color: var(--text-tertiary);
}

/* Progress bar */
.attach-progress {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-bottom: 12px;
    overflow: hidden;
}

.attach-progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    width: 0%;
    transition: width 0.2s;
}

/* รายการไฟล์ */
.attach-list {
    overflow-y: auto;
    max-height: 420px;
}

.attach-empty {
    text-align: center;
    color: var(--text-tertiary);
    font-size: 13px;
    padding: 32px 0;
}

/* ===== ตาราง ===== */
.attach-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.attach-table thead th {
    text-align: left;
    padding: 8px 10px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.attach-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

.attach-table tbody tr:last-child {
    border-bottom: none;
}

.attach-table tbody tr:hover {
    background: var(--bg);
}

.attach-table td {
    padding: 8px 10px;
    vertical-align: middle;
}

/* Thumbnail column */
.attach-col-thumb {
    width: 52px;
}

.attach-thumb-img {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
    display: block;
    cursor: pointer;
    transition: opacity 0.15s;
}

.attach-thumb-img:hover {
    opacity: 0.85;
}

.attach-thumb-icon {
    font-size: 28px;
    display: block;
    text-align: center;
    line-height: 1;
}

/* ชื่อไฟล์ column */
.attach-col-name {
    min-width: 180px;
}

.attach-name {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--primary);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
}

.attach-name:hover {
    text-decoration: underline;
}

.attach-size {
    display: block;
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

/* ตำแหน่ง column */
.attach-col-location {
    width: 160px;
}

.attach-note-tag {
    background: rgba(74, 108, 247, 0.1);
    color: var(--primary);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
    display: inline-block;
}

/* วันที่ column */
.attach-col-date {
    width: 130px;
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Actions column */
.attach-col-actions {
    width: 70px;
    text-align: right;
}

.btn-attach-dl {
    font-size: 16px;
    text-decoration: none;
    padding: 3px 5px;
    border-radius: 4px;
    transition: background 0.1s;
    cursor: pointer;
}

.btn-attach-dl:hover {
    background: var(--border);
}

.btn-attach-del {
    font-size: 16px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 3px 5px;
    border-radius: 4px;
    transition: background 0.1s;
    opacity: 0.4;
}

.btn-attach-del:hover {
    background: rgba(220, 53, 69, 0.1);
    opacity: 1;
}

/* ===== ปุ่ม [?] info ===== */
.modal-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.attach-info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1.5px solid var(--text-tertiary);
    color: var(--text-tertiary);
    font-size: 11px;
    font-weight: 700;
    cursor: default;
    position: relative;
    flex-shrink: 0;
    user-select: none;
}

.attach-info-tooltip {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #2b2b28;
    color: #fff;
    font-size: 12px;
    font-weight: 400;
    padding: 10px 14px;
    border-radius: 8px;
    white-space: nowrap;
    z-index: 200;
    line-height: 1.8;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    pointer-events: none;
}

.attach-info-btn:hover .attach-info-tooltip,
.attach-info-btn:focus .attach-info-tooltip {
    display: block;
}

.editor-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    font-size: 14px;
}

/* No-tab placeholder (กลางจอ) */
.editor-no-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 8px;
    color: var(--text-secondary);
    text-align: center;
}
.editor-no-tab-icon {
    font-size: 48px;
    line-height: 1;
    margin-bottom: 4px;
    opacity: .6;
}
.editor-no-tab-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}
.editor-no-tab-sub {
    font-size: 13px;
    color: var(--text-tertiary);
    margin: 0 0 12px;
}
.editor-no-tab-btn {
    padding: 8px 24px;
    font-size: 14px;
    border-radius: 8px;
}

/* ========================================
   Navbar — nav-link + navbar-center
   ======================================== */

/* กลางจอแบบ absolute — ไม่ขึ้นกับความกว้าง brand/user */
.navbar-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
    align-items: center;
}

/* Mobile dropdown menu */
.navbar-mobile-menu { display: none; }
.navbar-mobile-menu.open {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 16px;
    background: #EBF3FF;
    border-bottom: 1px solid var(--border);
}
.navbar-mobile-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    border-radius: 99px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
    white-space: nowrap;
}

.nav-link:hover {
    background: rgba(91, 159, 224, 0.12);
    color: var(--text);
}

.nav-link.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 10px rgba(91, 159, 224, 0.40);
}

/* ========================================
   Prompt Library Page
   ======================================== */

.prompts-page { background: var(--bg); }

.prompts-layout {
    display: flex;
    height: calc(100vh - 56px);
    overflow: hidden;
}

/* Sidebar */
.prompts-sidebar {
    width: 200px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 16px 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.prompt-filter-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.prompt-filter-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 4px;
}

/* (เดิม: prompt-filter-btn แบบ stacked — ถูก override ด้วย .prompt-filter-row style ในส่วนล่าง) */

/* Main */
.prompts-main {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px;
}

.prompts-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 8px;
}

.prompt-search-input {
    flex: 0 0 280px;
    background: var(--surface);
}

.prompt-count {
    font-size: 12px;
    color: var(--text-tertiary);
    margin: 0 0 16px;
}

/* Prompt Grid */
.prompt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 18px;
}

/* Filter row ใน prompts page */
.prompt-filter-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.prompt-filter-sep {
    width: 1px;
    height: 22px;
    background: var(--border);
    margin: 0 4px;
}
.prompt-filter-btn {
    padding: 7px 14px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-soft);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.prompt-filter-btn:hover {
    border-color: var(--border);
    color: var(--text);
    background: var(--bg-soft);
}
.prompt-filter-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 2px 6px rgba(24, 59, 117, .2);
}

/* Prompt Card */
.prompt-card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xs);
    transition: box-shadow .18s, transform .12s, border-color .15s;
    gap: 10px;
    transition: box-shadow 0.15s;
}

.prompt-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--border);
}

.prompt-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.prompt-type-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 99px;
}

.btn-prompt-fav {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 2px;
    opacity: 0.4;
    transition: opacity 0.15s, transform 0.15s;
}

.btn-prompt-fav:hover,
.btn-prompt-fav.starred { opacity: 1; }

.btn-prompt-fav.starred { transform: scale(1.15); }

/* Title row: ชื่อ (ellipsis) + copy icon ด้านขวา */
.prompt-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
}

.prompt-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
    line-height: 1.4;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.prompt-preview {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    overflow: hidden;
    font-family: 'JetBrains Mono', 'Consolas', 'Monaco', monospace;
    line-height: 1.55;
    flex: 1;
}

.prompt-note {
    font-size: 11px;
    color: var(--text-tertiary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.prompt-card-footer {
    display: flex;
    gap: 4px;
    margin-top: auto;
    border-radius: var(--radius-sm);
    overflow: hidden;
    height: 70px;
    flex-shrink: 0;
}

.prompt-use-count {
    font-size: 11px;
    color: var(--text-tertiary);
}

.prompt-card-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.btn-copy-prompt {
    font-size: 12px !important;
    padding: 4px 10px !important;
}

.prompt-empty {
    text-align: center;
    color: var(--text-tertiary);
    padding: 80px 0;
    font-size: 14px;
}

.prompt-content-input {
    resize: vertical;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    line-height: 1.6;
}

/* ========================================
   Filter Bar (Phase 2)
   ======================================== */

.filter-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.filter-pill {
    padding: 7px 14px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-soft);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.filter-pill:hover {
    border-color: var(--border);
    color: var(--text);
    background: var(--bg-soft);
}
.filter-pill.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 2px 6px rgba(24, 59, 117, .2);
}

/* Tag filter area */
.tag-filter-area {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.tag-filter-pill {
    padding: 4px 10px;
    border-radius: 99px;
    border: 1px solid var(--tag-color, #ccc);
    background: transparent;
    color: var(--tag-color, #666);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.tag-filter-pill:hover {
    background: color-mix(in srgb, var(--tag-color, #ccc) 15%, transparent);
}

.tag-filter-pill.active {
    background: var(--tag-color, #ccc);
    color: #fff;
}

/* ========================================
   Card Tags (Phase 2)
   ======================================== */

.card-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin: 4px 0;
}

.card-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

/* ========================================
   Tag Picker (ใน Project Modal)
   ======================================== */

.form-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.form-label-row .form-label {
    margin-bottom: 0;
}

.btn-link-sm {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    color: var(--primary);
    padding: 0;
    text-decoration: none;
}

.btn-link-sm:hover {
    text-decoration: underline;
}

.tag-picker {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    min-height: 36px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
}

.tag-picker-empty {
    font-size: 12px;
    color: var(--text-tertiary);
    align-self: center;
}

.tag-pick-pill {
    padding: 3px 10px;
    border-radius: 99px;
    border: 1px solid var(--tag-color, #ccc);
    background: transparent;
    color: var(--tag-color, #666);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.tag-pick-pill:hover {
    background: color-mix(in srgb, var(--tag-color, #ccc) 15%, transparent);
}

.tag-pick-pill.selected {
    background: var(--tag-color, #ccc);
    color: #fff;
}

/* ========================================
   Tag Manager Modal
   ======================================== */

.tag-create-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 16px;
}

.tag-create-row .form-control-sm {
    flex: 1;
    padding: 6px 10px;
    font-size: 13px;
    height: 34px;
}

.tag-create-row input[type="color"] {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 2px;
    flex-shrink: 0;
}

.tag-manager-list {
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.tag-manager-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

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

.tag-manager-item:hover {
    background: var(--bg);
}

.tag-swatch {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}

.tag-manager-name {
    flex: 1;
    font-size: 13px;
    color: var(--text);
}

.tag-manager-empty {
    text-align: center;
    padding: 20px;
    color: var(--text-tertiary);
    font-size: 13px;
    margin: 0;
}

/* ============================================================
   Prompt Modal — ขนาดใหญ่ขึ้น รองรับ prompt ยาว
   ============================================================ */

/* modal-prompt: กว้าง + มี scroll bar เมื่อ content ยาว */
.modal-box.modal-prompt {
    max-width: 800px;
    width: 95vw;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
}

/* form ส่วนที่ scroll ได้ */
.modal-prompt form {
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
}

/* label hint text */
.form-hint {
    font-size: 11px;
    color: var(--text-tertiary);
    font-weight: 400;
    margin-left: 6px;
}

/* ลด margin ระหว่าง field ใน prompt modal */
.modal-prompt .form-group {
    margin-bottom: 12px;
}

/* override grid → flex เพื่อรองรับ 3 ช่องในแถวเดียว */
.modal-prompt .form-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 12px;
}

/* label row สำหรับ Prompt + ปุ่ม copy */
.prompt-content-labelrow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.prompt-content-labelrow .form-label {
    margin-bottom: 0;
}

.prompt-copy-btn {
    padding: 2px 10px;
    font-size: 12px;
    line-height: 1.5;
}

/* ============================================================
   Prompt toolbar — search + project filter + button
   ============================================================ */
.prompts-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
}

.prompt-search-input { flex: 1; }

.prompt-project-filter {
    width: 180px;
    flex-shrink: 0;
}

/* ============================================================
   Image Slots (3 ช่อง แนวนอน)
   ============================================================ */
.prompt-img-slots {
    display: flex;
    gap: 12px;
}

.prompt-img-slot {
    position: relative;
    flex: 1;
    aspect-ratio: 1 / 1;
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    background: var(--bg);
    transition: border-color .15s, background .15s;
}

.prompt-img-slot.empty:hover,
.prompt-img-slot.drag-over {
    border-color: var(--primary);
    background: #f0f3ff;
}

/* placeholder ตรงกลาง */
.slot-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 100%;
    color: var(--text-tertiary);
    font-size: 12px;
    user-select: none;
    padding: 8px;
    text-align: center;
}

/* รูปภาพ preview */
.slot-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    cursor: zoom-in;
}

/* ปุ่มลบ — อยู่มุมขวาบน */
.slot-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(0,0,0,.55);
    color: #fff;
    border: none;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .15s;
}

.prompt-img-slot:hover .slot-remove {
    opacity: 1;
}

/* Card คลิกได้ทั้งใบ */
.prompt-card {
    cursor: pointer;
}

/* Copy icon บน card */
.prompt-copy-icon {
    font-size: 16px;
    cursor: pointer;
    opacity: 0.45;
    transition: opacity .15s, transform .1s;
    user-select: none;
    padding: 2px 4px;
    border-radius: 4px;
}

.prompt-copy-icon:hover {
    opacity: 1;
    transform: scale(1.15);
}

/* modal footer: ลบอยู่ซ้าย, ยกเลิก+บันทึกอยู่ขวา */
.modal-prompt .modal-footer {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============================================================
   Prompt Card — thumbnail in footer (2 ภาพ)
   ============================================================ */
.prompt-card-thumb {
    flex: 1;
    min-width: 0;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 4px;
}

/* ============================================================
   Prompt Card — project tag badge
   ============================================================ */
.prompt-proj-tag {
    display: inline-block;
    font-size: 11px;
    color: var(--text-secondary);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 7px;
    margin: 2px 0 4px;
}

/* ========================================
   Files Page
   ======================================== */

.files-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.files-loading {
    padding: 40px;
    text-align: center;
    color: var(--text-tertiary);
}
.files-group {
    margin-bottom: 24px;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}
.files-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border-soft);
}
.files-group-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-blue);
}
.files-group-name {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--text);
    flex: 1;
}
.files-group-count {
    font-size: 11px;
    color: var(--text-tertiary);
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-pill);
    padding: 2px 8px;
    font-weight: 600;
}
.files-table-wrap { overflow-x: auto; }
.files-table {
    width: 100%;
    font-size: 14px;
    border-collapse: collapse;
    font-size: 13px;
}
.files-table th {
    text-align: left;
    padding: 8px 18px;
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-tertiary);
    border-bottom: 1px solid var(--border-soft);
    background: var(--surface);
}
.files-table td {
    padding: 10px 18px;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
}
.files-table tr:last-child td { border-bottom: none; }
.files-table tr:hover td { background: var(--bg-soft); }
.files-file-icon { margin-right: 4px; }
.files-name { font-weight: 500; color: var(--text); }
.files-note { color: var(--text-secondary); font-size: 13px; }
.files-size { color: var(--text-tertiary); white-space: nowrap; font-size: 13px; }
.files-date { color: var(--text-tertiary); white-space: nowrap; font-size: 13px; }
.files-actions { white-space: nowrap; text-align: right; display: flex; gap: 4px; justify-content: flex-end; }
.files-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    text-decoration: none;
    transition: background .1s, border-color .1s, color .1s;
}
.files-action-btn:hover {
    background: var(--bg-soft);
    border-color: var(--border);
    color: var(--text);
}
.files-action-del:hover { color: var(--danger); border-color: var(--danger-soft); background: var(--danger-soft); }

/* ========================================
   Settings Page
   ======================================== */

.settings-page { max-width: none; }

.settings-header { margin-bottom: 24px; }
.settings-title  { font-size: 22px; font-weight: 700; margin: 0; color: var(--text); }

.settings-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    align-items: start;
}

.settings-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-soft);
    padding: 22px 24px;
    box-shadow: var(--shadow-xs);
    transition: box-shadow .15s, border-color .15s;
}
.settings-card:hover {
    box-shadow: var(--shadow-sm);
}
.settings-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.settings-card-icon { font-size: 20px; }
.settings-card-header h2 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    color: var(--text);
}
.settings-card-footer {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
}

/* Storage card */
.storage-summary { margin-bottom: 16px; }
.storage-summary-numbers {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 8px;
}
.storage-used  { font-size: 28px; font-weight: 700; color: var(--text); }
.storage-sep   { font-size: 13px; color: var(--text-tertiary); }
.storage-quota { font-size: 16px; color: var(--text-secondary); }
.storage-bar-full {
    width: 100%;
    height: 10px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 6px;
}
.storage-bar-fill-full {
    height: 100%;
    border-radius: 99px;
    transition: width .4s;
}
.storage-pct-label { font-size: 12px; color: var(--text-tertiary); }

.storage-breakdown { display: flex; flex-direction: column; gap: 10px; }
.storage-breakdown-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    padding: 8px 10px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}
.storage-breakdown-icon { font-size: 16px; flex-shrink: 0; }
.storage-breakdown-label { flex: 1; color: var(--text-secondary); }
.storage-breakdown-val { font-weight: 600; color: var(--text); }

/* ========================================
   Responsive Navbar
   ======================================== */

.navbar-hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 4px 6px;
    color: var(--text);
    line-height: 1;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}
.navbar-hamburger:hover { background: rgba(0,0,0,.06); }

/* ========================================
   EDITOR PAGE — sidebar icon-only + hover overlay (desktop only)
   ======================================== */
@media (min-width: 961px) {
    body.editor-page {
        --sidebar-w: 64px;
    }
    body.editor-page .app-sidebar {
        width: 64px;
        transition: width .2s ease;
        overflow: hidden;
        z-index: 60;
    }
    body.editor-page .app-sidebar:hover {
        width: 240px;
        box-shadow: var(--shadow-lg);
    }

    /* ซ่อน label / storage / user info ตอน collapsed */
    body.editor-page .app-sidebar:not(:hover) .sb-link-label,
    body.editor-page .app-sidebar:not(:hover) .sb-brand-name,
    body.editor-page .app-sidebar:not(:hover) .sb-group-label,
    body.editor-page .app-sidebar:not(:hover) .sb-storage,
    body.editor-page .app-sidebar:not(:hover) .sb-user-info,
    body.editor-page .app-sidebar:not(:hover) .sb-user-logout {
        display: none;
    }
    body.editor-page .app-sidebar:not(:hover) .sb-link {
        justify-content: center;
        padding: 8px;
    }
    body.editor-page .app-sidebar:not(:hover) .sb-brand {
        justify-content: center;
        padding: 16px 0 14px;
    }
    body.editor-page .app-sidebar:not(:hover) .sb-brand-link {
        justify-content: center;
    }
    body.editor-page .app-sidebar:not(:hover) .sb-user {
        justify-content: center;
        padding: 12px 0;
    }
    body.editor-page .app-sidebar:not(:hover) .sb-manage {
        padding: 8px 0;
    }
}

/* ========================================
   MANUAL COLLAPSE — user กดพับ sidebar (desktop ≥961px)
   ======================================== */
@media (min-width: 961px) {
    /* แสดงปุ่ม collapse บน desktop เสมอ */
    .sb-collapse-btn {
        display: inline-flex;
    }

    /* ─── สถานะ collapsed ─── */
    body.sb-collapsed {
        --sidebar-w: 64px;
    }
    body.sb-collapsed .app-sidebar {
        width: 64px;
        overflow: hidden;
        transition: width .2s ease;
        z-index: 60;
    }
    body.sb-collapsed .app-sidebar:hover {
        width: 240px;
        overflow: visible;
        box-shadow: var(--shadow-lg);
    }

    /* ซ่อน label ขณะ collapsed + ไม่ hover */
    body.sb-collapsed .app-sidebar:not(:hover) .sb-link-label,
    body.sb-collapsed .app-sidebar:not(:hover) .sb-brand-name,
    body.sb-collapsed .app-sidebar:not(:hover) .sb-group-label,
    body.sb-collapsed .app-sidebar:not(:hover) .sb-user-info,
    body.sb-collapsed .app-sidebar:not(:hover) .sb-user-logout {
        display: none;
    }
    body.sb-collapsed .app-sidebar:not(:hover) .sb-link {
        justify-content: center;
        padding: 8px;
    }
    body.sb-collapsed .app-sidebar:not(:hover) .sb-brand {
        justify-content: center;
        padding: 16px 0 14px;
    }
    body.sb-collapsed .app-sidebar:not(:hover) .sb-brand-link {
        justify-content: center;
    }
    body.sb-collapsed .app-sidebar:not(:hover) .sb-user {
        justify-content: center;
        padding: 12px 0;
    }
    body.sb-collapsed .app-sidebar:not(:hover) .sb-manage {
        padding: 8px 0;
    }

    /* ─── Editor page: ยังคงพับอัตโนมัติ แต่ถ้า user พับเองด้วยก็ไม่ conflict ─── */
    body.editor-page.sb-collapsed .app-sidebar,
    body.editor-page .app-sidebar {
        width: 64px;
    }
}

/* ========================================
   Responsive — App Sidebar drawer (≤960px)
   ======================================== */
@media (max-width: 960px) {
    .app-sidebar {
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: 8px 0 32px rgba(15, 23, 42, .12);
    }
    .app-sidebar.is-open {
        transform: translateX(0);
    }
    .app-main {
        margin-left: 0;
    }
    .util-mobile-toggle {
        display: inline-flex;
    }
    .util-bar { padding: 0 16px; }
    .app-content { padding: 18px 16px 32px; }
}

/* ========================================
   Trash Page
   ======================================== */

.trash-group {
    margin-bottom: 28px;
}

.trash-group-header {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.trash-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    transition: box-shadow .15s;
}
.trash-item:hover { box-shadow: var(--shadow-sm); }

.trash-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.trash-item-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trash-item-sub {
    font-size: 12px;
    color: var(--text-tertiary);
}

.trash-days {
    font-size: 12px;
    color: var(--text-tertiary);
    white-space: nowrap;
    padding: 2px 8px;
    border-radius: 99px;
    background: var(--bg);
}
.trash-days.warn   { color: var(--warning); background: rgba(200,154,64,.1); }
.trash-days.urgent { color: var(--danger);  background: rgba(224,112,112,.1); }

.trash-item-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    border: none;
}
.btn-danger:hover { background: #d05555; }

/* ========================================
   Star Rating (Prompt Library)
   ======================================== */
.star-rating {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 38px;
    padding: 0 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    user-select: none;
}
.star-rating .star {
    font-size: 22px;
    color: #d1d5db;
    cursor: pointer;
    line-height: 1;
    transition: color .12s, transform .12s;
}
.star-rating .star.filled,
.star-rating .star.hover {
    color: #f59e0b;
}
.star-rating .star:hover {
    transform: scale(1.15);
}
.star-rating .star-clear {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-tertiary);
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 4px;
}
.star-rating .star-clear:hover {
    background: rgba(0,0,0,.06);
    color: var(--danger);
}

/* Rating ใน card */
.prompt-rating-display {
    display: inline-block;
    color: #f59e0b;
    font-size: 14px;
    letter-spacing: 1px;
    margin: 4px 0;
}

/* ========================================
   Mobile Sidebar Toggle (Editor page)
   ======================================== */
.breadcrumb-sidebar-toggle {
    display: none;           /* default: ซ่อนบน desktop */
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 2px 8px;
    line-height: 1;
    color: var(--text);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}
.breadcrumb-sidebar-toggle:hover { background: rgba(0,0,0,.06); }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 998;
    opacity: 0;
    transition: opacity .2s;
}
.sidebar-backdrop.show {
    display: block;
    opacity: 1;
}

/* ========================================
   HOME PAGE — Stats cards + sections
   ======================================== */
/* ===== Stats grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 28px;
}
.stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    box-shadow: var(--shadow-xs);
    transition: box-shadow .18s, transform .12s, border-color .15s;
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: transparent;
    transition: background .15s;
}
.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--border);
}
.stat-card:hover::before { background: var(--accent-blue); }

.stat-card-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
/* icon color variants */
.stat-icon-blue  { background: var(--accent-blue-soft); color: var(--primary); }
.stat-icon-pink  { background: var(--pink-soft);        color: var(--pink); }
.stat-icon-amber { background: var(--warning-soft);     color: #92400E; }
.stat-icon-green { background: var(--success-soft);     color: #065F46; }

.stat-card-body { min-width: 0; flex: 1; }
.stat-card-label {
    font-size: 11px;
    color: var(--text-tertiary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.stat-card-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
    margin-top: 3px;
}
.stat-card-unit {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-tertiary);
}
/* progress bar เล็กสำหรับ storage */
.stat-card-bar {
    height: 4px;
    background: var(--border-soft);
    border-radius: 2px;
    margin-top: 6px;
    overflow: hidden;
    position: relative;
}
.stat-bar-fill {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    border-radius: 2px;
    transition: width .3s;
}

/* ===== Home page header quick actions ===== */
.home-page-header { align-items: center; }
.home-quick-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.home-quick-actions .btn { font-size: 13px; gap: 6px; }

/* ===== Home grid ===== */
.home-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
@media (max-width: 900px) {
    .home-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

.home-section {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 0;
    box-shadow: var(--shadow-xs);
    overflow: hidden;
}
.home-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 14px;
    border-bottom: 1px solid var(--border-soft);
    background: var(--surface-2);
}
.home-section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 7px;
}
.home-section-count {
    font-size: 11px;
    color: var(--text-tertiary);
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-pill);
    padding: 2px 8px;
    font-weight: 600;
}
.home-empty {
    padding: 36px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13.5px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.home-empty p { margin: 0 0 4px; }
.home-empty-hint {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.fav-list, .recent-list {
    display: flex;
    flex-direction: column;
    padding: 8px 0;
}
.fav-item, .recent-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 20px;
    text-decoration: none;
    color: var(--text);
    transition: background .1s;
}
.fav-item:hover, .recent-item:hover {
    background: var(--bg-soft);
}
.fav-item-icon, .recent-item-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.fav-item-icon-project { background: var(--accent-blue-soft); color: var(--primary); }
.fav-item-icon-prompt  { background: var(--pink-soft); color: var(--pink); }
.recent-icon-project   { background: var(--accent-blue-soft); color: var(--primary); }
.recent-icon-prompt    { background: var(--pink-soft);        color: var(--pink); }

.fav-item-body, .recent-item-body { flex: 1; min-width: 0; }
.fav-item-title, .recent-item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.fav-item-meta, .recent-item-meta {
    font-size: 11.5px;
    color: var(--text-tertiary);
    margin-top: 1px;
}
.fav-pin { font-size: 13px; flex-shrink: 0; }
.star-inline { color: var(--warning); font-size: 11px; }

/* ========================================
   Tablet Responsive — Settings + grids (≤960px)
   ======================================== */
@media (max-width: 960px) {
    .settings-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ========================================
   Mobile Responsive — All pages (≤680px)
   ======================================== */
@media (max-width: 680px) {

    /* ---------- Main content ---------- */
    .main-content { padding: 16px 12px; }
    .app-content  { padding: 16px 14px 28px; }

    /* ---------- Settings ---------- */
    .settings-grid { grid-template-columns: 1fr; }

    /* ---------- Home ---------- */
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .home-quick-actions { display: none; } /* ซ่อน quick actions บน mobile */

    /* ---------- Page header ---------- */
    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .page-title { font-size: 22px; }
    .page-actions { width: 100%; justify-content: flex-end; }
    .page-toolbar { width: 100%; flex-wrap: wrap; }
    .page-search input { width: 100%; flex: 1; }
    .page-search { flex: 1; min-width: 120px; }

    /* Util bar — ซ่อน search kbd hint บนมือถือ */
    .util-search-kbd { display: none; }

    /* ---------- Dashboard header (legacy) ---------- */
    .dashboard-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .dashboard-title { font-size: 22px; }

    .search-filter-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .search-input {
        flex: 1 1 auto;       /* override flex: 0 0 300px ที่กลายเป็น height ใน column */
        width: 100%;
        min-height: 40px;
    }
    .filter-group {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }
    .filter-group::-webkit-scrollbar { display: none; }
    .filter-pill { flex-shrink: 0; }

    /* Project grid → 1 column */
    .project-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* ---------- Modal ---------- */
    .modal-overlay { padding: 12px; }
    .modal-box {
        padding: 16px;
        max-height: 92vh;
        overflow-y: auto;
    }
    .modal-box.modal-prompt {
        width: 100%;
        max-height: 95vh;
    }
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    .form-row .form-group { flex: 1 1 auto !important; }

    /* ---------- Editor page: Breadcrumb ---------- */
    .breadcrumb-sidebar-toggle { display: inline-flex; align-items: center; }
    .project-breadcrumb {
        padding: 0 10px;
        gap: 4px;
        font-size: 12px;
    }
    .breadcrumb-home { font-size: 15px; }
    .breadcrumb-project { max-width: 90px; font-size: 12px; }
    .breadcrumb-section { max-width: 110px; font-size: 12px; }

    /* ---------- Editor page: Sidebar → drawer ---------- */
    .editor-layout { position: relative; }

    .editor-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 260px;
        max-width: 80vw;
        z-index: 999;
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: 4px 0 16px rgba(0,0,0,.15);
    }
    .editor-sidebar.open { transform: translateX(0); }

    /* ---------- Editor page: Tab bar ---------- */
    .tab-bar { padding: 4px 8px 0; gap: 2px; }
    .save-indicator { font-size: 11px; }

    /* tab — อ่านชื่อได้พอควร แล้วใช้ scroll แนวนอนแทนการบีบ */
    .tab-item {
        padding: 6px 10px;
        font-size: 12px;
        flex-shrink: 0;       /* ห้าม browser บีบให้แคบ */
    }
    .tab-label {
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    /* ซ่อนปุ่ม ··· บนแท็บที่ไม่ active เพื่อประหยัดที่ */
    .tab-item:not(.active) .tab-menu-btn { display: none; }

    /* ---------- Editor page: Attach strip ---------- */
    .attach-strip { padding: 0 10px; height: 36px; }
    .attach-strip-label { font-size: 11px; }

    /* ---------- Prompt Library: Sidebar → horizontal ---------- */
    .prompts-layout {
        flex-direction: column;
        height: auto;
    }
    .prompts-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        display: flex;
        flex-direction: row;
        gap: 6px;
        overflow-x: auto;
        padding: 8px 12px;
        -webkit-overflow-scrolling: touch;
    }
    .prompts-sidebar::-webkit-scrollbar { display: none; }
    .prompt-filter-group {
        display: flex;
        flex-direction: row;
        gap: 6px;
        flex-shrink: 0;
    }
    .prompt-filter-btn { white-space: nowrap; flex-shrink: 0; }
    .prompt-filter-divider {
        width: 1px;
        height: 28px;
        background: var(--border);
        margin: 0 4px;
        align-self: center;
        flex-shrink: 0;
    }

    .prompts-main { padding: 12px; }
    .prompts-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .prompt-search-input,
    .prompt-project-filter { width: 100%; }
    .prompt-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* ---------- Trash page: items → stack ---------- */
    .trash-item {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 12px;
    }
    .trash-item-info { flex: 1 1 100%; min-width: 0; }
    .trash-days { order: 2; }
    .trash-item-actions {
        flex: 1 1 100%;
        justify-content: flex-end;
    }
}

/* ========================================
   Very small screens (≤420px) — extra tight
   ======================================== */
@media (max-width: 420px) {
    .breadcrumb-project { max-width: 70px; }
    .breadcrumb-section { max-width: 80px; }
    .modal-box { padding: 14px; }
    .navbar { padding: 0 10px; }
    .navbar-title { font-size: 15px; }
    .filter-pill { font-size: 12px; padding: 4px 10px; }
}
