:root {
  --bg-primary: #0d0d0f;
  --bg-secondary: #16161a;
  --bg-card: #1c1c21;
  --bg-hover: #242429;
  --border: #2e2e35;
  --text-primary: #fffffe;
  --text-secondary: #94949c;
  --text-muted: #5c5c66;
  --accent: #a39171;
  --accent-hover: #8c7a5e;
  --accent-glow: rgba(163, 145, 113, 0.2);
  --success: #2cb67d;
  --error: #e55353;
  --warning: #f0a050;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family:
    "Nunito",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px;
}

header {
  text-align: center;
  margin-bottom: 32px;
  padding-top: 16px;
}

.header-logo {
  width: 40px;
  height: 40px;
  margin-bottom: 8px;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 400;
  margin-top: 4px;
}

.current-time {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  margin-top: 8px;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  transition: border-color 0.2s ease;
}

.card:hover {
  border-color: #3a3a42;
}

.card h2 {
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-header h2 {
  margin-bottom: 0;
}

.view-all-btn {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* Accordion */
.accordion {
  width: 100%;
}

.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.accordion-header::-webkit-details-marker {
  display: none;
}

.accordion-header h2 {
  margin-bottom: 0;
}

.accordion-icon {
  width: 20px;
  height: 20px;
  position: relative;
  transition: transform 0.2s ease;
}

.accordion-icon::before,
.accordion-icon::after {
  content: "";
  position: absolute;
  background: var(--text-muted);
  border-radius: 1px;
}

.accordion-icon::before {
  width: 12px;
  height: 2px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.accordion-icon::after {
  width: 2px;
  height: 12px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
}

details.accordion[open] .accordion-icon::after {
  transform: translate(-50%, -50%) rotate(90deg);
  opacity: 0;
}

.accordion-content {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.hidden {
  display: none;
}

/* Connection status */
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.status {
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 100px;
  font-size: 0.8rem;
  letter-spacing: 0.01em;
}

.status.disconnected {
  background: rgba(229, 83, 83, 0.1);
  color: var(--error);
  border: 1px solid rgba(229, 83, 83, 0.2);
}

.status.connecting {
  background: rgba(240, 160, 80, 0.1);
  color: var(--warning);
  border: 1px solid rgba(240, 160, 80, 0.2);
}

.status.connected {
  background: rgba(44, 182, 125, 0.1);
  color: var(--success);
  border: 1px solid rgba(44, 182, 125, 0.2);
}

.battery {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.battery.hidden {
  display: none;
}

.battery-icon {
  display: inline-block;
  width: 20px;
  height: 11px;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  position: relative;
  margin-right: 6px;
}

.battery-icon::before {
  content: "";
  position: absolute;
  right: -5px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 6px;
  background: currentColor;
  border-radius: 0 1px 1px 0;
}

.battery-icon::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  bottom: 2px;
  background: currentColor;
  border-radius: 1px;
  width: var(--battery-level, 0%);
}

.battery-percent {
  font-weight: 500;
}

/* Buttons */
button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

button:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  background: var(--bg-hover);
  color: var(--text-muted);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Secondary button style */
button.secondary {
  background: var(--bg-hover);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

button.secondary:hover {
  background: #2a2a30;
  color: var(--text-primary);
  box-shadow: none;
}

/* Control groups */
.control-group {
  margin-bottom: 24px;
}

.control-group:last-child {
  margin-bottom: 0;
}

.control-group label {
  display: block;
  font-weight: 500;
  font-size: 0.9rem;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.control-group small {
  display: block;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* Toggle row */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.toggle-text {
  flex: 1;
}

.toggle-label {
  display: block;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.toggle-description {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Toggle switch */
input.toggle {
  appearance: none;
  width: 48px;
  height: 28px;
  background: var(--bg-hover);
  border-radius: 14px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

input.toggle::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all 0.2s ease;
}

input.toggle:checked {
  background: var(--accent);
}

input.toggle:checked::before {
  left: 24px;
  background: white;
}

/* Hours inputs */
.hours-inputs {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.hours-inputs.hidden {
  display: none;
}

.hours-inputs span {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.input-row span {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Inputs */
input[type="number"],
input[type="text"] {
  width: 80px;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  color: var(--text-primary);
  transition: all 0.2s ease;
}

input[type="text"] {
  width: 100%;
  box-sizing: border-box;
}

input[type="number"]:focus,
input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

input[type="number"]::placeholder,
input[type="text"]::placeholder {
  color: var(--text-muted);
}

/* Proverb index display */
#proverbIndex {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent);
  min-width: 40px;
}

/* Proverb navigation */
.proverb-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.proverb-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.proverb-text {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-primary);
  text-align: center;
  padding: 8px 0;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.proverb-reference {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-top: 12px;
  text-align: center;
  width: 100%;
}

.proverb-reference:empty {
  display: none;
}

.proverb-index {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.nav-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Proverbs textarea */
textarea {
  width: 100%;
  padding: 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text-primary);
  resize: vertical;
  margin-bottom: 14px;
  transition: all 0.2s ease;
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea::placeholder {
  color: var(--text-muted);
}

#proverbs button {
  width: 100%;
}

.upload-error {
  margin-top: 12px;
  padding: 12px 14px;
  background: rgba(229, 83, 83, 0.1);
  border: 1px solid rgba(229, 83, 83, 0.3);
  border-radius: 10px;
  color: var(--error);
  font-size: 0.9rem;
  line-height: 1.5;
}

.upload-error.hidden {
  display: none;
}

/* Log */
#log.card {
  background: var(--bg-secondary);
}

#logOutput {
  font-family: "SF Mono", "Fira Code", "JetBrains Mono", monospace;
  font-size: 0.75rem;
  background: var(--bg-primary);
  color: var(--text-secondary);
  padding: 14px;
  border-radius: 10px;
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border);
}

#logOutput:empty::before {
  content: "Waiting for connection...";
  color: var(--text-muted);
  font-style: italic;
}

.log-entry {
  margin-bottom: 6px;
  line-height: 1.5;
}

.log-entry.error {
  color: var(--error);
}

.log-entry.success {
  color: var(--success);
}

.log-entry.warning {
  color: var(--warning);
}

.log-entry .timestamp {
  color: var(--text-muted);
  margin-right: 10px;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Toast notification */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 12px 20px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1000;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success {
  border-color: var(--success);
  background: var(--bg-card);
}

.toast.success::before {
  content: "\2713";
  margin-right: 8px;
  color: var(--success);
  font-weight: 700;
}

.toast.error {
  border-color: var(--error);
  background: var(--bg-card);
}

.toast.error::before {
  content: "\2717";
  margin-right: 8px;
  color: var(--error);
  font-weight: 700;
}

/* Proverb Set Selector */
select {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394949c' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

select option {
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 10px;
}

/* Set details */
.set-details {
  margin-top: 16px;
  padding: 14px;
  background: var(--bg-secondary);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.set-description {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 8px;
}

.set-count {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Set actions */
.set-actions {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.set-actions button {
  flex: 1;
}

.current-set-indicator {
  font-size: 0.8rem;
  color: var(--success);
  padding: 6px 12px;
  background: rgba(44, 182, 125, 0.1);
  border: 1px solid rgba(44, 182, 125, 0.2);
  border-radius: 100px;
  white-space: nowrap;
}

/* Sync progress bar */
.sync-progress {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.sync-status-text {
  width: 100%;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.sync-progress.hidden {
  display: none;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-hover) 100%);
  border-radius: 4px;
  transition: width 0.15s ease-out;
}

.progress-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  min-width: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Onboarding section */
#onboarding {
  transition: opacity 0.3s ease, max-height 0.3s ease;
}

#onboarding.hidden {
  display: none;
}

.onboarding-intro {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 20px;
}

.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
}

.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.checklist-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.checklist-item:first-child {
  padding-top: 0;
}

.check-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  background: rgba(44, 182, 125, 0.15);
  border: 1.5px solid var(--success);
  position: relative;
}

.check-icon::after {
  content: "\2713";
  color: var(--success);
  font-size: 0.75rem;
  font-weight: 700;
}

.checklist-item.pending .check-icon {
  background: var(--bg-secondary);
  border-color: var(--border);
}

.checklist-item.pending .check-icon::after {
  content: "";
}

.checklist-item.failed .check-icon {
  background: rgba(229, 83, 83, 0.15);
  border-color: var(--error);
}

.checklist-item.failed .check-icon::after {
  content: "\2717";
  color: var(--error);
}

.check-content {
  flex: 1;
  min-width: 0;
}

.check-label {
  display: block;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.checklist-item.failed .check-label {
  color: var(--error);
}

.checklist-item.reminder {
  padding-left: 34px;
  align-items: center;
}

.checklist-item.reminder .check-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.checklist-item.reminder .check-text {
  flex: 1;
}

.checklist-item.reminder button {
  padding: 8px 16px;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.check-detail {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.check-detail code {
  background: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.75rem;
  color: var(--accent);
  word-break: break-all;
}

.onboarding-note {
  margin-top: 20px;
  padding: 14px;
  background: var(--bg-secondary);
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.onboarding-note strong {
  color: var(--accent);
}

/* Mobile refinements */
@media (max-width: 480px) {
  .container {
    padding: 16px 12px;
  }

  .card {
    padding: 16px;
    border-radius: 14px;
  }

  button {
    padding: 12px 20px;
  }
}
