@import url("https://fonts.googleapis.com/css2?family=Knewave&family=Noto+Sans+Thai:wght@500;700;900&family=Sriracha&display=swap");

:root {
  --navy: #102f31;
  --navy-2: #193f41;
  --ink: #f7fff9;
  --muted: #c9d9d2;
  --line: rgba(205, 255, 212, 0.16);
  --surface: #2f5f5e;
  --soft: #274f4f;
  --lime: #b8f34c;
  --lime-bright: #b7f52e;
  --green: #9bec53;
  --green-soft: rgba(184, 243, 76, 0.14);
  --red: #ff6b5f;
  --red-soft: rgba(255, 107, 95, 0.16);
  --gray: #8fa5a0;
  --gray-soft: rgba(255, 255, 255, 0.1);
  --shadow: 0 20px 58px rgba(0, 0, 0, 0.28);
  --brush-font: "Knewave", "Sriracha", "Noto Sans Thai", cursive;
  --row-height: 6px;
  --app-zoom: 1;
  --text-scale: 1;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  font-size: calc(16px * var(--text-scale));
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background:
    radial-gradient(circle at 18% 0%, rgba(184, 243, 76, 0.18), transparent 22rem),
    radial-gradient(circle at 92% 8%, rgba(255, 255, 255, 0.08), transparent 20rem),
    linear-gradient(180deg, #163739 0%, #214d4d 48%, #173636 100%);
  color: var(--ink);
  font-family: "Noto Sans Thai", Inter, ui-sans-serif, system-ui, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
input[type="date"] {
  touch-action: manipulation;
}

.app-shell {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) clamp(12px, 3vw, 28px) max(28px, env(safe-area-inset-bottom));
}

.app-title {
  margin: 0 0 10px;
  color: rgba(247, 255, 249, 0.84);
  font-family: var(--brush-font);
  font-size: clamp(1.25rem, 4.8vw, 2rem);
  font-weight: 400;
  line-height: 1.18;
  text-align: center;
  text-shadow: none;
}

.schedule-card {
  overflow: hidden;
  border: 1px solid rgba(218, 255, 211, 0.18);
  border-radius: 18px;
  background: rgba(48, 94, 94, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  transform-origin: top center;
  zoom: var(--app-zoom);
}

.day-header {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 12px;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(16, 47, 49, 0.98), rgba(9, 30, 32, 0.95)),
    rgba(20, 50, 52, 0.9);
  color: #fff;
}

.date-strip {
  display: grid;
  grid-auto-columns: minmax(50px, 1fr);
  grid-auto-flow: column;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 12px 12px;
  scrollbar-width: none;
}

.date-strip::-webkit-scrollbar {
  display: none;
}

.date-chip {
  display: grid;
  gap: 2px;
  min-height: 58px;
  place-items: center;
  border: 0;
  border-radius: 16px;
  background: rgba(7, 20, 22, 0.18);
  color: var(--muted);
  cursor: pointer;
}

.date-chip strong {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  color: var(--ink);
  font-family: var(--brush-font);
  font-size: 1rem;
  font-weight: 400;
}

.date-chip.active {
  background: rgba(184, 243, 76, 0.13);
}

.date-chip.active strong {
  background: var(--lime);
  color: var(--navy);
}

.date-chip.today:not(.active) strong {
  box-shadow: inset 0 0 0 2px var(--lime);
}

.date-chip span {
  font-size: 0.78rem;
  font-weight: 900;
}

.date-title {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2vw, 22px);
  min-width: 0;
}

.calendar-icon {
  display: grid;
  width: clamp(44px, 9vw, 78px);
  height: clamp(44px, 9vw, 78px);
  place-items: center;
}

.calendar-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.2));
}

.date-label {
  min-width: 0;
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  font-family: var(--brush-font);
  font-size: clamp(2rem, 9vw, 5.1rem);
  font-weight: 400;
  line-height: 0.95;
  text-shadow: 0 5px 0 rgba(0, 0, 0, 0.26);
  white-space: nowrap;
}

.date-picker {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  opacity: 0;
  pointer-events: auto;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(184, 243, 76, 0.22);
  border-radius: 9px;
  background: rgba(7, 20, 22, 0.42);
  color: #fff;
  cursor: pointer;
  font-size: 2rem;
  line-height: 1;
}

.toolbar {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 16px 18px 10px;
  scrollbar-width: thin;
}

