:root {
  --bg-color: #0f172a; /* Slate 900 */
  --surface-color: #1e293b; /* Slate 800 */
  --border-color: #334155; /* Slate 700 */
  --text-primary: #f8fafc; /* Slate 50 */
  --text-secondary: #94a3b8; /* Slate 400 */
  --accent: #10b981; /* Emerald 500 */
  --accent-hover: #059669; /* Emerald 600 */
  --accent-light: rgba(16, 185, 129, 0.15);
  --danger: #ef4444;
}

* { box-sizing: border-box; }

/* A downward drag at the top of the list must not reload the page and lose
   what is on screen. */
html { overscroll-behavior-y: none; }

body {
  margin: 0; padding: 0;
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

.background-decor {
  position: absolute;
  top: -100px; left: -100px;
  width: 400px; height: 400px;
  background: radial-gradient(circle, var(--accent-light) 0%, transparent 70%);
  z-index: -1;
  pointer-events: none;
}

header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--border-color);
  background: rgba(30, 41, 59, 0.7);
  backdrop-filter: blur(8px);
}

.logo { display: flex; align-items: center; gap: 0.5rem; }
.moon { font-size: 1.5rem; }
h1 { margin: 0; font-size: 1.25rem; font-weight: 600; letter-spacing: -0.025em; }

.pill {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.35rem 0.85rem; border-radius: 999px;
  background: var(--bg-color); border: 1px solid var(--border-color);
  font-size: 0.8rem; font-weight: 500;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-secondary); transition: background 0.3s; }
.pill[data-state="synced"] .dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); }

main.dashboard {
  padding: 2rem;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 2rem;
  max-width: 1000px;
  margin: 0 auto;
}

@media (max-width: 768px) {
  main.dashboard { flex-direction: column-reverse; padding: 1rem; }
}

.calendar-sidebar {
  flex: 1;
  width: 100%;
  min-width: 300px;
  background: var(--surface-color);
  border-radius: 16px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2), 0 0 0 1px var(--border-color);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 80vh;
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: rgba(0,0,0,0.15);
}
.sidebar-header h2 { margin: 0; font-size: 1.25rem; color: #fff; }
.sidebar-header p { margin: 0; color: var(--text-secondary); font-size: 0.85rem; }

.calendar-list {
  padding: 1rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.calendar-list .empty {
  color: var(--text-secondary); text-align: center; margin-top: 2rem;
}

.calendar-month-group {
  margin-top: 1rem;
}
.calendar-month-group:first-child { margin-top: 0; }
.calendar-month-group h4 {
  margin: 0 0 0.5rem 0;
  color: var(--accent);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.25rem;
}

.birthday-item {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.birthday-info h5 { margin: 0 0 0.25rem 0; font-size: 1rem; color: #fff; }
.birthday-info p { margin: 0; font-size: 0.8rem; color: var(--text-secondary); }
.birthday-age {
  background: var(--accent-light);
  color: var(--accent);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: bold;
}

/* ---------- sync code ---------- */
.sync-code {
  border-top: 1px solid var(--border-color);
  padding: 1rem 1.5rem 1.25rem;
  font-size: 0.85rem; color: var(--text-secondary);
  background: rgba(0,0,0,0.15);
}
.sync-code summary {
  cursor: pointer; font-weight: 600; color: var(--text-primary);
}
.sync-help { margin: 0.75rem 0; font-size: 0.8rem; line-height: 1.45; }
.sync-row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.sync-row input {
  flex: 1; min-width: 0;
  padding: 0.55rem 0.7rem; font-size: 0.85rem;
}
.btn {
  flex: none; padding: 0.55rem 0.9rem;
  background: var(--bg-color); color: var(--text-primary);
  border: 1px solid var(--border-color); border-radius: 8px;
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.sync-status { margin: 0.5rem 0 0; font-size: 0.8rem; min-height: 1.2em; }
.sync-status[data-kind="good"] { color: var(--accent); }
.sync-status[data-kind="bad"] { color: var(--danger); }

.card {
  flex: 1;
  width: 100%; max-width: 480px;
  background: var(--surface-color);
  border-radius: 16px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2), 0 0 0 1px var(--border-color);
  overflow: hidden;
}

.card-header { padding: 2rem 2rem 1rem 2rem; text-align: center; }
.card h2 { margin: 0 0 0.5rem 0; font-size: 1.5rem; font-weight: 700; color: #fff; }
.desc { color: var(--text-secondary); margin: 0; font-size: 0.95rem; }

.tabs {
  display: flex; padding: 0 1rem; margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}
.tabs button {
  flex: 1; padding: 1rem 0.5rem;
  background: transparent; color: var(--text-secondary);
  border: none; border-bottom: 2px solid transparent;
  cursor: pointer; font-size: 0.95rem; font-weight: 500;
  transition: all 0.2s;
}
.tabs button:hover { color: var(--text-primary); }
.tabs button.active {
  color: var(--accent); border-bottom-color: var(--accent);
}

.panel { display: none; padding: 0 2rem 2rem 2rem; animation: fadeIn 0.3s ease; }
.panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.input-group label, .panel > label {
  display: block; margin-bottom: 0.5rem;
  color: var(--text-secondary); font-size: 0.875rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.05em;
}

input, select {
  width: 100%; padding: 0.875rem 1rem;
  background: var(--bg-color); color: var(--text-primary);
  border: 1px solid var(--border-color); border-radius: 8px;
  font-size: 1rem; outline: none; transition: border-color 0.2s;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* Custom Date Input Styling */
.date-input {
  appearance: none; -webkit-appearance: none;
  font-family: monospace; font-size: 1.1rem; text-align: center;
}
::-webkit-calendar-picker-indicator { filter: invert(1); cursor: pointer; }

.hijri-inputs { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }
.hijri-inputs .col { flex: 1; }
.hijri-inputs .col-main { flex: 2; }
.hijri-inputs input, .hijri-inputs select { text-align: center; }

.btn-primary {
  width: 100%; padding: 1rem; margin-top: 1.5rem;
  background: var(--accent); color: #fff;
  border: none; border-radius: 8px;
  font-size: 1rem; font-weight: 600; cursor: pointer;
  box-shadow: 0 4px 14px var(--accent-light);
  transition: all 0.2s;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(1px); }

.btn-secondary {
  width: 100%; padding: 0.8rem;
  background: var(--surface-color); color: #fff;
  border: 1px solid var(--accent); border-radius: 8px;
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover { background: var(--accent-light); }

.result-box {
  margin: 0 2rem 2rem 2rem; padding: 1.5rem;
  background: var(--accent-light);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 12px; text-align: center;
  animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes popIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

.result-box h3 { margin: 0 0 0.5rem 0; color: var(--accent); font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.05em; }
.highlight-date { font-size: 1.75rem; font-weight: 800; margin: 0; color: #fff; line-height: 1.2; }
.age-text { color: var(--text-primary); font-size: 1rem; margin: 1rem 0; background: rgba(0,0,0,0.2); padding: 0.5rem; border-radius: 6px; }

.save-form {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px dashed rgba(16, 185, 129, 0.4);
  display: flex; flex-direction: column; gap: 0.75rem;
}
.save-form input { background: rgba(0,0,0,0.2); border-color: rgba(16, 185, 129, 0.4); }

