:root {
  --ink: #1b2a33;
  --muted: #5d6c76;
  --line: #e3e8ec;
  --paper: #f3f5f6;
  --card: #ffffff;
  --header: #102433;
  --lane: #e2b43a;
  --shadow: 0 10px 28px rgba(16, 36, 51, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  padding-top: var(--header-space, 84px);
  padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  background: var(--paper);
  color: var(--ink);
  font-family: "Noto Sans Lao", "Lao Sangam MN", "Phetsarath OT", sans-serif;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  padding: 12px 20px;
  background: var(--header);
  color: #fff;
  border-bottom: 3px solid var(--lane);
  transform: translate3d(0, 0, 0);
  transition: transform 280ms cubic-bezier(0.2, 0, 0, 1);
  will-change: transform;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
}

.header-date {
  color: rgba(255, 255, 255, 0.82);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
}

.menu-wrap {
  position: relative;
  flex: 0 0 auto;
}

.kebab {
  width: 42px;
  height: 42px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #fff;
  cursor: pointer;
}

.kebab span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
}

.kebab:hover,
.kebab[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.12);
}

.menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  padding: 28px 16px;
  background: #fff;
  color: var(--ink);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(16, 36, 51, 0.18);
}

.menu-empty {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.page {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 24px;
}

.nav-btn:focus-visible,
.kebab:focus-visible {
  outline: 2px solid var(--lane);
  outline-offset: 3px;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: calc(64px + env(safe-area-inset-bottom, 0px));
  padding: 0 18px env(safe-area-inset-bottom, 0px);
  background: #fff;
  border-top: 1px solid #24323c;
  transform: translate3d(0, 0, 0);
  transition: transform 280ms cubic-bezier(0.2, 0, 0, 1);
  will-change: transform;
}

.nav-btn {
  width: 72px;
  height: 48px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: #7d8b95;
  text-decoration: none;
  cursor: pointer;
}

.nav-btn[aria-current="page"] {
  color: var(--ink);
}

.nav-btn svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-btn[aria-current="page"] svg {
  stroke-width: 2.2;
}

body.chrome-hidden .topbar {
  transform: translate3d(0, -100%, 0);
  pointer-events: none;
}

body.chrome-hidden .bottom-nav {
  transform: translate3d(0, calc(100% + env(safe-area-inset-bottom, 0px) + 10px), 0);
  pointer-events: none;
}

.page.profile-page {
  width: min(440px, calc(100% - 40px));
  padding-top: 48px;
}

.profile-identity {
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.profile-avatar {
  width: 132px;
  height: 132px;
  flex: 0 0 132px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: #f0f2f5;
  color: #6b7280;
}

.profile-avatar img,
.profile-avatar svg {
  grid-area: 1 / 1;
}

.profile-avatar img {
  width: 132px;
  height: 132px;
  min-width: 0;
  min-height: 0;
  object-fit: cover;
  border-radius: 50%;
}

.profile-avatar img[hidden],
.profile-avatar svg[hidden] {
  display: none;
}

.profile-avatar svg {
  width: 74px;
  height: 74px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.profile-username,
.profile-password {
  margin: 0;
  text-align: center;
  color: #1c1e21;
}

.profile-username {
  margin-top: 18px;
  font-size: 24px;
  font-weight: 700;
}

.profile-password {
  margin-top: 16px;
  font-size: 20px;
  font-weight: 600;
  color: #4b5563;
}

.profile-auth {
  position: relative;
  display: flex;
  justify-content: center;
  margin-top: 18px;
  pointer-events: auto;
}

.profile-auth-toggle {
  padding: 0;
  border: 0;
  background: transparent;
  color: #102433;
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}

.login-pop {
  position: absolute;
  z-index: 6;
  top: calc(100% + 8px);
  left: 50%;
  width: min(320px, 80vw);
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 16px 36px rgba(16, 36, 51, 0.16);
  transform: translateX(-50%);
}

.login-pop[hidden] {
  display: none;
}

.login-pop input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid #d5dbe0;
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
}

.login-pop button {
  height: 42px;
  border: 0;
  border-radius: 8px;
  background: #102433;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.login-pop button:disabled {
  opacity: 0.6;
}

.login-message {
  margin: 0;
  color: #fa3e3e;
  font-size: 14px;
  font-weight: 600;
}

.profile-history {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 36px;
  padding: 16px 0;
  color: #4b5563;
  font-size: 16px;
  font-weight: 600;
  pointer-events: none;
}

.profile-history svg {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.detail-page {
  width: min(680px, calc(100% - 28px));
}

.station {
  margin: 0 0 36px;
}

.station h2 {
  margin: 4px 0 16px;
  font-size: 18px;
  font-weight: 700;
}

.shift-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  column-gap: 16px;
  row-gap: 8px;
  align-items: start;
  margin-bottom: 22px;
}

.frame-photo,
.condition-rail {
  height: 138px;
}

.frame {
  border: 1.5px solid #24323c;
  background: #fff;
}

.frame-photo {
  width: 112px;
  justify-self: center;
}

.shift-label,
.condition-label {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.shift-label {
  width: 150px;
  text-align: center;
}

.condition-rail {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  cursor: grab;
  -webkit-overflow-scrolling: touch;
}

.condition-rail.is-dragging {
  cursor: grabbing;
  scroll-snap-type: none;
}

.condition-rail::-webkit-scrollbar {
  height: 6px;
}

.condition-rail::-webkit-scrollbar-thumb {
  background: #c5ced4;
  border-radius: 99px;
}

.frame-condition {
  flex: 0 0 84px;
  height: 138px;
  scroll-snap-align: start;
}

.condition-label {
  justify-self: start;
  width: calc(3 * 84px + 2 * 12px);
  max-width: 100%;
  text-align: center;
}

.frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (max-width: 860px) {
  .topbar h1 {
    font-size: 18px;
  }

  .header-date {
    font-size: 14px;
  }
}

@media (max-width: 560px) {
  .page {
    width: min(1120px, calc(100% - 20px));
  }

  .shift-row {
    grid-template-columns: 118px minmax(0, 1fr);
    column-gap: 10px;
  }

  .frame-photo {
    width: 96px;
  }

  .shift-label {
    width: 118px;
    font-size: 12px;
  }

  .frame-condition {
    flex-basis: 72px;
  }

  .condition-label {
    width: calc(3 * 72px + 2 * 12px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .condition-rail {
    scroll-behavior: auto;
  }

  .topbar,
  .bottom-nav {
    transition: none;
  }
}