.view-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 14px 18px 0;
}

.view-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: rgba(7, 20, 22, 0.36);
  color: var(--muted);
  cursor: pointer;
  font-weight: 900;
}

.view-button.active {
  border-color: transparent;
  background: var(--lime);
  color: #102f31;
  box-shadow: 0 8px 22px rgba(184, 243, 76, 0.2);
}

.size-controls {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  overflow-x: auto;
  padding: 12px 18px 0;
  scrollbar-width: thin;
}

.zoom-controls,
.text-size-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.control-label {
  color: var(--lime);
  font-size: 0.9rem;
  font-weight: 950;
  white-space: nowrap;
}

.zoom-button,
.zoom-reset,
.text-size-button,
.text-size-reset {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  background: rgba(7, 20, 22, 0.36);
  color: var(--ink);
  cursor: pointer;
  font-weight: 950;
}

.zoom-button,
.text-size-button {
  display: grid;
  width: 48px;
  place-items: center;
  font-size: 1.25rem;
  line-height: 1;
}

.zoom-reset,
.text-size-reset {
  padding: 8px 12px;
}

.zoom-value,
.text-size-value {
  min-width: 64px;
  color: var(--ink);
  font-weight: 950;
  text-align: center;
}

.mode-chip {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: rgba(7, 20, 22, 0.36);
  color: var(--ink);
  cursor: pointer;
  padding: 8px 12px;
  font-family: var(--brush-font);
  font-size: 1.08rem;
  font-weight: 400;
  white-space: nowrap;
}

.mode-chip.active {
  border-color: transparent;
  background: linear-gradient(180deg, #c4ff38, #a8ee25);
  color: #102f31;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22), 0 10px 22px rgba(183, 245, 46, 0.2);
}

.status-dot {
  display: inline-grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 900;
  line-height: 1;
}

.free-dot {
  background: var(--green);
}

.busy-dot {
  background: var(--gray);
}

.booking-dot {
  border-radius: 7px;
  background: var(--red);
  font-size: 0.78rem;
}

.notice {
  min-height: 26px;
  padding: 0 18px 8px;
  color: var(--muted);
  font-weight: 700;
}

.timeline-wrap {
  display: grid;
  grid-template-columns: minmax(112px, 42%) 1fr;
  border-top: 1px solid var(--line);
}

.time-column,
.grid-column {
  position: relative;
  min-height: calc(var(--row-height) * 156);
}

.time-column {
  border-right: 1px solid var(--line);
  background: rgba(23, 54, 56, 0.58);
}

.time-mark {
  position: absolute;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: 48px 1fr;
  align-items: start;
  height: calc(var(--row-height) * 12);
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--brush-font);
  font-size: clamp(1.45rem, 4.6vw, 2.55rem);
  font-weight: 400;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.18);
}

.clock {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border: 3px solid var(--lime);
  border-radius: 50%;
}

.clock::before {
  width: 10px;
  height: 10px;
  border-bottom: 3px solid var(--lime);
  border-left: 3px solid var(--lime);
  content: "";
  transform: translate(2px, -2px);
}

.slot-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: repeat(156, var(--row-height));
  background: rgba(37, 78, 78, 0.72);
}

.slot-button {
  width: 100%;
  min-height: var(--row-height);
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.slot-button.hour {
  border-bottom: 0;
}

.slot-button:focus-visible {
  position: relative;
  z-index: 4;
  outline: 3px solid rgba(11, 42, 104, 0.32);
  outline-offset: -3px;
}

.event-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.week-view,
.month-view {
  border-top: 1px solid var(--line);
  background: rgba(37, 78, 78, 0.72);
}

.week-view {
  overflow-x: auto;
}

.week-header,
.week-body {
  display: grid;
  grid-template-columns: 92px repeat(7, minmax(112px, 1fr));
  min-width: 940px;
}

.week-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(21, 49, 51, 0.9);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}

.week-head-spacer,
.week-day-head {
  min-height: 58px;
  border-right: 1px solid var(--line);
  padding: 9px;
}

.week-day-head {
  display: grid;
  align-content: center;
  gap: 3px;
  text-align: center;
}

.week-day-head strong {
  font-size: 1.05rem;
}

.week-day-head span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.week-day-head.today,
.month-day.today {
  background: rgba(184, 243, 76, 0.16);
}

