/* Base */
html,body{margin:0;height:100%}
img{max-width:100%}
/* Layout: one screen, no page scroll. Header (title, live car status, language and admin) on top, then a month calendar beside the selected day's bookings; the calendar rows stretch to fill the height and the day list scrolls inside its own panel. Tall content (admin report) scrolls inside its panel. Very short screens fall back to a normal scrolling page. */
:root{
  --bg:#EEF1F5; --surface:#FFFFFF; --surface-2:#F6F8FA; --ink:#15213A; --muted:#566275; --line:#D6DCE4;
  --accent:#E3970B; --accent-soft:#FBEFD5; --on-accent:#1C1505;
  --road:#33405A; --ok:#1B7F51; --ok-soft:#DCF1E6; --bad:#B53A27; --bad-soft:#FAE2DD;
  --scrim:rgba(15,20,29,.45);
  --font-display:"Barlow Condensed","IBM Plex Sans Thai","Noto Sans SC","Arial Narrow",system-ui,sans-serif;
  --font-body:"IBM Plex Sans","IBM Plex Sans Thai","Noto Sans SC","PingFang SC","Microsoft YaHei",system-ui,-apple-system,"Segoe UI",sans-serif;
  --radius:10px;
  --gap:14px;
  color-scheme:light;
}

*,*::before,*::after{box-sizing:border-box}
[hidden]{display:none!important}
body{background:var(--bg);color:var(--ink);font-family:var(--font-body);font-size:15px;line-height:1.5;-webkit-font-smoothing:antialiased}
body.locked{overflow:hidden}
button{font:inherit}

.wrap{max-width:1320px;margin:0 auto;height:100vh;height:100dvh;overflow:hidden;padding-top:max(14px,env(safe-area-inset-top,0px));padding-bottom:max(14px,env(safe-area-inset-bottom,0px));padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px));display:flex;flex-direction:column;gap:var(--gap)}
@media (min-height:860px){ :root{--gap:18px} .wrap{padding-top:max(20px,env(safe-area-inset-top,0px));padding-bottom:max(20px,env(safe-area-inset-bottom,0px))} }

/* Header: title | live status | language and admin */
.top{flex:none;display:grid;grid-template-columns:minmax(0,1fr) minmax(260px,460px) auto;grid-template-areas:"brand tag bar";align-items:center;gap:10px 20px}
.brand{grid-area:brand;min-width:0}
.eyebrow{margin:0 0 2px;font-family:var(--font-display);font-weight:600;font-size:.82rem;letter-spacing:.16em;text-transform:uppercase;color:var(--muted)}
h1{margin:0;font-family:var(--font-display);font-weight:700;font-size:clamp(1.5rem,1rem + 2vw,2.6rem);line-height:.95;letter-spacing:.01em;text-transform:uppercase;text-wrap:balance}
.lede{display:none;margin:8px 0 0;color:var(--muted);max-width:56ch}
@media (min-height:860px) and (min-width:921px){ .lede{display:block} }

