/* ===== v1.2 user-facing layout (items 15, 16, 17, 19, 25) ===== */
/* use the side space: grids auto-fit instead of a fixed 2 columns */
.grid{grid-template-columns:repeat(auto-fill,minmax(min(100%,290px),1fr));}
@media (max-width:480px){ .grid{grid-template-columns:1fr;} }
/* marketplace (buyer): masonry — rectangular cards of different heights, tightly packed */
#mkt-market-grid,#tab-bookmark-market-list{display:block; column-width:230px; column-gap:12px; padding-left:0; padding-right:0;}
@media (min-width:600px){ #mkt-market-grid,#tab-bookmark-market-list{column-width:195px;} }
#mkt-market-grid > .mkt-market-card,#tab-bookmark-market-list > .mkt-market-card{break-inside:avoid; margin:0 0 12px; display:block; width:100%;}
#mkt-market-grid > .mkt-empty-state{column-span:all;}
#mkt-market-grid .mkt-market-cover,#tab-bookmark-market-list .mkt-market-cover{width:100%; height:auto; background-size:cover; background-position:center;}
/* seller dashboard + listing management: full width, cards flow into columns */
.mkt-seller-wrap{max-width:none !important; padding-left:0 !important; padding-right:0 !important;}
.mkt-listings-list{display:grid; grid-template-columns:repeat(auto-fill,minmax(min(100%,340px),1fr)); align-items:start;}
.mkt-sales-list{display:grid; grid-template-columns:repeat(auto-fill,minmax(min(100%,320px),1fr));}
/* reports / feedback */
.rp-body{max-width:none !important;}
.rp-form-grid{display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,320px),1fr)); gap:14px;}
/* phone gutters (item 25): ONE 16px gutter on .z-results; inner wrappers that used to add their own 20px are zeroed so nothing is flush with the edge or doubled */
@media (max-width:859px){
  .z-results{padding-left:16px !important; padding-right:16px !important;}
  .z-results .grid,.bookmark-stats,.bookmark-section-title,.account-wrap,.rp-body,#bookmark-exams-section .grid,#bookmark-market-section .grid,#take-exam-section .grid{padding-left:0 !important; padding-right:0 !important;}
  #bookmark-exams-section,#bookmark-market-section,#take-exam-section{padding-left:16px !important; padding-right:16px !important;}
  #bookmark-exams-section .bookmark-section-title,#bookmark-market-section .bookmark-section-title,#take-exam-section .bookmark-section-title{padding-left:0; padding-right:0;}
  .z-results .chip-row{margin-left:-16px; margin-right:-16px; padding-left:16px; padding-right:16px;}
  .z-results .grid{padding-left:0 !important; padding-right:0 !important;}
}

.subj-manage-link{background:none; border:none; padding:2px 0; margin-top:4px; font:inherit; font-size:var(--fs-xs); font-weight:700; color:var(--ink); text-decoration:underline; cursor:pointer;}

/* wide layout: the saved-summaries and take-exam blocks sat flush against the sidebar; give them the same 36px side gutter as the saved-exams block */
@media (min-width:860px){
  #bookmark-market-section,#take-exam-section{padding-left:36px; padding-right:36px;}
  #bookmark-market-section .bookmark-section-title,#take-exam-section .bookmark-section-title{padding-left:0; padding-right:0;}
  #bookmark-market-section .grid,#tab-bookmark-market-list,#take-exam-section .grid{padding-left:0; padding-right:0;}
}

/* covers keep their own proportions: nothing is cropped (item 6) */
.mkt-market-cover.has-img{aspect-ratio:auto !important; background:none; display:block; max-height:none;}
.mkt-market-cover.has-img img{display:block; width:100%; height:auto; border-radius:inherit;}
@media (hover:hover){ .mkt-market-card:hover .mkt-market-cover.has-img{transform:none;} .mkt-market-card:hover .mkt-market-cover.has-img img{transform:scale(1.03);} }
.mkt-market-cover.has-img img{transition:transform 260ms var(--ease-pop,ease);}

/* home tab preview of the marketplace: same masonry as the marketplace tab, so a short card never stretches to the height of its neighbour */
#home-market-grid{display:flex !important; gap:12px; align-items:flex-start; padding-left:0; padding-right:0;}
#home-market-grid > .hm-col{flex:1 1 0; min-width:0; display:flex; flex-direction:column; gap:12px;}
#home-market-grid .mkt-market-card{margin:0; display:block; width:100%;}
#home-market-grid .mkt-market-card > *{margin-bottom:9px;} #home-market-grid .mkt-market-card > :last-child{margin-bottom:0;}
#mkt-market-grid .mkt-market-card > *,#tab-bookmark-market-list .mkt-market-card > *{margin-bottom:9px;} #mkt-market-grid .mkt-market-card > :last-child,#tab-bookmark-market-list .mkt-market-card > :last-child{margin-bottom:0;}

/* practice tab: no big empty band between the intro card and the filters below it */
.z-results:has(> #practice-panel){padding-bottom:0 !important;}
#practice-panel.account-wrap{padding-bottom:6px;}
.z-results:has(> #practice-panel) + .exam-chips-wrap{padding-top:8px;}

/* page heading shown at the top of every tab (js/ui.js applyTabTitle) */
.tab-h1{padding-top:26px; margin:0 0 4px !important;}
.z-results:has(> .tab-h1) > .account-wrap{padding-top:10px;}
/* หน้าที่มีหัวข้อของตัวเองอยู่แล้ว (การ์ดดำ / ชื่อในหน้า) ไม่ต้องมีชื่อซ้ำด้านบนอีก
   (แผงอื่นถูกลบออกจาก DOM ตอนสลับแท็บ จึงมีเฉพาะแผงของแท็บที่เปิดอยู่) */
.z-results:has(#admin-dashboard-panel, #admin-practice-panel, #analytics-panel, #settings-panel, #admin-missions-panel, #marketplace-panel, #seller-panel, #admin-reports-panel, #messages-panel-tab) > .tab-h1{display:none;}

/* ---- ตัวจัดการรายวิชา (modal) — เดิมไม่มีสไตล์ จึงแสดงผลไม่ออก ---- */
.subj-modal-overlay{position:fixed; inset:0; z-index:9000; background:rgba(0,0,0,.5); display:flex; align-items:center; justify-content:center; padding:16px;}
.subj-modal{background:var(--card); color:var(--ink); border-radius:26px; width:min(440px,100%); max-height:80vh; display:flex; flex-direction:column; padding:16px; box-shadow:0 20px 60px rgba(0,0,0,.35);}
.subj-modal-head{display:flex; align-items:center; justify-content:space-between; margin-bottom:10px; font-size:var(--fs-md);}
.subj-modal-close{border:none; background:transparent; color:var(--ink); font-size:24px; line-height:1; cursor:pointer; padding:2px 8px;}
.subj-modal-add{display:flex; gap:8px; margin-bottom:6px;}
.subj-modal-add .admin-input{flex:1; margin:0;}
.subj-modal-add .btn{width:auto; padding:8px 16px;}
.subj-modal-msg{min-height:18px; font-size:var(--fs-sm); color:var(--danger, #c0392b);}
.subj-modal-list{overflow-y:auto; border-top:1px solid var(--line); margin-top:6px;}
.subj-row{display:flex; align-items:center; gap:6px; padding:8px 2px; border-bottom:1px solid var(--line);}
.subj-name{flex:1; min-width:0; overflow-wrap:anywhere;}
.subj-empty{padding:16px 0; text-align:center; color:var(--muted);}
