/* Panel Absensi: Telegram's theme colours (with fallbacks outside Telegram), 16 px text,
   touch targets of 44-48 px and a 360 px minimum width. No web fonts, no images. A warning
   has a border and starts with "⚠️": never colour alone. No inline styles (CSP). */

:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #16191d);
  --hint: var(--tg-theme-hint-color, #6b7280);
  --link: var(--tg-theme-link-color, #2481cc);
  --button: var(--tg-theme-button-color, #2481cc);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --card: var(--tg-theme-secondary-bg-color, #f1f2f4);
  --alert: var(--tg-theme-destructive-text-color, #d93025);
  --line: var(--tg-theme-section-separator-color, rgba(128, 128, 128, 0.35));
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--tg-theme-bg-color, #17212b);
    --text: var(--tg-theme-text-color, #f5f5f5);
    --hint: var(--tg-theme-hint-color, #9aa3ad);
    --link: var(--tg-theme-link-color, #6ab3f3);
    --card: var(--tg-theme-secondary-bg-color, #232e3c);
    --alert: var(--tg-theme-destructive-text-color, #ec6d6d);
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 360px;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 16px calc(32px + env(safe-area-inset-bottom, 0px));
}

h2 {
  font-size: 1.15rem;
  margin: 8px 0;
}

h3 {
  font-size: 1rem;
  margin: 20px 0 8px;
}

p {
  margin: 4px 0;
  overflow-wrap: anywhere;
}

.hint {
  color: var(--hint);
}

.strong {
  font-weight: 600;
}

.pre {
  white-space: pre-wrap;
}

.screen {
  padding: 48px 8px;
  text-align: center;
}

.top {
  padding: 4px 0;
}

/* Tabs stay on top while the screen scrolls. */
.tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  gap: 4px;
  margin: 0 -16px 8px;
  padding: 6px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.tabs button {
  flex: 1 1 0;
  min-width: 0;
  padding: 8px 4px;
}

.tabs button[aria-selected="true"],
.chip.on {
  background: var(--button);
  color: var(--button-text);
  border-color: var(--button);
}

button {
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

button.primary {
  background: var(--button);
  color: var(--button-text);
  border-color: var(--button);
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

button.link {
  padding: 8px 0;
  border: 0;
  background: none;
  color: var(--link);
}

button.row {
  display: block;
  width: 100%;
  margin: 8px 0;
  text-align: left;
}

.actions,
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}

.card,
.box {
  margin: 8px 0;
  padding: 10px 12px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: var(--card);
}

.card.active {
  border-color: var(--button);
}

/* Warnings and errors: a border (the text starts with ⚠️). */
.warn,
.error {
  margin: 8px 0;
  padding: 10px 12px;
  border: 2px solid var(--alert);
  border-radius: 12px;
}

.card.warn {
  background: var(--card);
}

.badge {
  display: inline-block;
  margin-left: 4px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--hint);
  font-size: 0.875rem;
  font-weight: 400;
}

label.check {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

label.check input {
  flex: none;
  width: 24px;
  height: 24px;
  margin: 0;
  accent-color: var(--button);
}

label.field {
  display: block;
  margin: 8px 0;
}

input[type="search"],
input[type="time"],
input[type="date"],
input[type="text"] {
  display: block;
  width: 100%;
  min-height: 44px;
  margin: 8px 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.command code {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg);
  font: 0.94rem/1.4 ui-monospace, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
  user-select: all;
  -webkit-user-select: all;
}

.command button {
  margin-top: 8px;
}

.status:empty {
  display: none;
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 5;
  max-width: 688px;
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.dialog {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
}

.sheet {
  width: 100%;
  max-width: 720px;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  border-radius: 16px 16px 0 0;
  background: var(--bg);
}
