/* ===== เสียงประกาศ — Office Notification ===== */
:root {
  --bg: oklch(0.969 0.003 250);
  --surface: oklch(1 0 0);
  --surface-2: oklch(0.975 0.003 250);
  --ink: oklch(0.235 0.012 262);
  --ink-soft: oklch(0.42 0.011 262);
  --muted: oklch(0.58 0.009 262);
  --faint: oklch(0.72 0.007 262);
  --border: oklch(0.905 0.004 262);
  --border-strong: oklch(0.84 0.005 262);
  --black: oklch(0.22 0.012 262);
  --live: oklch(0.64 0.13 152);
  --live-bg: oklch(0.95 0.04 152);
  --warn: oklch(0.62 0.16 35);
  --shadow-sm: 0 1px 2px oklch(0.2 0.02 262 / 0.05), 0 1px 1px oklch(0.2 0.02 262 / 0.04);
  --shadow-md: 0 4px 16px oklch(0.2 0.02 262 / 0.07), 0 1px 3px oklch(0.2 0.02 262 / 0.05);
  --shadow-lg: 0 24px 60px oklch(0.2 0.02 262 / 0.18), 0 4px 12px oklch(0.2 0.02 262 / 0.08);
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 24px;
  --font: "IBM Plex Sans Thai", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
}
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* ---------- App shell ---------- */
.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 28px 80px;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 22px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: var(--black);
  color: white;
  display: grid; place-items: center;
  flex: none;
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-name { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.brand-sub { font-size: 12.5px; color: var(--muted); font-weight: 400; margin-top: -2px; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }
.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px 0 12px;
  border-radius: 999px;
  background: var(--live-bg);
  color: oklch(0.42 0.1 152);
  border: 1px solid oklch(0.84 0.07 152);
  font-size: 13px; font-weight: 500;
}
.status-pill.muted {
  background: var(--surface-2);
  color: var(--muted);
  border-color: var(--border);
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 0 oklch(0.64 0.13 152 / 0.5);
  animation: pulse 2.4s ease-out infinite;
}
.status-pill.muted .status-dot { background: var(--faint); animation: none; box-shadow: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 oklch(0.64 0.13 152 / 0.45); }
  70% { box-shadow: 0 0 0 7px oklch(0.64 0.13 152 / 0); }
  100% { box-shadow: 0 0 0 0 oklch(0.64 0.13 152 / 0); }
}

.icon-btn {
  height: 36px; min-width: 36px; padding: 0 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-soft);
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 500;
  transition: all .15s ease;
}
.icon-btn:hover { border-color: var(--border-strong); background: var(--surface-2); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn.active { background: var(--black); color: white; border-color: var(--black); }

/* ---------- Clock hero ---------- */
.clock-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  padding: 40px 36px 34px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.clock-time {
  font-family: var(--mono);
  font-weight: 500;
  font-size: clamp(64px, 14vw, 132px);
  line-height: 0.95;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  display: flex; align-items: baseline; justify-content: center; gap: 2px;
}
.clock-time .sec {
  font-size: 0.36em;
  color: var(--faint);
  font-weight: 400;
  margin-left: 6px;
  align-self: center;
}
.clock-colon { animation: blink 2s steps(1) infinite; }
@keyframes blink { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0.32; } }
.clock-date {
  margin-top: 14px;
  font-size: 17px;
  color: var(--ink-soft);
  font-weight: 500;
}
.clock-date .en { color: var(--faint); font-weight: 400; font-size: 14px; }