.week-time-column {
  position: relative;
  grid-column: 1;
  min-height: calc(var(--row-height) * 156);
  border-right: 1px solid var(--line);
  background: rgba(23, 54, 56, 0.58);
}

.week-time-mark {
  position: absolute;
  left: 0;
  right: 0;
  height: calc(var(--row-height) * 12);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 900;
  padding: 6px 8px;
}

.week-columns {
  grid-column: 2 / -1;
  display: grid;
  grid-template-columns: repeat(7, minmax(112px, 1fr));
  min-height: calc(var(--row-height) * 156);
}

.week-day-column {
  position: relative;
  min-height: calc(var(--row-height) * 156);
  border-right: 1px solid var(--line);
  background: rgba(37, 78, 78, 0.72);
}

.week-slot-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: repeat(156, var(--row-height));
}

.week-slot {
  width: 100%;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.week-slot.hour {
  border-bottom: 0;
}

.week-event {
  position: absolute;
  left: 4px;
  right: 4px;
  z-index: 2;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  padding: 5px 6px;
  text-align: left;
  font-size: 0.92rem;
  font-weight: 900;
  line-height: 1.18;
}

.week-event small {
  display: block;
  opacity: 0.85;
}

.week-event.booking {
  background: linear-gradient(180deg, #c4ff38, #a7ed27);
  color: #062927;
  box-shadow: inset 4px 0 0 var(--red), 0 8px 18px rgba(0, 0, 0, 0.16);
}

.week-event.busy {
  background: rgba(255, 87, 87, 0.13);
  color: #ff6b5f;
  box-shadow: inset 4px 0 0 #ff5757;
}

.month-view {
  padding: 14px 18px 18px;
}

.month-weekdays,
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.month-weekdays {
  gap: 6px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 900;
  text-align: center;
}

.month-grid {
  gap: 6px;
}

.month-day {
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 54, 56, 0.42);
  padding: 8px;
}

.month-day.outside {
  background: rgba(7, 20, 22, 0.22);
  color: rgba(247, 255, 249, 0.42);
}

.month-day-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 7px;
}

.month-date-button {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: rgba(7, 20, 22, 0.36);
  color: var(--ink);
  cursor: pointer;
  font-weight: 950;
}

.month-day.today .month-date-button {
  background: var(--lime);
  color: #102f31;
}

.month-add-button {
  min-width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: rgba(184, 243, 76, 0.16);
  color: var(--lime);
  cursor: pointer;
  font-size: 1.15rem;
  font-weight: 950;
}

.month-items {
  display: grid;
  gap: 5px;
}

.month-item {
  overflow: hidden;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  padding: 5px 6px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.92rem;
  font-weight: 900;
}

.month-item.booking {
  background: linear-gradient(180deg, #c4ff38, #a7ed27);
  color: #062927;
  box-shadow: inset 4px 0 0 var(--red);
}

.month-item.busy {
  background: rgba(255, 87, 87, 0.13);
  color: #ff6b5f;
  box-shadow: inset 4px 0 0 #ff5757;
}

.month-more {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}

.event-block {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin: 3px 0;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  padding: 7px 12px;
  pointer-events: auto;
  text-align: left;
}

.event-block.generated-free {
  pointer-events: none;
}

.event-block.free {
  background: rgba(183, 245, 46, 0.14);
  color: var(--lime-bright);
}

.event-block.busy {
  background: rgba(255, 87, 87, 0.13);
  color: #ff6b5f;
  box-shadow: inset 5px 0 0 #ff5757;
}

.event-block.booking {
  background: linear-gradient(180deg, #c4ff38 0%, #a7ed27 100%);
  color: #062927;
  box-shadow: inset 5px 0 0 var(--red), 0 8px 18px rgba(0, 0, 0, 0.16);
}

.event-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 900;
}

.event-block.free .event-icon {
  background: var(--green);
}

.event-block.busy .event-icon {
  background: var(--gray);
}

.event-block.booking .event-icon {
  border-radius: 8px;
  background: var(--red);
  color: #fff;
}

.event-copy {
  min-width: 0;
  font-family: var(--brush-font);
  font-size: clamp(1.18rem, 3.4vw, 1.58rem);
  font-weight: 400;
  line-height: 1.22;
}

.event-copy small {
  display: block;
  overflow: hidden;
  color: currentColor;
  font-size: 0.72em;
  font-weight: 750;
  opacity: 0.86;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.booking-badge {
  align-self: start;
  border-radius: 9px;
  background: var(--red);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 900;
  padding: 3px 8px;
}

.summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--line);
  background: rgba(21, 49, 51, 0.9);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  color: var(--muted);
  font-weight: 800;
}

