/* YSG Hub — สไตล์อ้างอิง fastwork.com ตัวใหม่: แถบไอคอนซ้าย + แผงขาวมุมโค้ง + ปุ่มดำทรงเม็ดยา */
:root {
  --bg: #f5f5f5;
  --panel: #ffffff;
  --ink: #171717;
  --head: #2b313b;
  --muted: #737373;
  --line: #ececec;
  --soft: #f5f5f5;
  --dark: #232323;
  --red: #d4332b;
  --amber: #c27803;
  --green: #1f8f5a;
  --blue: #2563eb;
  --radius: 20px;
  --radius-lg: 24px;
  --shadow: 0 2px 12px rgba(0, 0, 0, .07);
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0; color: var(--ink); background: var(--bg);
  font-family: "Google Sans", "Figtree", "Noto Sans Thai", "Leelawadee UI", system-ui, sans-serif;
  font-size: 16px; line-height: 1.55; -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- โครงหน้า ---------- */
.shell { display: grid; grid-template-columns: 80px minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; padding: 16px 0; display: flex; flex-direction: column; align-items: center; gap: 4px;
  overflow-y: auto; scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail .grow { flex: 1; }
.rail .logo { width: 44px; height: 44px; display: grid; place-items: center; margin-bottom: 10px; color: var(--ink); }
.rail a.item, .rail button.item {
  width: 64px; padding: 9px 0 7px; border-radius: 16px; border: 0; background: transparent; cursor: pointer; text-decoration: none;
  display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; color: #5c5c5c; position: relative;
}
.rail .item:hover { background: rgba(0, 0, 0, .04); }
.rail .item.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.rail .item svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.rail .item .emo { font-size: 20px; line-height: 22px; height: 22px; }
.rail .item .lbl { max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail .badge {
  position: absolute; top: 3px; right: 9px; min-width: 17px; height: 17px; padding: 0 5px; border-radius: 99px;
  background: var(--dark); color: #fff; font-size: 10px; display: grid; place-items: center; font-weight: 600;
}
.rail .sep { width: 28px; height: 1px; background: #dcdcdc; margin: 8px 0; }

.panel {
  background: var(--panel); margin: 6px 6px 6px 0; border-radius: var(--radius); min-width: 0;
  padding: 44px clamp(18px, 4vw, 64px) 36px; min-height: calc(100vh - 12px); display: flex; flex-direction: column;
}
.panel > .body { flex: 1; width: 100%; max-width: 1040px; margin: 0 auto; }
.panel > footer { max-width: 1040px; width: 100%; margin: 56px auto 0; padding-top: 22px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; display: flex; gap: 16px; justify-content: space-between; flex-wrap: wrap; }

@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; top: auto; height: auto; flex-direction: row; justify-content: flex-start;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: rgba(245, 245, 245, .96); backdrop-filter: blur(8px);
    overflow-x: auto; overflow-y: hidden; border-top: 1px solid #e3e3e3; gap: 2px;
  }
  .rail .logo, .rail .sep, .rail .grow { display: none; }
  .rail a.item, .rail button.item { flex: 0 0 auto; width: 62px; }
  .panel { margin: 6px 6px 78px; padding: 28px 16px 24px; min-height: 0; }
}

/* ---------- ตัวอักษรและปุ่ม ---------- */
h1.big { margin: 0; font-size: clamp(26px, 4vw, 32px); font-weight: 500; color: var(--head); text-align: center; letter-spacing: -.01em; }
h2.sec { margin: 40px 0 14px; font-size: 20px; font-weight: 600; color: var(--head); }
.lead { text-align: center; color: var(--muted); margin: 8px auto 0; max-width: 560px; }
.muted { color: var(--muted); font-size: 14px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; cursor: pointer; text-decoration: none;
  background: var(--dark); color: #fff; padding: 12px 24px; border-radius: 99px; font-weight: 700; transition: transform .12s, opacity .12s;
}
.btn:hover { opacity: .88; transform: translateY(-1px); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid #dedede; font-weight: 500; }
.btn.soft { background: var(--soft); color: var(--ink); font-weight: 500; }
.btn.small { padding: 7px 16px; font-size: 14px; }
.btn.block { width: 100%; }
.btn.disabled { background: #e4e4e4; color: #999; pointer-events: none; }
.link { color: var(--muted); font-size: 14px; text-decoration: none; display: inline-flex; gap: 4px; align-items: center; }
.link:hover { color: var(--ink); }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--soft); color: #444; white-space: nowrap; }
.chip.blocking { background: #fdecea; color: var(--red); }
.chip.annoying { background: #fff3dc; color: var(--amber); }
.chip.idea { background: #e8f1ff; color: var(--blue); }
.chip.new { background: #232323; color: #fff; }
.chip.working { background: #fff3dc; color: var(--amber); }
.chip.fixed { background: #e6f6ee; color: var(--green); }
.chip.wontfix { background: #ececec; color: #777; }
.chip.m-light { background: #e6f6ee; color: var(--green); }
.chip.m-standard { background: #e8f1ff; color: var(--blue); }
.chip.m-deep { background: #f0eafd; color: #6a4bd8; }
.chip.m-none { background: #f1f1f1; color: #8a8a8a; }

/* ---------- การ์ด ---------- */
.card { background: #fff; border: 1px solid #f0f0f0; border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 22px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.app {
  display: flex; flex-direction: column; gap: 14px; padding: 22px; text-decoration: none; transition: transform .15s, box-shadow .15s;
}
.app:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0, 0, 0, .1); }
.app .icon { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; font-size: 28px; background: var(--soft); }
.app h3 { margin: 0; font-size: 18px; font-weight: 600; color: var(--head); }
.app p { margin: 0; color: var(--muted); font-size: 14px; }
.app .row { display: flex; gap: 8px; margin-top: auto; align-items: center; flex-wrap: wrap; }

/* ---------- ฟอร์ม ---------- */
label.f { display: block; font-weight: 600; margin: 18px 0 6px; font-size: 15px; }
label.f small { font-weight: 400; color: var(--muted); }
input[type=text], select, textarea {
  width: 100%; padding: 12px 16px; border: 1px solid transparent; border-radius: 14px; background: var(--soft);
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--dark); outline-offset: 1px; background: #fff; }
.choices { display: grid; gap: 8px; }
.choices label { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 14px; background: var(--soft); cursor: pointer; }
.choices input { accent-color: var(--dark); }
.hp { position: absolute; left: -9999px; height: 0; overflow: hidden; }
.shot-preview { max-width: 100%; max-height: 220px; border-radius: 14px; margin-top: 10px; }
.msg { padding: 12px 16px; border-radius: 14px; margin-top: 16px; }
.msg.err { background: #fdecea; color: var(--red); }
.msg.ok { background: #e6f6ee; color: var(--green); }
.narrow { max-width: 560px; margin: 28px auto 0; }

/* ---------- พื้นที่ทำงาน ---------- */
.capture { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; background: var(--soft); border-radius: 22px; padding: 8px; margin: 26px auto 0; max-width: 820px; }
.capture select { width: auto; background: #fff; border-radius: 99px; padding: 10px 14px; }
.capture input[type=text] { flex: 1 1 220px; background: #fff; border-radius: 99px; padding: 11px 18px; }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-top: 28px; }
.stat { text-align: left; }
.stat b { display: block; font-size: 32px; font-weight: 600; color: var(--head); line-height: 1.1; }
.stat span { color: var(--muted); font-size: 14px; }
.appbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.appbar .icon { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; font-size: 32px; background: var(--soft); }
.appbar h1 { margin: 0; font-size: 28px; font-weight: 500; color: var(--head); }
.tabs { display: flex; gap: 6px; margin: 26px 0 22px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 16px; cursor: pointer; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--ink); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.fact small { display: block; color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.fact div { word-break: break-all; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filters button { border: 0; background: var(--soft); padding: 7px 16px; border-radius: 99px; cursor: pointer; font-weight: 500; font-size: 14px; }
.filters button.on { background: var(--dark); color: #fff; }
.tk { padding: 0; overflow: hidden; margin-bottom: 12px; }
.tk .top { display: flex; gap: 10px; align-items: center; padding: 16px 20px; cursor: pointer; flex-wrap: wrap; }
.tk .top .t { flex: 1 1 240px; min-width: 0; font-weight: 500; overflow-wrap: anywhere; }
.tk .top .no { color: var(--muted); font-size: 13px; }
.tk .more { padding: 4px 20px 20px; border-top: 1px solid var(--line); }
.tk .desc { white-space: pre-wrap; overflow-wrap: anywhere; margin: 14px 0 6px; }
.tk .det { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.tk .edit { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-top: 16px; }
.tk .edit .wide { grid-column: 1 / -1; }
.tk .edit textarea { min-height: 70px; }
.tk .edit label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 4px; }
.tk img.thumb { max-width: 180px; border-radius: 12px; margin-top: 10px; cursor: zoom-in; }

/* สำรับการ์ด "ล่าสุดที่แก้" */
.deck { position: relative; height: 360px; max-width: 760px; margin: 12px auto 0; overflow: hidden; }
.deck .dc { position: absolute; top: 0; width: 300px; height: 330px; border-radius: 26px; background: #fff; box-shadow: 0 6px 26px rgba(0, 0, 0, .1); border: 1px solid #f0f0f0; padding: 22px; display: flex; flex-direction: column; gap: 10px; transform-origin: left top; }
.deck .dc .date { align-self: flex-start; background: var(--soft); border-radius: 12px; padding: 4px 12px; font-size: 12px; font-weight: 700; line-height: 1.2; text-align: center; }
.deck .dc h4 { margin: auto 0 0; font-size: 18px; font-weight: 600; color: var(--head); overflow-wrap: anywhere; }
.deck .dc p { margin: 0; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.deck .dc.first { z-index: 10; }
.deck .dc .art { flex: 1; display: grid; place-items: center; font-size: 64px; }

.applist { display: grid; gap: 10px; }
.applist a { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: 18px; background: var(--soft); text-decoration: none; }
.applist a:hover { background: #ececec; }
.applist .nm { flex: 1; font-weight: 600; }

/* ---------- แผนผัง ---------- */
.diagram { overflow-x: auto; padding: 4px; }
.diagram svg { display: block; width: 100%; min-width: 760px; height: auto; font-family: inherit; }
.diagram .band { fill: #f8f8f8; }
.diagram .layer-lbl { font-size: 12px; fill: #8a8a8a; font-weight: 600; letter-spacing: .02em; }
.diagram .n-title { font-size: 15px; font-weight: 700; fill: #232323; }
.diagram .n-sub { font-size: 12px; fill: #6b6b6b; }
.diagram .edge { fill: none; stroke: #b9b9b9; stroke-width: 1.6; stroke-dasharray: 5 5; animation: dash 1.4s linear infinite; }
.diagram .e-lbl { font-size: 11px; fill: #555; }
@keyframes dash { to { stroke-dashoffset: -20; } }
@media (prefers-reduced-motion: reduce) { .diagram .edge { animation: none; } }
.flow { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; counter-reset: s; }
.flow .st { position: relative; padding: 20px 18px 18px; border-radius: 20px; background: var(--soft); }
.flow .st::before { counter-increment: s; content: counter(s); position: absolute; top: -12px; left: 16px; width: 26px; height: 26px; border-radius: 99px; background: var(--dark); color: #fff; font-size: 13px; font-weight: 700; display: grid; place-items: center; }
.flow .st b { display: block; margin-bottom: 2px; }
.flow .st .who { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.flow .st p { margin: 0; font-size: 14px; color: #444; }
.tables { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.tables .grp { border-radius: 20px; padding: 16px 18px; }
.tables .grp h5 { margin: 0 0 10px; font-size: 14px; font-weight: 700; }
.tables .tb { display: flex; gap: 8px; align-items: baseline; padding: 5px 0; border-top: 1px dashed rgba(0, 0, 0, .1); font-size: 13px; }
.tables .tb code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-weight: 600; font-size: 12px; background: rgba(255, 255, 255, .7); padding: 1px 7px; border-radius: 8px; }
.tables .tb span { color: #555; }
.tone-blue { background: #e9f1ff; } .tone-green { background: #e6f6ee; } .tone-amber { background: #fff3dc; }
.tone-purple { background: #f0eafd; } .tone-slate { background: #eef0f3; } .tone-rose { background: #fdebee; }

.deck { width: 860px; max-width: 100%; }
.deck .dc:not(.first) .date { position: absolute; right: 10px; top: 16px; padding: 4px 8px; }
.deck .dc:not(.first) > :not(.date) { display: none; }
.deck .empty { position: static; width: auto; height: auto; text-align: center; color: var(--muted); padding: 60px 0; }
@media (max-width: 720px) {
  .deck { height: auto; overflow: visible; }
  .deck .dc { position: relative; left: 0 !important; top: 0 !important; transform: none !important; width: 100%; height: auto; min-height: 220px; }
  .deck .dc:not(.first) { display: none; }
}
.tk.on-top { box-shadow: 0 6px 22px rgba(0,0,0,.1); }
.rowx { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; }

.rail .logo svg { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