/* ---------- Next-up banner ---------- */
.nextup {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 16px 20px;
  display: flex; align-items: center; gap: 16px;
}
.nextup-icon {
  width: 40px; height: 40px; flex: none;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  color: var(--ink-soft);
}
.nextup-icon svg { width: 19px; height: 19px; }
.nextup-body { flex: 1; min-width: 0; }
.nextup-label { font-size: 12px; color: var(--muted); font-weight: 500; letter-spacing: 0.02em; text-transform: uppercase; }
.nextup-main { font-size: 15.5px; color: var(--ink); margin-top: 2px; font-weight: 500; }
.nextup-main b { font-weight: 600; }
.nextup-main .dim { color: var(--muted); font-weight: 400; }
.nextup-count {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--ink-soft);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  flex: none;
  font-variant-numeric: tabular-nums;
}
.nextup.empty .nextup-main { color: var(--muted); font-weight: 400; }

/* ---------- List section ---------- */
.list-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 34px 2px 14px;
}
.list-title { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.list-title .count { color: var(--faint); font-weight: 400; margin-left: 6px; }
.sync-badge { display: block; font-size: 12px; font-weight: 400; color: var(--muted); margin-top: 4px; letter-spacing: 0; }
.sync-badge.on { color: #2a7f4f; }
.sync-badge.off { color: #b3502c; }
.btn-add {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 18px 0 15px;
  border-radius: 10px;
  background: var(--black); color: white; border: none;
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, opacity .15s ease;
}
.btn-add:hover { opacity: 0.9; }
.btn-add:active { transform: translateY(1px); }
.btn-add svg { width: 17px; height: 17px; }

.cards { display: grid; gap: 12px; }

/* ---------- Announcement card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.card:hover { box-shadow: var(--shadow-md); }
.card.off { opacity: 0.62; }
.card.off .card-time { color: var(--muted); }

.card-time {
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  min-width: 92px;
}
.card-time .ampm { font-size: 13px; color: var(--faint); margin-left: 2px; }

.card-body { min-width: 0; }
.card-name { font-size: 15.5px; font-weight: 600; color: var(--ink); }
.card-text {
  font-size: 13.5px; color: var(--muted);
  margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.chip {
  font-size: 11.5px;
  color: var(--ink-soft);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2.5px 8px;
  font-weight: 500;
  display: inline-flex; align-items: center; gap: 5px;
}
.chip svg { width: 12px; height: 12px; opacity: 0.7; }
.chip .days-on { color: var(--ink); font-weight: 600; }
.chip .days-off { color: var(--faint); font-weight: 400; }

.card-actions { display: flex; align-items: center; gap: 6px; }
.card-icon {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  display: grid; place-items: center;
  transition: all .14s ease;
}
.card-icon:hover { background: var(--surface-2); border-color: var(--border); color: var(--ink); }
.card-icon.danger:hover { color: var(--warn); border-color: oklch(0.85 0.08 35); background: oklch(0.97 0.02 35); }
.card-icon svg { width: 17px; height: 17px; }

/* toggle switch */
.toggle {
  position: relative; width: 42px; height: 24px; flex: none;
  border-radius: 999px; border: none;
  background: var(--border-strong);
  transition: background .2s ease;
}
.toggle.on { background: var(--live); }
.toggle::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: white; box-shadow: var(--shadow-sm);
  transition: transform .2s cubic-bezier(.3,1.3,.5,1);
}
.toggle.on::after { transform: translateX(18px); }

/* ---------- Empty state ---------- */
.empty-state {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  padding: 48px 24px;
  text-align: center;
}
.empty-state .es-icon {
  width: 52px; height: 52px; margin: 0 auto 14px;
  border-radius: 14px; background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid; place-items: center; color: var(--faint);
}
.empty-state .es-icon svg { width: 24px; height: 24px; }
.empty-state h3 { font-size: 16px; font-weight: 600; }
.empty-state p { font-size: 13.5px; color: var(--muted); margin-top: 4px; }

/* ---------- Modal ---------- */
.overlay {
  position: fixed; inset: 0;
  background: oklch(0.3 0.02 262 / 0.42);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 24px;
  z-index: 50;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 540px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  transform: translateY(12px) scale(0.98);
  transition: transform .24s cubic-bezier(.2,.9,.3,1);
}
.overlay.show .modal { transform: none; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 24px 0;
}
.modal-head h2 { font-size: 18px; font-weight: 600; }
.modal-close {
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); display: grid; place-items: center;
  transition: all .14s ease;
}
.modal-close:hover { background: var(--surface-2); color: var(--ink); }
.modal-close svg { width: 16px; height: 16px; }
.modal-body { padding: 20px 24px 4px; }

.field { margin-bottom: 18px; }
.field-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 600; color: var(--ink-soft);
  margin-bottom: 7px;
}
.field-label .hint { font-weight: 400; color: var(--faint); font-size: 12px; }