.summary-number {
  margin-right: 4px;
  color: var(--lime);
  font-size: 1.4rem;
  font-weight: 950;
}

.clear-button,
.backup-button,
.ghost-button,
.delete-button,
.save-button {
  min-height: 40px;
  border-radius: 8px;
  cursor: pointer;
  padding: 9px 14px;
  font-weight: 900;
}

.clear-button,
.backup-button,
.ghost-button {
  border: 0;
  background: rgba(7, 20, 22, 0.36);
  color: var(--ink);
}

.delete-button {
  border: 0;
  background: var(--red-soft);
  color: #fff1ee;
}

.save-button {
  border: 0;
  background: var(--lime);
  color: #102f31;
}

.entry-dialog {
  width: min(540px, calc(100% - 24px));
  border: 0;
  border-radius: 18px;
  padding: 0;
  box-shadow: var(--shadow);
}

.entry-dialog::backdrop {
  background: rgba(4, 10, 28, 0.48);
}

.dialog-panel {
  display: grid;
  gap: 14px;
  padding: 22px;
  background: #2f5f5e;
  color: var(--ink);
}

.dialog-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
  text-transform: uppercase;
}

.dialog-head h2 {
  margin: 0;
  font-size: 2rem;
  line-height: 1;
}

.close-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: rgba(7, 20, 22, 0.36);
  color: var(--ink);
  cursor: pointer;
  font-size: 1.7rem;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 900;
}

.time-range {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: rgba(7, 20, 22, 0.32);
  color: var(--ink);
  padding: 11px 12px;
}

.field textarea {
  resize: vertical;
}

.error-text {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-weight: 850;
}

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-actions > div {
  display: flex;
  gap: 10px;
}

