:root {
  --bg: #0b1120;
  --surface: #1e293b;
  --surface-active: #1e3a5f;
  --border: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --accent: #3b82f6;
  --accent-light: #60a5fa;
  --danger: #ef4444;
  --success: #22c55e;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: clamp(14px, 3.2vw, 16px);
}

#app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  flex-shrink: 0;
}

header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

header h1 span {
  color: var(--accent-light);
}

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.icon-btn:hover {
  background: var(--surface-active);
  color: var(--text-primary);
}

/* Date Bar */
.date-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 10px;
  flex-shrink: 0;
}

.date-greg {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Hero */
.hero {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-active) 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  margin: 0 16px 10px;
  padding: 14px 16px;
  text-align: center;
  flex-shrink: 0;
}

.hero-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-light);
  margin-bottom: 4px;
  font-weight: 600;
}

.hero-name {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.hero-countdown {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* Prayer List */
.prayer-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 16px;
  min-height: 0;
  overflow: hidden;
}

.prayer-header {
  display: grid;
  grid-template-columns: 1fr 68px 68px;
  gap: 8px;
  padding: 0 12px 4px;
  flex-shrink: 0;
}

.prayer-header > div {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  text-align: center;
  font-weight: 600;
}

.prayer-header > div:first-child {
  text-align: left;
}

.prayer-row {
  display: grid;
  grid-template-columns: 1fr 68px 68px;
  gap: 8px;
  align-items: center;
  background: var(--surface);
  border-radius: 12px;
  padding: 0 12px;
  flex: 1;
  min-height: 0;
  border-left: 3px solid transparent;
  transition: background 0.2s ease;
}

.prayer-row.active {
  background: var(--surface-active);
  border-left-color: var(--accent);
}

.prayer-row.passed {
  opacity: 0.55;
}

.prayer-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
}

.prayer-name-en {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.prayer-name-ar {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-family: 'Arial', sans-serif;
}

.prayer-time {
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.prayer-time .label {
  display: none;
}

.prayer-time-label {
  font-size: 0.6rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
  margin-bottom: 2px;
}

/* Nav Bar */
.nav-bar {
  display: flex;
  gap: 8px;
  padding: 10px 16px 16px;
  flex-shrink: 0;
}

.nav-bar button {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.nav-bar button:hover {
  background: var(--surface-active);
}

.nav-bar button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.nav-bar button.primary:hover {
  background: #2563eb;
}

.nav-bar button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-overlay.show {
  display: flex;
}

.modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.modal-footer {
  display: flex;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-footer button {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  font-weight: 600;
  cursor: pointer;
}

.modal-footer button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* File Input */
.file-input-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.file-input-wrapper input[type="file"] {
  color: var(--text-secondary);
}

.status-msg {
  font-size: 0.85rem;
  color: var(--text-secondary);
  min-height: 1.2em;
}

.status-msg.error {
  color: var(--danger);
}

.status-msg.success {
  color: var(--success);
}

/* Preview Table */
.preview-table-wrapper {
  overflow-x: auto;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.preview-table th {
  background: var(--surface);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 8px 6px;
  text-align: center;
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.preview-table td {
  padding: 4px 6px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.preview-table td input {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  padding: 4px 6px;
  font-size: 0.75rem;
  text-align: center;
}

.preview-table td input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Night Bar */
.night-bar {
  background: rgba(30, 58, 95, 0.35);
  border-radius: 12px;
  padding: 8px 12px;
  flex-shrink: 0;
  margin-top: 2px;
  border: 1px solid rgba(51, 65, 85, 0.5);
}

.night-row {
  display: grid;
  grid-template-columns: 1fr 68px 68px;
  gap: 8px;
  align-items: center;
  min-height: 22px;
}

.night-row:first-child {
  margin-bottom: 4px;
}

.night-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-align: right;
  padding-right: 4px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.night-time {
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--accent-light);
}

/* Settings Panel */
.settings-sheet {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translate(-50%, 100%);
  transition: transform 0.25s ease;
  max-height: 50vh;
}

#settingsPanel.show .settings-sheet {
  transform: translate(-50%, 0);
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.settings-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.settings-body {
  padding: 8px 20px 24px;
  overflow-y: auto;
  flex: 1;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-label {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
}

.settings-row button {
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.settings-row button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.settings-row button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Utility */
.hidden {
  display: none !important;
}

.text-secondary {
  color: var(--text-secondary);
}

/* Isha row interaction */
.prayer-row[data-prayer="isha"] {
  cursor: pointer;
  position: relative;
}

.prayer-row[data-prayer="isha"]:hover,
.prayer-row[data-prayer="isha"]:active {
  background: var(--surface-active);
}

.prayer-hint {
  font-size: 0.6rem;
  color: var(--accent-light);
  margin-top: 2px;
  opacity: 0.85;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* Isha Modal */
.isha-modal {
  max-width: 360px;
}

.isha-modal-body {
  padding: 20px;
}

.isha-modal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
}

.isha-modal-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.isha-modal-time {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.isha-modal-divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

.isha-modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.isha-modal-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 16px 12px;
  text-align: center;
  border: 1px solid var(--border);
}

.isha-modal-card .isha-modal-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.65rem;
}

.isha-modal-accent {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent-light);
  font-variant-numeric: tabular-nums;
}

/* Isha countdown */
.isha-countdown {
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  margin-bottom: 18px;
  min-height: 1.4em;
  letter-spacing: -0.01em;
}
