html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow-x: hidden; }
img, svg { max-width: 100%; }

#app { height: 100vh; height: 100dvh; }

.cards { grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); }
.f2    { grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); }
.stats { grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); }

@media (min-width: 1500px) {
  #app { max-width: 1560px; }
  body { font-size: 16px; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
  .workspace { grid-template-columns: 240px minmax(0, 1fr); }
}

@media (hover: none) {
  button:hover { transform: none; box-shadow: none; filter: none; }
  .nav-button:hover, .logout-button:hover { transform: none; }
  .st:hover, .book:hover { transform: none; border-color: var(--bd); }
  .cbox:hover { transform: none; }
  .quick a:hover { transform: none; }
  .seat:not(:disabled):hover { transform: none; }
}

@media (pointer: coarse) {
  input, select { font-size: 16px; }
  button:not(.password-toggle):not(.linkbtn):not(.auth-link) { min-height: 44px; }
  .nav-button, .logout-button { min-height: 46px; }
  .seat { min-height: 50px; }
  .terms summary { padding: 4px 0; }
}

@media (min-width: 601px) and (max-width: 900px) {
  .workspace { grid-template-columns: 180px minmax(0, 1fr); gap: 10px; }
  .sidebar { padding: 12px 9px; }
  .nav-button, .logout-button { padding: 9px 10px; gap: 8px; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); }
  .st b { font-size: 30px; }
}

@media (min-width: 701px) and (max-width: 900px) {
  .form-pane { padding: 20px 3.5vw; }
  .ov-text { padding: 0 14px; }
  .ov-text h2 { font-size: 24px; }
  .ov-text p { font-size: 14px; }
  .auth .ov-text .lgx { width: 76px; height: 76px; }
  .ov-text button.ghost { padding: 8px 26px; }
  .auth-form-title { font-size: 26px; }
}

