:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1c232c;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #2f81f7;
  --green: #3fb950;
  --radius: 12px;
  color-scheme: dark; /* native controls (select popup) render dark */
}

* { box-sizing: border-box; }

/* Ensure the `hidden` attribute wins over display:flex/block set by classes
   (used by the client-side filter to hide rows/groups). */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-bottom: env(safe-area-inset-bottom);
}

.wrap {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  padding: max(12px, env(safe-area-inset-top)) 0 12px;
}

.topbar .wrap {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

h1 { font-size: 22px; margin: 0; }

.repo {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

main.wrap { padding-top: 24px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}

.card h2 { margin: 0 0 12px; font-size: 16px; }

.new-task { display: flex; flex-direction: column; gap: 10px; }

input[type="text"], input[type="password"], textarea {
  width: 100%;
  font: inherit;
  font-size: 16px; /* >=16px prevents iOS zoom-on-focus */
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  -webkit-appearance: none;
  appearance: none;
}

/* Hide the browser's built-in reveal "eye" (Edge) and password-manager key
   icons so the PIN field matches the plain text boxes. */
input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear { display: none; }
input[type="password"]::-webkit-credentials-auto-fill-button,
input[type="password"]::-webkit-strong-password-auto-fill-button {
  display: none !important;
  visibility: hidden;
  pointer-events: none;
}

textarea { resize: vertical; min-height: 44px; }

.field { display: flex; flex-direction: column; gap: 6px; }

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 129, 247, 0.25);
}

/* Priority selector: three color-coded buttons backed by a radio group (no JS,
   works under the strict CSP). Each label sets --p (accent) and --pt (on-fill
   text) for its priority. */
.priority-group { display: flex; gap: 8px; }

.prio-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.prio-btn {
  flex: 1;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--p);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

/* colored status dot for extra affordance */
.prio-btn::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--p);
}

.prio-btn:hover { border-color: var(--p); }

.prio-input:checked + .prio-btn {
  background: var(--p);
  border-color: var(--p);
  color: var(--pt);
}
.prio-input:checked + .prio-btn::before { background: var(--pt); }

.prio-input:focus-visible + .prio-btn {
  box-shadow: 0 0 0 3px rgba(47, 129, 247, 0.4);
}

.prio-high   { --p: #f85149; --pt: #ffffff; }
.prio-medium { --p: #d29922; --pt: #1a1200; }
.prio-low    { --p: #3fb950; --pt: #052310; }

button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 12px 16px;
  min-height: 44px; /* comfortable tap target */
  transition: filter 0.15s, background 0.15s;
}

button:active { filter: brightness(0.9); }

.new-task button {
  background: var(--accent);
  color: #fff;
}

.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.filters a {
  flex: 1;
  text-align: center;
  text-decoration: none;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 0;
  font-size: 14px;
  font-weight: 600;
}

.filters a.active {
  color: #fff;
  background: var(--surface-2);
  border-color: var(--accent);
}

.prio-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.pf-chip {
  flex: 1;
  text-align: center;
  text-decoration: none;
  color: var(--p);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 0;
  font-size: 13px;
  font-weight: 600;
}
.pf-chip:hover { border-color: var(--p); }
.pf-chip.active {
  background: var(--p);
  border-color: var(--p);
  color: var(--pt);
}
.pf-high   { --p: #f85149; --pt: #ffffff; }
.pf-medium { --p: #d29922; --pt: #1a1200; }
.pf-low    { --p: #3fb950; --pt: #052310; }

.search-form { margin-bottom: 16px; }
.search-form input[type="search"] {
  width: 100%;
  font: inherit;
  font-size: 16px; /* >=16px prevents iOS zoom-on-focus */
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  -webkit-appearance: none;
  appearance: none;
}
.search-form input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 129, 247, 0.25);
}

.group-title {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 20px 0 10px;
}

.count {
  display: inline-block;
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 12px;
  margin-left: 4px;
}

.tasks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }

.task {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.task-main { display: flex; align-items: flex-start; gap: 10px; flex: 1; min-width: 0; }

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(63, 185, 80, 0.15);
}
.dot.open { background: var(--green); }
.dot.closed { background: var(--muted); box-shadow: none; }

.task-text { min-width: 0; flex: 1; }

.task-title {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  word-break: break-word;
}
.task.closed .task-title { color: var(--muted); text-decoration: line-through; }

.task-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}

.label {
  border: 1px solid var(--c, var(--border));
  color: var(--text);
  border-radius: 999px;
  padding: 0 8px;
  font-size: 11px;
  line-height: 18px;
}

/* "Open since" chip: neutral, quieter than a colored priority chip. */
.label.since {
  color: var(--muted);
  border-color: var(--border);
}

.state-form { flex-shrink: 0; }

.btn-done {
  background: transparent;
  color: var(--green);
  border-color: var(--green);
  padding: 8px 14px;
  min-height: 40px;
}

.btn-reopen {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
  padding: 8px 14px;
  min-height: 40px;
}

.alert {
  background: rgba(248, 81, 73, 0.12);
  border: 1px solid rgba(248, 81, 73, 0.4);
  color: #ff7b72;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 14px;
  word-break: break-word;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
}

.hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lang-toggle {
  flex-shrink: 0;
  cursor: pointer;
  text-decoration: none;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
  min-height: 0; /* override generic button min-height */
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.lang-toggle:hover { color: var(--text); border-color: var(--accent); }

.nav-link {
  flex-shrink: 0;
  text-decoration: none;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
}
.nav-link:hover { color: var(--text); border-color: var(--accent); }

/* Schedule page: calendar fills the space below the sticky header. */
.schedule-body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}
.schedule-main {
  flex: 1;
  display: flex;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}
/* Border/corners live on the wrapper so the dark-mode filter below doesn't
   invert them. */
.schedule-frame-wrap {
  flex: 1;
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
}
.schedule-frame {
  flex: 1;
  width: 100%;
  min-height: 70vh;
  border: 0;
  background: #fff;
  /* The Google Calendar embed is light-only; invert + hue-rotate turns it into
     a dark theme (white bg -> near-black, dark text -> light) while keeping event
     colors roughly correct, so it matches the site. */
  filter: invert(0.92) hue-rotate(180deg);
}

.logout-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.who {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  max-width: 40vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
  padding: 6px 12px;
  min-height: 36px;
  font-size: 13px;
}