.input, .textarea, .select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 10px 13px;
  font-size: 14.5px;
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--black);
  box-shadow: 0 0 0 3px oklch(0.22 0.012 262 / 0.1);
}
.textarea { resize: vertical; min-height: 76px; line-height: 1.5; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2390909a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.text-with-btn { position: relative; }
.btn-preview {
  position: absolute; right: 8px; bottom: 8px;
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 13px;
  border-radius: 7px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--ink); font-size: 12.5px; font-weight: 500;
  transition: all .14s ease;
}
.btn-preview:hover { background: var(--black); color: white; border-color: var(--black); }
.btn-preview svg { width: 14px; height: 14px; }
.btn-preview.playing { background: var(--live); color: white; border-color: var(--live); }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* time picker — two 24h selects (hour + minute) styled to read as one clock field */
.time-picker { display: flex; align-items: center; gap: 6px; }
.time-picker .time-part {
  width: auto;
  flex: 1;
  font-family: var(--mono);
  font-size: 18px;
  letter-spacing: 0.04em;
  text-align: center;
  text-align-last: center; /* center the selected option in most browsers */
  padding-right: 28px;     /* leave room for the dropdown caret */
}
.time-picker .time-colon {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  color: #555;
  padding: 0 2px;
}

/* day picker */
.day-presets { display: flex; gap: 7px; margin-bottom: 10px; flex-wrap: wrap; }
.preset {
  font-size: 12px; font-weight: 500;
  padding: 6px 12px; border-radius: 7px;
  background: var(--surface); border: 1px solid var(--border-strong);
  color: var(--ink-soft); transition: all .14s ease;
}
.preset:hover { background: var(--surface-2); }
.preset.active { background: var(--black); color: white; border-color: var(--black); }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; }
.day {
  height: 46px; border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 13.5px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px;
  transition: all .14s ease;
}
.day .day-sub { font-size: 9.5px; font-weight: 400; color: var(--faint); }
.day:hover { border-color: var(--ink); }
.day.on {
  background: var(--black); color: white; border-color: var(--black);
}
.day.on .day-sub { color: oklch(0.78 0.01 262); }

/* sliders */
.slider-row { display: flex; align-items: center; gap: 14px; }
.slider {
  -webkit-appearance: none; appearance: none;
  flex: 1; height: 5px; border-radius: 999px;
  background: var(--border-strong);
  outline: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 19px; height: 19px; border-radius: 50%;
  background: var(--black); cursor: pointer;
  box-shadow: var(--shadow-sm); border: 2.5px solid white;
}
.slider::-moz-range-thumb {
  width: 19px; height: 19px; border-radius: 50%;
  background: var(--black); cursor: pointer; border: 2.5px solid white;
}
.slider-val {
  font-family: var(--mono); font-size: 13px;
  color: var(--ink); min-width: 52px; text-align: right;
  font-variant-numeric: tabular-nums;
}