@media (max-width: 600px) {
  .brand small { font-size: 10px; }

  .sidebar { flex-direction: row; align-items: center; gap: 6px; padding: 8px; }
  .sidebar nav { flex: 1; min-width: 0; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .sidebar nav::-webkit-scrollbar { display: none; }
  .nav-button { flex: none; }
  .logout-button {
    flex: none; width: 44px; min-width: 44px; padding: 0;
    justify-content: center; align-self: center;
  }
  .logout-button .nav-label { display: none; }

  .hdr .lgx { width: 64px; height: 64px; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stats > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .st b { font-size: 28px; }

  .f2 { grid-template-columns: 1fr; }
  .row.nowrap { flex-wrap: wrap; }
  .row.nowrap > .fixed { width: 100%; }
  .book .row > button { min-width: 0; }

  .cards { max-height: none; overflow: visible; padding: 0; }

  table { min-width: 560px; }
  th, td { padding: 8px 10px; font-size: 13px; }

  .seats { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; }

  .auth { margin: 16px auto; }
  .form-pane { padding: 20px 16px; }
  .auth-form-title { font-size: 26px; }
  .hero h1 { font-size: 28px; }
}

@media (max-width: 400px) {
  #app { padding: 6px; }
  .brand small { display: none; }
  .pad { padding: 12px; }
  h2 { font-size: 20px; }
  .st b { font-size: 24px; }
  .nav-button { padding: 7px 9px; font-size: 13px; }
  .hdr p { font-size: 13px; }
}

@media (max-height: 520px) and (min-width: 601px) {
  .top { min-height: 48px; padding: 4px 12px; }
  .lg { width: 34px; height: 34px; }
  .brand { font-size: 18px; }
  .brand small { display: none; }
  .theme-button { width: 36px; height: 36px; padding: 7px; }
  .sidebar { padding: 8px; gap: 6px; }
  .user-tag { display: none; }
  .nav-button, .logout-button { min-height: 38px; padding: 5px 10px; }
  h2 { font-size: 21px; margin-bottom: 8px; }
  .hdr { padding: 12px; }
  .hdr .lgx { width: 56px; height: 56px; }
}

@media (max-height: 560px) and (min-width: 701px) {
  .form-pane { padding: 10px 5vw; }
  .form-pane form { gap: 8px; }
  .auth-form-title { font-size: 22px; margin-bottom: 8px; }
  .auth-card input:not([type="checkbox"]), .auth-card select { padding-top: 9px; padding-bottom: 9px; }
  .ov-text .lgx, .auth .ov-text .lgx { display: none; }
  .ov-text h2 { font-size: 24px; margin-top: 0; }
  .or { margin: 10px 0 6px; }
}

@media (max-width: 700px) and (orientation: landscape) {
  .auth { width: min(100%, 560px); }
}

@media (max-width: 340px) {
  .stats { grid-template-columns: 1fr; }
  .seats { grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); }
  .toast { font-size: 13px; }
}

@media (max-width: 700px) {
  .slider.m-swap { overflow: hidden; transition: height .4s var(--ease); }

  .form-pane.out-left  { animation: paneOutL .22s ease-in both; }
  .form-pane.out-right { animation: paneOutR .22s ease-in both; }
  .form-pane.in-right  { animation: paneInR .4s var(--ease) both; }
  .form-pane.in-left   { animation: paneInL .4s var(--ease) both; }
}
@keyframes paneOutL { to   { opacity: 0; transform: translateX(-32px); } }
@keyframes paneOutR { to   { opacity: 0; transform: translateX(32px); } }
@keyframes paneInR  { from { opacity: 0; transform: translateX(32px); } to { opacity: 1; transform: none; } }
@keyframes paneInL  { from { opacity: 0; transform: translateX(-32px); } to { opacity: 1; transform: none; } }

@media (min-width: 601px) and (max-width: 1100px) and (orientation: portrait) {
  #app { padding: 10px; }

  .workspace { display: flex; flex-direction: column; gap: 10px; }
  .sidebar {
    flex: none; flex-direction: row; align-items: center;
    gap: 8px; padding: 8px 10px; border-radius: 22px;
  }
  .user-tag { flex: none; align-self: center; }

  .sidebar nav {
    flex: 1; min-width: 0; flex-direction: row; gap: 4px;
    padding: 3px 2px; overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .sidebar nav::-webkit-scrollbar { display: none; }

  .nav-button {
    flex: 1 1 auto; width: auto; min-width: max-content;
    justify-content: center; gap: 6px; padding: 8px 10px; min-height: 44px;
  }
  .nav-button:hover  { transform: translateY(-2px); }
  .nav-button:active { transform: scale(.96); }
  .logout-button {
    flex: none; width: auto; margin-top: 0;
    padding: 8px 14px; min-height: 44px;
  }

  .maincontent { flex: 1 1 0; min-height: 0; }

  .stats { grid-template-columns: repeat(auto-fit, minmax(min(130px, 100%), 1fr)); }
  .st b  { font-size: clamp(24px, 3.4vw, 30px); }

  table { min-width: 520px; }
  th, td { padding: 9px 10px; }

  .cards { grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); }
}

@media (min-width: 601px) and (max-width: 760px) and (orientation: portrait) {
  .stats:has(> :nth-child(5)) { grid-template-columns: repeat(6, 1fr); }
  .stats:has(> :nth-child(5)) > * { grid-column: span 2; }
  .stats:has(> :nth-child(5)) > :nth-child(n+4) { grid-column: span 3; }
}

@media (min-width: 601px) and (max-width: 860px) and (orientation: portrait) {
  .user-tag { display: none; }
  .sidebar { gap: 6px; padding: 6px 8px; }
  .sidebar nav { gap: 2px; }
  .nav-button {
    flex: 1 1 0; min-width: 0; flex-direction: column; justify-content: center;
    gap: 3px; padding: 6px 4px; min-height: 54px; font-size: 12px; text-align: center;
  }
  .nav-icon { width: auto; font-size: 18px; }
  .nav-label { white-space: nowrap; }
  .logout-button { width: 54px; min-width: 54px; min-height: 54px; padding: 0; justify-content: center; }
  .logout-button .nav-label { display: none; }
}

@media (min-width: 601px) and (max-width: 1100px) and (orientation: portrait) {
  .user-tag { display: none; }
}
@media (min-width: 861px) and (max-width: 1100px) and (orientation: portrait) {
  .logout-button { width: 54px; min-width: 54px; padding: 0; justify-content: center; }
  .logout-button .nav-label { display: none; }
  .nav-button { padding: 8px 9px; font-size: 13px; }
}

@media (min-width: 861px) {
  .stats:has(> :nth-child(5):last-child) {
    grid-template-columns: repeat(auto-fit, minmax(min(130px, 100%), 1fr));
  }
  .stats:has(> :nth-child(5):last-child) .st b { font-size: clamp(26px, 2.8vw, 34px); }
}

.lo-back {
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.lo-card { margin: auto; }
.lo-card p b { color: var(--tx); overflow-wrap: anywhere; }

@media (max-width: 400px) {
  .lo-card { padding: 22px 16px 16px; border-radius: 20px; }
  .lo-icon { width: 58px; height: 58px; }
  .lo-card h3 { font-size: 21px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .lo-card { width: min(440px, 100%); padding: 16px 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .lo-card > :not(button) { grid-column: 1 / -1; }
  .lo-icon { display: none; }
  .lo-card h3 { font-size: 20px; margin: 0; }
  .lo-card p  { margin: 0 0 4px; }
  .lo-yes { margin-bottom: 0; }
}

@media (min-width: 1500px) {
  .seats { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
  .seat { min-height: 62px; font-size: 17px; }
}

@media (max-width: 600px) {
  .seat-status { flex-wrap: wrap; padding: 12px; gap: 10px 12px; }
  .ss-icon { width: 44px; height: 44px; }
  .ss-text b { font-size: 16px; }
  .seat-status button { width: 100%; }
  .seat-top { flex-direction: column; align-items: flex-start; }
  .seated { grid-template-columns: 1fr; }
  .seat { border-radius: 14px; }
  .seat-sub { font-size: 18px; }
}

@media (max-width: 340px) {
  .ss-text .mu { font-size: 12px; }
  .seated-card { flex-wrap: wrap; }
  .seated-card button { width: 100%; }
}

@media (hover: none) {
  .seat.o:hover { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .28); }
  .seated-card:hover { transform: none; border-color: var(--bd); }
}

@media (max-height: 520px) and (orientation: landscape) {
  .seat-status { padding: 8px 12px; margin-bottom: 8px; }
  .ss-icon { width: 38px; height: 38px; }
  .seat { min-height: 42px; }
}

@media (max-width: 700px) {
  .lo-card.map-card { padding: 18px 14px 14px; }
  .map-grid { grid-template-columns: 1fr; gap: 12px; }
  .map-box { padding: 10px; }
  .lvl { height: 36px; }
  .lvl .spines { height: 27px; }
}

@media (max-width: 380px) {
  .map-card h3 { font-size: 19px; }
  .book .loc-btn { padding: 7px 8px 7px 10px; font-size: 12px; }
}

@media (max-height: 520px) and (orientation: landscape) and (min-width: 560px) {
  .lo-card.map-card { width: min(760px, 100%); padding: 12px 16px; }
  .map-card .lo-icon { display: none; }
  .map-grid { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
  .map-card .lo-card h3 { font-size: 18px; }
  .map-copies { margin: 8px 0 10px !important; }
}

@media (min-width: 1500px) {
  .lo-card.map-card { width: min(880px, 100%); }
  .lvl { height: 44px; }
  .lvl .spines { height: 34px; }
}

@media (hover: none) { .book .loc-btn:hover { border-color: var(--bd); } }

@media (max-width: 600px) {
  .floor-tabs { max-width: none; }
  .floor-tabs .ft { min-height: 50px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .floor-tabs { margin-bottom: 8px; }
  .floor-tabs .ft { min-height: 40px; padding: 4px 6px; flex-direction: row; gap: 8px; justify-content: center; }
}
@media (hover: none) { .floor-tabs .ft:hover { background: transparent; } }

.room { padding: 12px; }
@media (min-width: 1500px) {
  .room { padding: 18px; }
  .zone-tables { gap: 28px 32px; }
}
@media (max-width: 400px) {
  .room { padding: 8px; border-radius: 18px; }
  .zone-tables { gap: 16px 12px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .room { padding: 8px; }
  .room-in { gap: 10px 16px; }
}
@media (hover: none) {
  .room .seat:not(:disabled):hover { transform: none; }
}

@media (max-width: 600px) {
  .resv-card { grid-template-columns: minmax(0, 1fr) auto; padding: 12px; }
  .resv-btns { grid-column: 1 / -1; }
  .resv-btns > * { flex: 1; }
  .shelf-room { gap: 26px 10px; }
  .shelf-name { font-size: 10px; padding: 2px 6px; }
}
@media (max-width: 340px) {
  .resv-card { grid-template-columns: minmax(0, 1fr); }
  .resv-time { justify-self: start; }
}
@media (min-width: 1500px) {
  .shelf-room { width: min(100%, 520px); }
  .resv-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-height: 520px) and (orientation: landscape) {
  .shelf-room { width: min(100%, 300px); gap: 26px 12px; padding-top: 30px; }
}

@media (max-width: 700px) {
  .ab-general h3 { font-size: 20px; }
  .ab-card { padding: 14px; }
  .ab-head h3 { font-size: 17px; }
  .seg button { min-height: 44px; font-size: 14px; }
  .book .book-actions > button { flex: 1 1 100%; }
}
@media (max-width: 380px) {
  .ab-list li { padding: 8px 10px; gap: 8px; }
  .ab-ico { width: 42px; height: 42px; }
}
@media (min-width: 1500px) {
  .ab-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ab-general p { font-size: 16px; }
}
@media (max-height: 480px) and (orientation: landscape) {
  .seg button { min-height: 38px; }
}

@media (max-width: 700px) {
  .resv-btns { flex-wrap: wrap; }
  .resv-btns > button { flex: 1 1 130px; }
}

@media (min-width: 1500px) {
  .hdr .lgx { width: 120px; }
  .sec-head { margin-bottom: 14px; }
  .trash-item { padding: 14px 18px; }
}

@media (max-width: 1024px) {
  .hdr .lgx { width: 92px; }
  .stu-table { min-width: 720px; }
}

@media (max-width: 820px) {
  .sec-head { align-items: flex-start; }
  .head-tools { width: 100%; }
  .head-tools > button { flex: 1 1 160px; }
  .trash-item { align-items: flex-start; }
  .hdr .lgx { width: 80px; }
}

@media (max-width: 600px) {
  .hdr .lgx { width: 84px; height: auto; }
  .hdr.pad { padding: 14px; }
  .ab-grid { grid-template-columns: minmax(0, 1fr); }
  .sec-head { flex-direction: column; align-items: stretch; }
  .sec-head > .danger-btn, .sec-head > button { width: 100%; justify-content: center; }
  .head-tools > button { flex: 1 1 100%; }
  .trash-item { flex-direction: column; align-items: stretch; }
  .trash-item .acts > * { flex: 1 1 130px; }
  .stu-table { min-width: 700px; }
  .lo-card.wide { padding: 22px 16px 18px; }
  .ban-presets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 380px) {
  .hdr .lgx { width: 68px; height: auto; }
  .cnt { min-width: 20px; height: 20px; font-size: 11px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .hdr .lgx { width: 60px; height: auto; }
  .lo-card.wide { max-height: calc(100dvh - 20px); padding: 16px 18px; }
  .lo-card.wide .lo-icon { display: none; }
}

input[type="date"] { min-width: 0; max-width: 100%; }
.tw { -webkit-overflow-scrolling: touch; }

@media (max-width: 900px) {
  .stu-table { min-width: 680px; }
  .stu-table .chip { min-width: 150px; }
  .stu-table .chip-note { max-width: 150px; }
  .stu-table td:nth-child(5), .stu-table th:nth-child(5) { width: 180px; }
  .stu-table td:last-child, .stu-table th:last-child { width: 200px; }
  .stu-table .acts { grid-template-columns: repeat(2, 90px); }
}

@media (max-width: 600px) {
  .stu-table .acts button { padding-left: 8px; padding-right: 8px; font-size: 13px; }
  .seat-status { flex-wrap: wrap; }
  .seat-status .ss-text { flex-basis: 100%; }
  .err { font-size: 13px; }
}

.lo-back { overflow-y: auto; overscroll-behavior: contain; padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.lo-card { max-width: 100%; }
.resv-card .resv-actions button, .resv-card button { min-height: 40px; }
@media (max-width: 480px) { .lo-card .lo-yes, .lo-card .lo-no { min-height: 48px; } }
@media (min-width: 1600px) { .lo-card { width: min(420px, 100%); } }

@media (max-width: 600px) {
  .profile-card { margin-top: 0; flex: none; padding: 4px; gap: 0; border-radius: 99px; align-self: center; }
  .pc-text { display: none; }
  .profile-card .avatar { width: 36px; height: 36px; font-size: 12px; }
  .pc-more { width: 32px; height: 32px; }
  .set-photo { width: 100%; justify-content: center; }
  .avatar.xl { width: 62px; height: 62px; font-size: 22px; }
  .settings-grid { gap: 10px; }
  .pmenu { min-width: min(232px, calc(100vw - 16px)); }
}
@media (min-width: 601px) and (max-width: 1100px) and (orientation: portrait) {
  .profile-card { margin-top: 0; flex: none; padding: 4px; gap: 0; border-radius: 99px; align-self: center; }
  .pc-text { display: none; }
  .profile-card .avatar { width: 40px; height: 40px; }
}
@media (max-height: 520px) and (min-width: 601px) {
  .profile-card { padding: 6px; }
  .pc-text small { display: none; }
  .profile-card .avatar { width: 34px; height: 34px; font-size: 12px; }
}
@media (min-width: 601px) and (max-width: 900px) and (orientation: landscape) {
  .profile-card { padding: 8px; gap: 8px; }
  .pc-more { width: 30px; }
}
@media (hover: none) {
  .profile-card:hover .avatar { transform: none; }
  .pm-item:hover { transform: none; }
}


/* Settings: two even columns, no empty gaps on any screen */
@media (min-width: 601px) {
  .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; }
  .set-wide { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  .settings-grid { grid-template-columns: 1fr; }
  .set-actions { width: 100%; }
  .set-actions > * { flex: 1; justify-content: center; }
  .set-lbl { flex-basis: 30%; font-size: 13px; }
  .set-row { padding: 12px; }
}

@media (max-width: 600px) {
  .set-top { gap: 10px; }
  .set-who { flex: 1 1 140px; }
  .seg .seg-b { padding: 10px 4px; font-size: 13px; }
  .set-pwform { padding: 4px 12px 14px; }
}
@media (max-width: 380px) {
  .set-row { gap: 8px; padding: 11px 10px; }
  .set-lbl { flex-basis: 28%; }
}