/* Layout: a quiet profile column beside a single feed of work posts; one column under 900px */
:root {
  --bg: #F2F3F5;
  --surface: #FFFFFF;
  --sunk: #E8EAEE;
  --ink: #15171B;
  --muted: #5D6472;
  --line: #DEE1E7;
  --accent: #2A56E6;
  --accent-soft: #E3E9FC;
  --danger: #C2362B;
  --scrim: rgba(242, 243, 245, .7);
  --media-scrim: rgba(12, 14, 18, .5);
  --on-media: #FFFFFF;
  --shadow: 0 1px 2px rgba(20, 22, 27, .06), 0 14px 36px rgba(20, 22, 27, .14);
  --f-display: "Anuphan", "IBM Plex Sans Thai", system-ui, -apple-system, sans-serif;
  --f-body: "IBM Plex Sans Thai", "Noto Sans Thai", system-ui, -apple-system, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --r: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1013; --surface: #16191E; --sunk: #1F232A; --ink: #ECEEF2; --muted: #9AA2AF; --line: #282C34;
    --accent: #88A4FF; --accent-soft: #1C2440; --danger: #FF8577; --scrim: rgba(14, 16, 19, .72);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 14px 36px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: light; -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; }
img, video { max-width: 100%; }
[hidden] { display: none !important; }
html.locked { overflow: hidden; }
body { background: var(--bg); color: var(--ink); font: 400 15px/1.65 var(--f-body); -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { width: 1em; height: 1em; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* owner bar */
.adminbar { background: var(--ink); color: var(--bg); font-size: 13px; }
.adminbar__in {
  max-width: 1040px; margin: 0 auto; padding-block: 8px; display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.adminbar__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.adminbar__msg { flex: 1 1 220px; min-width: 0; }
.adminbar__acts { display: flex; gap: 8px; flex-wrap: wrap; }
.adminbar button {
  background: transparent; border: 1px solid color-mix(in srgb, var(--bg) 35%, transparent); color: inherit;
  border-radius: 999px; padding: 4px 12px; cursor: pointer; font-size: 13px;
}
.adminbar button:hover { background: color-mix(in srgb, var(--bg) 12%, transparent); }
.adminbar .adminbar__hot { border-color: var(--accent); color: var(--accent); }

/* page */
.page {
  max-width: 1040px; margin: 0 auto; padding-block: 40px 128px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 48px; align-items: start;
}
@media (max-width: 900px) {
  .page { grid-template-columns: minmax(0, 1fr); gap: 28px; padding-block: 24px 120px; }
}
.page--single { grid-template-columns: minmax(0, 560px); justify-content: center; }

/* profile */
.profile { position: sticky; top: calc(28px + env(safe-area-inset-top, 0px)); min-width: 0; }
@media (max-width: 900px) { .profile { position: static; } }
.avatar {
  width: 88px; aspect-ratio: 1; border-radius: 50%; overflow: hidden; display: grid; place-items: center;
  background: var(--accent-soft) center / cover no-repeat; color: var(--accent); font: 600 34px/1 var(--f-display); flex: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar--s { width: 38px; font-size: 16px; }
.name { font: 600 28px/1.2 var(--f-display); letter-spacing: -.01em; margin: 18px 0 2px; text-wrap: balance; overflow-wrap: anywhere; }
.tagline { margin: 0; color: var(--muted); }
.bio { margin: 14px 0 0; white-space: pre-line; overflow-wrap: anywhere; }
.roles { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.roles li { font-size: 13px; line-height: 1.5; padding: 3px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.stats { display: flex; gap: 28px; margin: 22px 0 0; padding: 14px 0; border-block: 1px solid var(--line); }
.stats div { display: grid; }
.stats dt { font-size: 12px; color: var(--muted); }
.stats dd { margin: 0; font: 600 22px/1.25 var(--f-display); font-variant-numeric: tabular-nums; }
.contacts { list-style: none; padding: 0; margin: 10px 0 0; display: grid; }
.contacts li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; min-width: 0; }
.contacts li + li { border-top: 1px dashed var(--line); }
.c-label { font-size: 13px; color: var(--muted); flex: none; }
.c-value { font-weight: 500; overflow-wrap: anywhere; text-align: right; display: inline-flex; align-items: center; gap: 4px; min-width: 0; }
.c-copy { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.mini { font-size: 12px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.updated { margin: 18px 0 0; font-size: 12px; color: var(--muted); }

/* feed */
.feed { display: grid; gap: 20px; min-width: 0; }
.filters { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; line-height: 1.4; white-space: nowrap;
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer;
}
.chip:hover { border-color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip .n { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.chip[aria-pressed="true"] .n { color: inherit; opacity: .7; }

.post {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 18px 18px 16px; display: grid; gap: 12px; min-width: 0; scroll-margin-top: 24px;
}
@media (max-width: 520px) { .post { padding: 14px 14px 12px; border-radius: 14px; } }
.post__head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.post__who { display: grid; line-height: 1.35; min-width: 0; flex: 1; }
.post__who b { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.post__meta { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 0 6px; }
.job { font: 500 12px/1.5 var(--f-mono); padding: 0 6px; border-radius: 6px; background: var(--sunk); color: var(--ink); }
.pin { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--accent); white-space: nowrap; }
.post__title { font: 600 21px/1.3 var(--f-display); margin: 0; text-wrap: balance; overflow-wrap: anywhere; }
.post__body { margin: 0; white-space: pre-line; overflow-wrap: anywhere; max-width: 68ch; }

.media { display: grid; gap: 4px; border-radius: 12px; overflow: hidden; }
.media--1 { grid-template-columns: minmax(0, 1fr); }
.media--2 { grid-template-columns: 1fr 1fr; aspect-ratio: 16 / 9; }
.media--3 { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; aspect-ratio: 3 / 2; }
.media--3 .cell:first-child { grid-row: span 2; }
.media--4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; aspect-ratio: 5 / 4; }
.media, .cell { max-width: 100%; }
.cell {
  position: relative; display: block; width: 100%; height: 100%; min-height: 0; padding: 0; border: 0; overflow: hidden; cursor: zoom-in;
  background: var(--sunk) center / cover no-repeat;
}
.media--1 .cell { aspect-ratio: 16 / 9; height: auto; }
.cell img, .cell video { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .3s ease; }
.cell img.on, .cell video.on { opacity: 1; }
.cell:hover img.on, .cell:hover video.on { opacity: .94; }
.badge {
  position: absolute; left: 8px; top: 8px; display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600;
  padding: 2px 9px; border-radius: 999px; background: var(--media-scrim); color: var(--on-media);
}
.more { position: absolute; inset: 0; display: grid; place-items: center; background: var(--media-scrim); color: var(--on-media); font: 600 28px var(--f-display); }
.broken::after {
  content: "โหลดไฟล์ไม่ได้"; position: absolute; inset: 0; display: grid; place-items: center;
  background: var(--sunk); color: var(--muted); font-size: 13px;
}

.credits {
  margin: 0; padding-top: 12px; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 18px; font-size: 14px;
}
.credits dt { color: var(--muted); }
.credits dd { margin: 0; overflow-wrap: anywhere; }
.post__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.tags { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tags li { font-size: 12px; color: var(--muted); padding: 1px 9px; border-radius: 999px; background: var(--sunk); }

.empty { border: 1.5px dashed var(--line); border-radius: var(--r); padding: 48px 24px; text-align: center; color: var(--muted); }
.empty h2 { margin: 0 0 4px; font: 600 20px var(--f-display); color: var(--ink); }
.empty p { margin: 0; }

.notice {
  display: grid; gap: 10px; justify-items: start; padding: 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
}
.notice h2 { margin: 0; font: 600 18px/1.35 var(--f-display); }
.notice p, .notice ol { margin: 0; color: var(--muted); }
.notice ol { padding-left: 20px; display: grid; gap: 2px; }
.login { justify-items: stretch; }
.login__row { display: flex; flex-wrap: wrap; gap: 8px; }
.login__row .input { flex: 1 1 200px; }

/* post menu */
.menuwrap { position: relative; flex: none; }
.iconbtn {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; border: 0;
  background: transparent; color: var(--muted); cursor: pointer;
}
.iconbtn:hover { background: var(--sunk); color: var(--ink); }
.iconbtn svg { width: 20px; height: 20px; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 6; min-width: 196px; display: grid; gap: 2px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.menu > button { text-align: left; padding: 9px 12px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; font-size: 14px; }
.menu > button:hover { background: var(--sunk); }
.menu .danger { color: var(--danger); }
.menu__q { margin: 4px 8px 8px; font-size: 14px; font-weight: 500; }
.menu__row { display: flex; gap: 6px; padding: 0 4px 4px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 14px; font-weight: 600; line-height: 1.4;
  padding: 10px 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn--primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn--primary:hover { border-color: var(--ink); filter: brightness(1.15); }
.btn--danger { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.btn--warn { color: var(--danger); border-color: var(--danger); }
.btn--s { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }

.fab {
  position: fixed; z-index: 20; right: calc(20px + env(safe-area-inset-right, 0px)); bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  display: inline-flex; align-items: center; gap: 8px; height: 52px; padding: 0 22px 0 16px; border: 0; border-radius: 999px;
  background: var(--ink); color: var(--bg); font-size: 15px; font-weight: 600; box-shadow: var(--shadow); cursor: pointer;
}
.fab svg { width: 22px; height: 22px; }
.fab:hover { filter: brightness(1.15); }

/* sheet */
.scrim {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: var(--scrim);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.sheet {
  width: min(640px, 100%); max-height: 100%; overflow: auto; overscroll-behavior: contain; display: grid; grid-template-rows: auto 1fr auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
}
.sheet__head {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 14px 14px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.sheet__head h2 { margin: 0; font: 600 18px/1.3 var(--f-display); }
.sheet__body { padding: 18px 20px 22px; display: grid; gap: 16px; align-content: start; }
.sheet__foot {
  position: sticky; bottom: 0; z-index: 2; display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px;
  padding: 12px 20px; background: var(--surface); border-top: 1px solid var(--line);
}
@media (max-width: 560px) {
  .scrim { padding: 0; }
  .sheet { width: 100%; height: 100%; max-height: none; border: 0; border-radius: 0; }
  .sheet__head { padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
  .sheet__foot { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .sheet__head, .sheet__body, .sheet__foot { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
}
.form-err { margin: 0 auto 0 0; color: var(--danger); font-size: 13px; font-weight: 500; }
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field__label { font-size: 13px; font-weight: 500; color: var(--muted); }
.input {
  width: 100%; min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink);
}
.input::placeholder { color: var(--muted); opacity: .7; }
.input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
textarea.input { resize: vertical; min-height: 92px; line-height: 1.6; }
.hint { margin: 0; font-size: 12px; color: var(--muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .row2 { grid-template-columns: minmax(0, 1fr); } }
.field--check { align-content: end; }
.check { display: inline-flex; align-items: center; gap: 8px; padding: 10px 0; cursor: pointer; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.cats { display: flex; flex-wrap: wrap; gap: 6px; }
.cats .chip { padding: 5px 12px; font-size: 13px; }

.drop {
  display: grid; justify-items: center; gap: 2px; padding: 20px 16px; text-align: center; cursor: pointer;
  border: 1.5px dashed var(--line); border-radius: 12px; color: var(--muted); transition: border-color .15s, background-color .15s;
}
.drop svg { width: 28px; height: 28px; margin-bottom: 4px; }
.drop b { color: var(--ink); font-weight: 600; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop.over b, .drop.over { color: var(--accent); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--sunk) center / cover no-repeat; }
.thumb img, .thumb video { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumb__cover { position: absolute; top: 5px; left: 5px; font-size: 11px; font-weight: 600; padding: 0 7px; border-radius: 999px; background: var(--ink); color: var(--bg); }
.thumb__state {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 6px; text-align: center;
  background: var(--scrim); color: var(--ink); font-size: 12px; font-weight: 500; line-height: 1.35;
}
.thumb--err .thumb__state { color: var(--danger); }
.thumb__bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; padding: 5px; }
.thumb__bar button {
  width: 26px; height: 26px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%;
  background: var(--surface); color: var(--ink); cursor: pointer; box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
}
.thumb__bar button svg { width: 14px; height: 14px; }
.thumb__bar button:disabled { opacity: .35; cursor: default; }

.avedit { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.avedit .avatar { width: 72px; font-size: 28px; }
.avedit__acts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cedit { display: grid; gap: 8px; }
.cedit > .btn { justify-self: start; }
.cedit__row { display: grid; grid-template-columns: 1fr 1.2fr 1.6fr auto; gap: 8px; align-items: center; }
@media (max-width: 560px) {
  .cedit__row { grid-template-columns: 1fr 1fr auto; padding-bottom: 8px; border-bottom: 1px dashed var(--line); }
  .cedit__row > :nth-child(3) { grid-column: 1 / 3; }
  .cedit__row > :nth-child(4) { grid-column: 3; grid-row: 1; }
}

/* viewer */
.lb { position: fixed; inset: 0; z-index: 40; display: grid; grid-template-rows: auto minmax(0, 1fr); background: var(--bg); }
.lb__top {
  display: flex; align-items: center; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px));
}
.lb__title { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb__count { font: 500 13px var(--f-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.lb__stage {
  position: relative; min-height: 0; overflow: hidden; touch-action: pan-y;
  margin: 0 max(16px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.lb__stage img, .lb__stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.lb__nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 1; width: 46px; height: 46px; display: grid; place-items: center;
  border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; box-shadow: var(--shadow);
}
.lb__nav svg { width: 22px; height: 22px; }
.lb__prev { left: max(16px, env(safe-area-inset-left, 0px)); }
.lb__next { right: max(16px, env(safe-area-inset-right, 0px)); }

/* toast + saving */
.toast {
  position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 70;
  max-width: calc(100% - 32px); width: max-content; padding: 10px 16px; border-radius: 12px; background: var(--ink); color: var(--bg);
  font-size: 14px; box-shadow: var(--shadow);
}
.saving {
  position: fixed; left: 50%; top: calc(12px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); z-index: 70;
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; background: var(--ink); color: var(--bg); font-size: 13px;
}
.spin { width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