.topbar{grid-area:bar;align-self:start;display:flex;justify-content:flex-end;align-items:center;gap:8px}
.lang{display:inline-flex;background:var(--surface);border:1px solid var(--line);border-radius:999px;padding:3px}
.lang button{font-size:.85rem;font-weight:600;color:var(--muted);background:none;border:0;border-radius:999px;padding:5px 12px;cursor:pointer;line-height:1.4}
.lang button[aria-pressed="true"]{background:var(--ink);color:#FFFFFF}

.tag{grid-area:tag;min-width:0;background:var(--surface);border:1px solid var(--line);border-radius:12px;padding:10px 16px;display:grid;grid-template-columns:auto minmax(0,1fr);grid-template-rows:auto auto;column-gap:16px;align-items:center}
.tag[data-state="out"]{border-color:var(--accent);background:color-mix(in srgb,var(--accent) 6%,var(--surface))}
.tag-label{grid-area:1 / 1;font-family:var(--font-display);font-weight:600;font-size:.74rem;letter-spacing:.16em;text-transform:uppercase;color:var(--muted);white-space:nowrap}
.tag-state{grid-area:2 / 1;font-family:var(--font-display);font-weight:700;font-size:1.45rem;line-height:1.1;display:flex;align-items:center;gap:8px;text-transform:uppercase;letter-spacing:.02em;white-space:nowrap}
.tag-state::before{content:"";flex:none;width:10px;height:10px;border-radius:50%;background:var(--line)}
.tag[data-state="free"] .tag-state::before{background:var(--ok)}
.tag[data-state="out"] .tag-state::before{background:var(--accent);animation:signal 1.1s steps(1,end) infinite}
@keyframes signal{50%{opacity:.2}}
.tag-detail{grid-area:1 / 2;font-weight:500;font-size:.92rem;line-height:1.35;min-width:0;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden}
.tag-next{grid-area:2 / 2;color:var(--muted);font-size:.85rem;line-height:1.35;min-width:0;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden}
.tag-detail,.tag-next{padding-left:16px;border-left:1px solid var(--line)}

.notice{margin:0;background:var(--accent-soft);border-radius:8px;padding:10px 14px;font-size:.92rem}

/* Buttons */
.btn-primary{font-family:var(--font-display);font-weight:700;font-size:1.15rem;letter-spacing:.07em;text-transform:uppercase;background:var(--accent);color:var(--on-accent);border:0;border-radius:8px;padding:9px 18px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:8px;white-space:nowrap}
.btn-primary:hover{filter:brightness(1.06)}
.btn-primary:disabled{opacity:.5;cursor:not-allowed;filter:none}
.btn-primary .plus{font-size:1.4rem;line-height:1;margin-top:-2px}
.btn-plain{font-size:.88rem;font-weight:600;color:var(--ink);background:var(--surface);border:1px solid var(--line);border-radius:8px;padding:7px 12px;cursor:pointer;white-space:nowrap}
.btn-plain:hover{border-color:var(--muted)}
.btn-plain:disabled{opacity:.6;cursor:wait}
.icon-btn{width:38px;height:38px;flex:none;display:inline-grid;place-items:center;font-size:1.2rem;color:var(--ink);background:var(--surface);border:1px solid var(--line);border-radius:8px;cursor:pointer}
.icon-btn:hover{border-color:var(--muted)}
.btn-ghost{font-size:.82rem;font-weight:600;color:var(--muted);background:none;border:1px solid var(--line);border-radius:6px;padding:4px 10px;cursor:pointer;white-space:nowrap}
.btn-ghost:hover{color:var(--ink);border-color:var(--muted)}
.btn-ghost.danger{color:#FFFFFF;background:var(--bad);border-color:var(--bad)}
.btn-ghost:disabled{opacity:.6;cursor:wait}
button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,.cell:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.cell:focus-visible{outline-offset:-2px}

/* Main layout: calendar beside the day panel, filling the rest of the screen */
.main{flex:1 1 0;min-height:0;display:grid;grid-template-columns:minmax(0,1fr) minmax(0,340px);gap:20px}

/* Calendar */
.cal{container:cal / inline-size;min-width:0;min-height:0;display:flex;flex-direction:column;gap:10px}
.cal-bar{flex:none;display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:10px}
.cal-nav{display:flex;align-items:center;gap:8px;min-width:0}
.month{margin:0 6px 0 4px;font-family:var(--font-display);font-weight:700;font-size:1.75rem;letter-spacing:.03em;text-transform:uppercase;line-height:1;white-space:nowrap;min-width:0;overflow:hidden;text-overflow:ellipsis}
.grid-wrap{flex:1 1 0;min-height:0;display:flex;flex-direction:column;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);overflow:hidden}
.dow,.days{display:grid;grid-template-columns:repeat(7,minmax(0,1fr))}
.dow{flex:none}
.days{flex:1 1 0;min-height:0;grid-auto-rows:minmax(0,1fr)}
.dow div{padding:7px 10px;font-family:var(--font-display);font-weight:600;font-size:.85rem;letter-spacing:.12em;text-transform:uppercase;color:var(--muted);border-bottom:1px solid var(--line);white-space:nowrap;overflow:hidden}
.cell{position:relative;min-height:0;min-width:0;overflow:hidden;padding:4px 5px 5px;border-right:1px solid var(--line);border-bottom:1px solid var(--line);display:flex;flex-direction:column;gap:3px;cursor:pointer;background:var(--surface)}
.cell:nth-child(7n){border-right:0}
.days .cell:nth-last-child(-n+7){border-bottom:0}
.cell.weekend{background:var(--surface-2)}
.cell:hover{background:color-mix(in srgb,var(--accent) 7%,var(--surface))}
.cell.other .num{color:var(--muted);opacity:.6}
.cell.other .evs{opacity:.55}
.cell.picked{box-shadow:inset 0 0 0 2px var(--accent)}
.cell-top{flex:none;display:flex;align-items:center;gap:5px;min-width:0}
.num{flex:none;min-width:24px;height:24px;padding:0 6px;border-radius:12px;display:inline-grid;place-items:center;font-weight:600;font-size:.86rem;font-variant-numeric:tabular-nums}
.cell.today .num{background:var(--ink);color:#FFFFFF}
.more{flex:none;font-size:.72rem;font-weight:700;line-height:18px;color:var(--ink);background:var(--accent-soft);border-radius:999px;padding:0 7px;font-variant-numeric:tabular-nums}
.evs{flex:1 1 0;min-height:0;overflow:hidden;display:flex;flex-direction:column;gap:2px;min-width:0}
.ev{flex:none;display:flex;gap:5px;align-items:baseline;min-width:0;padding:0 6px;border-radius:4px;background:var(--road);color:#FFFFFF;font-size:.72rem;line-height:16px;white-space:nowrap;overflow:hidden}
.ev b{font-weight:600;font-variant-numeric:tabular-nums}
.ev span{overflow:hidden;text-overflow:ellipsis}
.ev.live{background:var(--accent);color:var(--on-accent)}
.ev.done{background:var(--line);color:var(--muted)}
.cell-add{position:absolute;top:4px;right:4px;width:26px;height:26px;border-radius:6px;border:1px solid var(--line);background:var(--surface);color:var(--ink);font-size:1rem;line-height:1;cursor:pointer;opacity:0;display:grid;place-items:center}
@media (hover:hover){ .cell:hover .cell-add,.cell-add:focus-visible{opacity:1} }
@media (hover:none){ .cell-add{display:none} }
.cal-foot{flex:none;display:flex;flex-wrap:wrap;gap:4px 16px;font-size:.8rem;line-height:1.3;color:var(--muted)}
.key{display:inline-flex;align-items:center;gap:6px}
.key i{width:14px;height:8px;border-radius:2px;background:var(--road)}
.key i.live{background:var(--accent)}
.key i.done{background:var(--line)}

/* Narrow calendar (phones, small windows): coloured bars instead of text */
@container cal (max-width:560px){
  .dow div{padding:5px 0;text-align:center;font-size:.72rem;letter-spacing:.04em}
  .cell{padding:2px 3px 3px;align-items:center;gap:2px}
  .cell-top{justify-content:center}
  .num{min-width:22px;height:22px;font-size:.78rem;padding:0 4px}
  .evs{width:100%;gap:2px;align-items:stretch}
  .ev{height:4px;padding:0;border-radius:2px}
  .ev b,.ev span{display:none}
  .more{display:none}
}
@container cal (max-width:480px){
  .cal-bar{flex-wrap:nowrap;gap:8px}
  .cal-nav{gap:6px}
  .icon-btn{width:34px;height:34px}
  .month{font-size:1.3rem;margin:0 2px}
  .cal-nav .btn-plain{padding:6px 10px}
  #newBtn{width:40px;height:36px;padding:0;flex:none}
  #newBtn .btn-label{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap}
}

/* Day panel */
.daypanel{min-width:0;min-height:0;overflow:hidden;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:16px;display:flex;flex-direction:column;gap:12px}
.dp-head{flex:none;min-width:0}
.dp-rel{margin:0;font-family:var(--font-display);font-weight:600;font-size:.85rem;letter-spacing:.14em;text-transform:uppercase;color:var(--muted);min-height:1.2em}
.dp-title{margin:0;font-family:var(--font-display);font-weight:700;font-size:1.55rem;line-height:1.05;text-transform:uppercase;letter-spacing:.02em;text-wrap:balance}
.daypanel .day{flex:none}
.daypanel .list-msg{flex:none}
.dp-list{flex:1 1 0;min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;margin:0 -10px;padding:0 10px}
#dayBookBtn{flex:none}
.dp-rows{list-style:none;margin:0;padding:0;display:flex;flex-direction:column}
.row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:4px 12px;padding:11px 0;border-top:1px solid var(--line)}
.row:first-child{border-top:0;padding-top:2px}
.row.live{background:var(--accent-soft);margin:0 -10px;padding-left:10px;padding-right:10px;padding-top:10px;border-radius:8px}
.row.live + .row{border-top-color:transparent}
.row.done .t,.row.done .name{color:var(--muted)}
.when{grid-column:1 / -1;grid-row:1;min-width:0}
.body{grid-column:1 / -1;grid-row:2;min-width:0}
.act{grid-column:1 / -1;grid-row:3;display:flex;flex-wrap:wrap;gap:6px;justify-content:flex-start;align-items:center;margin-top:4px}
.act:empty{display:none}
.t{font-family:var(--font-display);font-weight:600;font-size:1.3rem;line-height:1.1;font-variant-numeric:tabular-nums;white-space:nowrap}
.dur{display:block;font-size:.78rem;color:var(--muted)}
.who{margin:0;display:flex;flex-wrap:wrap;gap:2px 10px;align-items:baseline}
.name{font-weight:600;overflow-wrap:anywhere}
.dept{font-size:.75rem;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.07em}
.purpose{margin:2px 0 0;overflow-wrap:anywhere}
.chip{font-size:.7rem;font-weight:600;letter-spacing:.05em;text-transform:uppercase;padding:3px 8px;border-radius:999px;white-space:nowrap}
.chip.live{background:var(--accent);color:var(--on-accent)}
.chip.done{color:var(--muted);border:1px solid var(--line)}
.chip.mine{background:var(--ok-soft);color:var(--ok)}
.dp-empty{margin:0;padding:16px 12px;border:1px dashed var(--line);border-radius:8px;text-align:center;color:var(--muted)}
.list-msg{margin:0;color:var(--bad);font-weight:500;font-size:.9rem}

/* Day timeline */
.track{position:relative;height:34px;border-radius:6px;border:1px solid var(--line);background-color:var(--surface-2);background-image:repeating-linear-gradient(90deg,var(--line) 0 12px,transparent 12px 22px);background-size:100% 2px;background-position:0 50%;background-repeat:no-repeat;overflow:hidden}
.blk{position:absolute;top:5px;bottom:5px;background:var(--road);color:#FFFFFF;border-radius:4px;font-size:.68rem;font-weight:600;display:flex;align-items:center;padding:0 4px;overflow:hidden;white-space:nowrap;font-variant-numeric:tabular-nums}
.sel{position:absolute;top:2px;bottom:2px;border:2px solid var(--accent);background:color-mix(in srgb,var(--accent) 24%,transparent);border-radius:5px}
.sel.clash{border-color:var(--bad);background:color-mix(in srgb,var(--bad) 24%,transparent)}
.now{position:absolute;top:0;bottom:0;width:2px;margin-left:-1px;background:var(--accent)}
.ticks{position:relative;height:16px;font-size:.68rem;color:var(--muted);font-variant-numeric:tabular-nums}
.ticks span{position:absolute;top:0;transform:translateX(-50%)}
.ticks span:first-child{transform:none}
.ticks span:last-child{transform:translateX(-100%)}

/* Booking pop-up */
.overlay{position:fixed;inset:0;z-index:20;background:var(--scrim);display:grid;place-items:center;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));overflow-y:auto;overscroll-behavior:contain}
.sheet{width:100%;max-width:470px;background:var(--surface);border:1px solid var(--line);border-radius:14px;padding:20px;box-shadow:0 24px 60px rgba(15,20,29,.22)}
.sheet-head{display:flex;align-items:center;justify-content:space-between;gap:12px}
.sheet h2{margin:0;font-family:var(--font-display);font-weight:700;font-size:1.55rem;letter-spacing:.03em;text-transform:uppercase}
form{display:flex;flex-direction:column;gap:14px;margin-top:14px}
.three{display:grid;grid-template-columns:minmax(0,1.4fr) minmax(0,1fr) minmax(0,1fr);gap:12px}
.field{display:flex;flex-direction:column;gap:5px;min-width:0}
.field > span{font-size:.8rem;font-weight:600;color:var(--muted);letter-spacing:.02em}
input,textarea{font:inherit;color:var(--ink);background:var(--surface-2);border:1px solid var(--line);border-radius:8px;padding:9px 11px;width:100%;min-width:0;min-height:42px}
input[type="date"],input[type="time"]{-webkit-appearance:none;appearance:none;display:block;font-variant-numeric:tabular-nums}
input::-webkit-date-and-time-value{text-align:left}
select{font:inherit;color:var(--ink);background-color:var(--surface-2);border:1px solid var(--line);border-radius:8px;padding:9px 34px 9px 11px;width:100%;min-width:0;min-height:42px;-webkit-appearance:none;appearance:none;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23566275' stroke-width='2'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 12px center;background-size:12px 8px;cursor:pointer;text-overflow:ellipsis}
select:invalid{color:var(--muted)}
select option{color:var(--ink)}
textarea{resize:vertical;min-height:74px}
.day{display:flex;flex-direction:column;gap:6px}
.day-head{display:flex;justify-content:space-between;flex-wrap:wrap;gap:4px 8px;font-size:.8rem;font-weight:600;color:var(--muted)}
.hint{margin:0;font-size:.85rem;font-weight:500}
.hint.ok{color:var(--ok)}
.hint.bad{color:var(--bad)}
.msg{margin:0;min-height:1.4em;font-weight:500}
.msg.bad{color:var(--bad)}
form .btn-primary{padding:12px 16px;font-size:1.2rem}
@media (max-height:700px){
  .sheet{padding:16px 18px}
  form{gap:10px;margin-top:10px}
}

.toast{position:fixed;left:50%;bottom:calc(20px + env(safe-area-inset-bottom,0px));transform:translateX(-50%);z-index:30;max-width:calc(100% - 32px);background:var(--ink);color:#FFFFFF;padding:10px 16px;border-radius:8px;font-weight:500;box-shadow:0 10px 30px rgba(15,20,29,.2)}

/* Admin report: header fixed, report body scrolls inside */
.admin{flex:1 1 0;min-height:0;display:flex;flex-direction:column;gap:12px;min-width:0}
.admin > *{flex:none}
.ad-head{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:space-between;gap:12px}
.ad-title{margin:0;font-family:var(--font-display);font-weight:700;font-size:2rem;line-height:1;text-transform:uppercase;letter-spacing:.02em}
.ad-tools{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
.ad-tools .month{min-width:9ch;text-align:center;margin:0 4px}
.admin > .ad-scroll{flex:1 1 0;min-height:0;overflow-y:auto;overscroll-behavior:contain;display:flex;flex-direction:column;gap:16px;padding-bottom:2px}
.ad-scroll > *{flex:none}
.stats{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}
.stat{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:12px 16px;min-width:0}
.stat span{display:block;font-size:.8rem;font-weight:600;color:var(--muted)}
.stat strong{display:block;margin-top:2px;font-family:var(--font-display);font-weight:700;font-size:2rem;line-height:1.1;font-variant-numeric:tabular-nums;overflow-wrap:anywhere}
.stat strong.txt{font-size:1.4rem;line-height:1.25}
.ad-grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:16px}
.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:16px 18px;min-width:0}
.card h3{margin:0 0 10px;font-family:var(--font-display);font-weight:700;font-size:1.25rem;text-transform:uppercase;letter-spacing:.04em}
.card h4{margin:16px 0 2px;font-size:.95rem}
.tbl-wrap{overflow-x:auto}
table{width:100%;border-collapse:collapse;font-size:.9rem}
th{text-align:left;font-size:.74rem;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.05em;padding:6px 12px 6px 0;border-bottom:1px solid var(--line);white-space:nowrap}
td{padding:8px 12px 8px 0;border-bottom:1px solid var(--line);vertical-align:top}
tbody tr:last-child td{border-bottom:0}
th.n,td.n{text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
td.nw{white-space:nowrap;font-variant-numeric:tabular-nums}
td.w{min-width:200px;overflow-wrap:anywhere}
tfoot td{font-weight:600;border-top:1px solid var(--line);border-bottom:0}
.muted{color:var(--muted);margin:0;font-size:.9rem}
.plist{list-style:none;margin:0;padding:0;display:flex;flex-direction:column}
.plist li{display:flex;justify-content:space-between;align-items:center;gap:10px;padding:9px 0;border-top:1px solid var(--line)}
.plist li:first-child{border-top:0}
.pn{min-width:0;overflow-wrap:anywhere;font-weight:500}
.pd{color:var(--muted);font-size:.85rem;font-weight:400}

/* Mid widths: smaller day panel */
@media (max-width:1100px){
  .main{grid-template-columns:minmax(0,1fr) minmax(0,300px);gap:16px}
}

/* Tablet: title and buttons on one row, status underneath */
@media (max-width:920px){
  .top{grid-template-columns:minmax(0,1fr) auto;grid-template-areas:"brand bar" "tag tag"}
  .top .eyebrow,.tag-label{display:none}
  .tag-state{grid-area:1 / 1 / 3 / 2}
  .ad-grid{grid-template-columns:minmax(0,1fr)}
}

/* Portrait tablets and phones: calendar on top, a fixed-height day panel below it */
@media (max-width:920px) and (orientation:portrait), (max-width:640px){
  .main{display:flex;flex-direction:column;gap:12px}
  .cal{flex:1 1 0}
  .daypanel{flex:none;height:clamp(170px,30dvh,280px);display:grid;grid-template-columns:minmax(0,1fr) auto;grid-template-rows:auto auto minmax(0,1fr);align-content:stretch;gap:8px 12px;padding:12px 14px}
  .dp-head{grid-area:1 / 1;align-self:center;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden}
  .dp-rel,.dp-title{display:inline}
  .dp-rel{margin-right:8px;min-height:0}
  .dp-title{font-size:1.2rem}
  #dayBookBtn{grid-area:1 / 2;align-self:center;font-size:1rem;padding:7px 12px}
  #dayBookBtn .plus{font-size:1.15rem}
  .daypanel .day{display:none}
  .daypanel .list-msg{grid-area:2 / 1 / 3 / -1}
  .dp-list{grid-area:3 / 1 / 4 / -1}
  .t{font-size:1.15rem}
  .row{padding:8px 0}
}

@media (max-width:720px){ .stats{grid-template-columns:repeat(2,minmax(0,1fr))} }

/* Phones: language and admin on top, then title, then status */
@media (max-width:640px){
  :root{--gap:10px}
  .wrap{padding-top:max(10px,env(safe-area-inset-top,0px));padding-bottom:max(10px,env(safe-area-inset-bottom,0px))}
  .top{grid-template-columns:minmax(0,1fr);grid-template-areas:"bar" "brand" "tag";gap:8px}
  .topbar{justify-content:space-between}
  .lang button{padding:4px 10px}
  .tag{padding:8px 12px;column-gap:12px}
  .tag-state{font-size:1.25rem}
  .tag-detail,.tag-next{padding-left:12px}
  .tag-next{-webkit-line-clamp:1}
  .overlay{place-items:end stretch;padding:max(24px,env(safe-area-inset-top,0px)) 0 0}
  .sheet{max-width:none;border-radius:16px 16px 0 0;border-bottom:0;padding:18px max(16px,env(safe-area-inset-right,0px)) calc(18px + env(safe-area-inset-bottom,0px)) max(16px,env(safe-area-inset-left,0px))}
  .ad-title{font-size:1.6rem}
}
@media (max-width:640px) and (max-height:719px){ .brand,.cal-foot{display:none} }
@media (max-width:360px){ .three{grid-template-columns:1fr 1fr} .three > :first-child{grid-column:1 / -1} .lang button{padding:4px 8px} }
@media (prefers-reduced-motion:reduce){ .tag[data-state="out"] .tag-state::before{animation:none} }

/* Screens too short to fit everything (landscape phones, tiny windows): fall back to a normal scrolling page */
@media (max-height:539px), (max-width:920px) and (orientation:portrait) and (max-height:599px){
  .wrap{height:auto;min-height:100dvh;overflow:visible}
  .main{flex:none}
  .cal{flex:none}
  .grid-wrap,.days{flex:none}
  .days{grid-auto-rows:minmax(58px,auto)}
  .evs{flex:none;overflow:visible}
  .daypanel{height:auto;max-height:none}
  .dp-list{flex:none;overflow:visible}
  .admin,.admin > .ad-scroll{flex:none;overflow:visible}
  .brand{display:block}
  .cal-foot{display:flex}
}

/* Thai and Chinese: no letter-spacing, taller lines so marks and characters are not clipped */
html[lang="th"] *,html[lang="zh"] *{letter-spacing:0!important}
html[lang="th"] h1,html[lang="th"] .dp-title,html[lang="th"] .month,html[lang="th"] .tag-state,html[lang="th"] .sheet h2,html[lang="th"] .ad-title,html[lang="th"] .btn-primary,html[lang="th"] .stat strong{line-height:1.4}
html[lang="th"] .t{line-height:1.2}
html[lang="zh"] h1,html[lang="zh"] .dp-title,html[lang="zh"] .month,html[lang="zh"] .tag-state,html[lang="zh"] .sheet h2,html[lang="zh"] .ad-title{line-height:1.25}
html[lang="th"] h1{font-size:clamp(1.4rem,.9rem + 1.8vw,2.3rem)}
html[lang="zh"] h1{font-size:clamp(1.4rem,.9rem + 1.8vw,2.2rem)}

/* Admin: text for the car group */
.share-head{display:flex;flex-wrap:wrap;align-items:center;gap:10px 12px;margin-bottom:12px}
.card .share-head h3{margin:0;flex:1 1 auto}
.seg{display:inline-flex;background:var(--surface-2);border:1px solid var(--line);border-radius:999px;padding:3px}
.seg button{font-size:.85rem;font-weight:600;color:var(--muted);background:none;border:0;border-radius:999px;padding:5px 12px;cursor:pointer;line-height:1.4;white-space:nowrap}
.seg button[aria-pressed="true"]{background:var(--ink);color:#FFFFFF}
#copyBtn{font-size:1rem;padding:8px 16px}
.share-text{display:block;min-height:150px;font-size:.9rem;line-height:1.55;resize:vertical;white-space:pre-wrap}

/* Admin PIN dialog and small print */
.pin-sheet{max-width:360px}
.pin-input{font-size:1.5rem;letter-spacing:.4em;text-align:center;font-variant-numeric:tabular-nums}
.fine{margin:0;font-size:.82rem;color:var(--muted)}