@media (max-width: 680px) {
  :root {
    --row-height: 10px;
  }

  .app-shell {
    padding: max(10px, env(safe-area-inset-top)) 10px max(14px, env(safe-area-inset-bottom));
  }

  .schedule-card {
    border-radius: 14px;
  }

  .toolbar {
    padding: 12px 10px 8px;
  }

  .mode-chip {
    min-height: 44px;
  }

  .day-header {
    grid-template-columns: 34px 1fr 34px;
    gap: 6px;
    padding: 14px 10px;
  }

  .icon-button {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    font-size: 1.5rem;
  }

  .timeline-wrap {
    grid-template-columns: 44% 56%;
  }

  .time-mark {
    grid-template-columns: 38px 1fr;
    padding: 8px 8px;
  }

  .clock {
    width: 27px;
    height: 27px;
    border-width: 3px;
  }

  .event-block {
    grid-template-columns: 34px minmax(0, 1fr);
    padding: 6px 8px;
  }

  .booking-badge {
    display: none;
  }

  .summary-bar {
    position: sticky;
    bottom: 0;
    z-index: 8;
    flex-wrap: wrap;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }

  .view-switch {
    padding: 10px 10px 0;
  }

  .size-controls {
    padding: 10px 10px 0;
  }

  .zoom-controls,
  .text-size-controls {
    flex: 1 1 100%;
  }

  .text-size-reset {
    min-width: 116px;
  }

  .view-button {
    min-height: 38px;
    font-size: 0.9rem;
  }

  .month-view {
    padding: 10px;
    overflow-x: auto;
  }

  .month-weekdays,
  .month-grid {
    min-width: 620px;
  }

  .dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .dialog-actions > div {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .time-range {
    grid-template-columns: 1fr;
  }
}

.fab-add {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 30;
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 0;
  border-radius: 18px;
  background: var(--lime);
  color: var(--navy);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  font-size: 2rem;
  font-weight: 950;
  line-height: 1;
}

@media (max-width: 680px) {
  :root {
    --row-height: 3.8px;
  }

  html {
    font-size: 16px;
  }

  body {
    background:
      radial-gradient(circle at 18% 0%, rgba(184, 243, 76, 0.18), transparent 22rem),
      radial-gradient(circle at 92% 8%, rgba(255, 255, 255, 0.08), transparent 20rem),
      linear-gradient(180deg, #163739 0%, #214d4d 48%, #173636 100%);
  }

  .app-shell {
    display: flex;
    width: min(430px, 100%);
    min-height: 100svh;
    flex-direction: column;
    padding: 0;
    background: rgba(48, 94, 94, 0.92);
  }

  .app-title {
    position: sticky;
    top: 0;
    z-index: 28;
    margin: 0;
    border-bottom: 1px solid var(--line);
    background:
      linear-gradient(135deg, rgba(16, 47, 49, 0.98), rgba(9, 30, 32, 0.95)),
      rgba(20, 50, 52, 0.92);
    padding: max(8px, env(safe-area-inset-top)) 14px 6px;
    color: rgba(247, 255, 249, 0.84);
    font-size: 1.1rem;
    text-align: left;
  }

  .schedule-card {
    display: flex;
    min-height: 0;
    flex: 1;
    flex-direction: column;
    border: 0;
    border-radius: 0;
    background: rgba(48, 94, 94, 0.92);
    box-shadow: none;
    zoom: 1;
  }

  .day-header {
    position: relative;
    top: auto;
    z-index: 4;
    grid-template-columns: 34px 1fr 34px;
    gap: 8px;
    border-bottom: 1px solid var(--line);
    background:
      linear-gradient(135deg, rgba(16, 47, 49, 0.98), rgba(9, 30, 32, 0.95)),
      rgba(20, 50, 52, 0.92);
    padding: 6px 8px;
  }

  .calendar-icon {
    display: none;
  }

  .date-label {
    font-size: 1.7rem;
    text-shadow: none;
  }

  .time-mark:last-child {
    display: none;
  }

  .icon-button {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(7, 20, 22, 0.36);
  }

  .date-strip {
    display: none;
  }

  .view-switch {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    padding: 5px 8px 0;
  }

  .view-button {
    min-height: 30px;
    border-radius: 7px;
    font-size: 0.85rem;
    background: rgba(7, 20, 22, 0.36);
    color: var(--muted);
  }

  .view-button.active {
    background: var(--lime);
    color: var(--navy);
  }

  .size-controls {
    display: none;
  }

  .toolbar {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 5px;
    overflow: visible;
    padding: 6px 8px 5px;
  }

  .mode-chip {
    min-height: 31px;
    min-width: 0;
    border-radius: 7px;
    justify-content: center;
    gap: 5px;
    padding: 4px 5px;
    font-size: 0.8rem;
    line-height: 1.05;
    text-align: center;
    white-space: normal;
  }

  .mode-chip[data-mode="free"],
  .mode-chip[data-mode="busy"] {
    grid-column: span 3;
  }

  .mode-chip[data-mode="booking"] {
    grid-column: span 2;
  }

  .status-dot {
    width: 20px;
    height: 20px;
    font-size: 0.75rem;
  }

  .notice {
    min-height: 0;
    padding: 0;
    font-size: 0.74rem;
    line-height: 1.15;
  }

  .timeline-wrap {
    flex: 1;
    grid-template-columns: 42% 58%;
    min-height: 0;
    overflow: hidden;
    border-top: 1px solid var(--line);
    background: rgba(37, 78, 78, 0.82);
  }

  .time-column,
  .grid-column {
    min-height: calc(var(--row-height) * 156);
  }

  .time-column {
    border-right: 1px solid var(--line);
    background: rgba(23, 54, 56, 0.58);
  }

  .time-mark {
    grid-template-columns: 22px 1fr;
    height: calc(var(--row-height) * 12);
    align-items: center;
    justify-items: start;
    padding: 0 6px;
    border-bottom: 1px solid var(--line);
    color: rgba(247, 255, 249, 0.78);
    font-size: clamp(0.9rem, 3.5vw, 1.12rem);
    text-shadow: none;
  }

  .clock {
    display: grid;
    width: 16px;
    height: 16px;
    border-width: 2px;
  }

  .clock::before {
    width: 5px;
    height: 5px;
    border-bottom-width: 2px;
    border-left-width: 2px;
    transform: translate(1px, -1px);
  }

  .slot-grid {
    background:
      repeating-linear-gradient(to bottom, transparent 0 calc((var(--row-height) * 3) - 1px), rgba(218, 255, 211, 0.11) calc((var(--row-height) * 3) - 1px) calc(var(--row-height) * 3)),
      rgba(37, 78, 78, 0.72);
  }

  .event-block {
    left: 0;
    right: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    gap: 0;
    margin: 0;
    border-left: 0;
    border-radius: 0;
    padding: 3px 6px;
    box-shadow: none;
  }

  .event-icon,
  .booking-badge {
    display: none;
  }

  .event-block.booking {
    border-left: 4px solid var(--red);
    background: linear-gradient(180deg, #c4ff38 0%, #a7ed27 100%);
    color: #062927;
  }

  .event-block.free {
    border-left: 4px solid var(--green);
    background: rgba(183, 245, 46, 0.14);
    color: var(--lime-bright);
  }

  .event-block.busy {
    border-left: 4px solid #ff5757;
    background: rgba(255, 87, 87, 0.13);
    color: #ff6b5f;
  }

  .event-copy {
    font-size: clamp(0.86rem, 3.4vw, 1.2rem);
    line-height: 1.05;
  }

  .event-copy small {
    font-family: "Noto Sans Thai", Inter, ui-sans-serif, system-ui, sans-serif;
    font-size: 0.68rem;
    line-height: 1.05;
  }

  .summary-bar {
    position: relative;
    bottom: 0;
    z-index: 22;
    display: grid;
    grid-template-columns: 1fr 1fr auto auto auto;
    gap: 4px;
    padding: 4px 8px max(5px, env(safe-area-inset-bottom));
    background: rgba(21, 49, 51, 0.94);
  }

  .summary-bar > div {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 0;
    background: rgba(7, 20, 22, 0.2);
    padding: 3px 6px;
  }

  .summary-number {
    display: block;
    margin: 0;
    font-family: var(--brush-font);
    font-size: 0.98rem;
    font-weight: 400;
    line-height: 1;
  }

  .summary-bar span:not(.summary-number) {
    display: block;
    overflow: hidden;
    color: var(--muted);
    font-size: 0.68rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .clear-button {
    min-height: 30px;
    align-self: stretch;
    border-radius: 7px;
    padding: 4px 8px;
    font-size: 0.78rem;
  }

  .backup-button {
    min-height: 30px;
    align-self: stretch;
    border-radius: 7px;
    padding: 4px 7px;
    font-size: 0.78rem;
  }

  .fab-add {
    right: max(12px, env(safe-area-inset-right));
    bottom: calc(58px + max(8px, env(safe-area-inset-bottom)));
    width: 52px;
    height: 52px;
    border-radius: 16px;
    font-size: 1.85rem;
  }

  .week-view,
  .month-view {
    flex: 1;
    min-height: 0;
    overflow: auto;
  }

  .week-header,
  .week-body {
    grid-template-columns: 58px repeat(7, minmax(88px, 1fr));
    min-width: 690px;
  }

  .week-head-spacer,
  .week-day-head {
    min-height: 52px;
    padding: 7px;
  }

  .week-time-mark {
    font-family: var(--brush-font);
    font-size: 0.82rem;
    font-weight: 400;
    text-align: center;
  }

  .week-columns {
    grid-template-columns: repeat(7, minmax(88px, 1fr));
  }

  .month-view {
    padding: 10px 10px 86px;
  }

  .month-weekdays,
  .month-grid {
    min-width: 560px;
  }

  .entry-dialog {
    width: 100%;
    max-width: 430px;
    max-height: 92svh;
    margin: auto auto 0;
    border-radius: 24px 24px 0 0;
  }

  .dialog-panel {
    gap: 12px;
    padding: 12px 16px max(18px, env(safe-area-inset-bottom));
  }

  .dialog-panel::before {
    width: 44px;
    height: 5px;
    margin: 0 auto 2px;
    border-radius: 999px;
    background: rgba(247, 255, 249, 0.34);
    content: "";
  }

  .dialog-head h2 {
    font-size: 1.2rem;
  }

  .field input,
  .field select,
  .field textarea {
    min-height: 46px;
    border-radius: 14px;
  }

  .dialog-actions {
    align-items: stretch;
  }
}

@media (max-width: 680px) and (max-height: 760px) {
  :root {
    --row-height: 3.25px;
  }
}

@media (max-width: 680px) and (min-height: 880px) {
  :root {
    --row-height: 4.25px;
  }
}

@media (min-width: 681px) {
  .app-shell {
    width: min(430px, 100%);
  }

  .schedule-card {
    border-radius: 24px;
  }
}