/* inline toggle field */
.toggle-field {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 15px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.toggle-field .tf-text { font-size: 14px; font-weight: 500; color: var(--ink); }
.toggle-field .tf-sub { font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 1px; }

/* segmented (repeat / lang) */
.segmented { display: flex; gap: 0; border: 1px solid var(--border-strong); border-radius: var(--r-sm); overflow: hidden; }
.segmented button {
  flex: 1; padding: 9px 6px; border: none; background: var(--surface);
  font-size: 13px; font-weight: 500; color: var(--ink-soft);
  border-right: 1px solid var(--border);
  transition: all .14s ease;
}
.segmented button:last-child { border-right: none; }
.segmented button.active { background: var(--black); color: white; }

/* modal footer */
.modal-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 24px 22px;
  position: sticky; bottom: 0;
  background: linear-gradient(to top, var(--surface) 70%, transparent);
}
.btn-save {
  flex: 1; height: 46px; border-radius: 11px;
  background: var(--black); color: white; border: none;
  font-size: 15px; font-weight: 600;
  transition: opacity .15s ease, transform .1s ease;
}
.btn-save:hover { opacity: 0.9; }
.btn-save:active { transform: translateY(1px); }
.btn-ghost {
  height: 46px; padding: 0 20px; border-radius: 11px;
  background: var(--surface); border: 1px solid var(--border-strong);
  color: var(--ink-soft); font-size: 15px; font-weight: 500;
  transition: all .14s ease;
}
.btn-ghost:hover { background: var(--surface-2); }
.btn-del { color: var(--warn); border-color: oklch(0.85 0.08 35); }
.btn-del:hover { background: oklch(0.97 0.02 35); }

/* now-speaking flash */
.speaking-flash {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--black); color: white;
  border-radius: 14px; padding: 14px 22px;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 13px;
  font-size: 14.5px; font-weight: 500;
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 60; max-width: 90vw;
}
.speaking-flash.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.sound-wave { display: flex; align-items: center; gap: 3px; height: 20px; }
.sound-wave span {
  width: 3px; border-radius: 2px; background: var(--live);
  animation: wave 0.9s ease-in-out infinite;
}
.sound-wave span:nth-child(1) { animation-delay: 0s; }
.sound-wave span:nth-child(2) { animation-delay: .15s; }
.sound-wave span:nth-child(3) { animation-delay: .3s; }
.sound-wave span:nth-child(4) { animation-delay: .45s; }
@keyframes wave { 0%, 100% { height: 6px; } 50% { height: 18px; } }
.speaking-flash .sf-sub { color: oklch(0.78 0.01 262); font-weight: 400; font-size: 12.5px; }

/* enable-sound banner */
.enable-banner {
  margin-top: 16px;
  background: oklch(0.97 0.03 85);
  border: 1px solid oklch(0.86 0.07 85);
  border-radius: var(--r-lg);
  padding: 14px 18px;
  display: flex; align-items: center; gap: 14px;
  font-size: 14px; color: oklch(0.42 0.08 70);
}
.enable-banner svg { width: 20px; height: 20px; flex: none; }
.enable-banner button {
  margin-left: auto;
  height: 36px; padding: 0 16px; border-radius: 9px;
  background: oklch(0.45 0.09 70); color: white; border: none;
  font-size: 13.5px; font-weight: 600; flex: none;
}
.enable-banner.hidden { display: none; }

/* Thai voice notice — neutral tone */
.enable-banner.thai-voice {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--ink-soft);
  align-items: flex-start;
  line-height: 1.55;
}
.enable-banner.thai-voice svg { color: var(--muted); margin-top: 2px; }
.enable-banner.thai-voice b { color: var(--ink); font-weight: 600; }
.enable-banner.thai-voice button { background: var(--black); align-self: center; }

/* editor inline voice hint */
.voice-hint {
  display: none;
  align-items: center; gap: 7px;
  margin-top: 8px; padding: 8px 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 12px; color: var(--muted);
}
.voice-hint.show { display: flex; }
.voice-hint svg { width: 14px; height: 14px; flex: none; }

@media (max-width: 640px) {
  .app { padding: 18px 16px 64px; }
  .card { grid-template-columns: auto 1fr; }
  .card-actions { grid-column: 1 / -1; justify-content: flex-end; padding-top: 4px; border-top: 1px solid var(--border); }
  .row2 { grid-template-columns: 1fr; }
}
