:root {
  --bg:      linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  --bg2:     #080c14;
  --text:    #e2e8f0;
  --muted:   #64748b;
  --accent:  #7eb8f7;
  --green:   #22d3a0;
  --danger:  #f87171;
  --card:    rgba(255, 255, 255, 0.06);
  --border:  rgba(255, 255, 255, 0.10);
}

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

body {
  background: var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
}

/* ── Header ── */
.app-header {
  position: sticky;
  top: 0;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  flex-shrink: 0;
  z-index: 10;
}

.app-header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

#status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

#status-dot.error {
  background: var(--danger);
}

/* ── Navigation ── */
#app-nav {
  display: flex;
  flex-direction: row;
  gap: 6px;
  padding: 8px 12px;
  flex-shrink: 0;
}

.nav-tab {
  flex: 1;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
  padding: 8px 4px;
  white-space: nowrap;
}

.nav-tab.active {
  color: var(--accent);
  background: rgba(126, 184, 247, 0.15);
  border-color: rgba(126, 184, 247, 0.35);
}

/* ── Main content ── */
#app-main {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.view {
  display: none;
}

.view.active {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ── Search term styles ── */
.term-query {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.term-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 3px;
}

/* ── Buttons ── */
.btn {
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn:hover {
  opacity: 0.85;
}

.btn:active {
  opacity: 0.7;
}

.btn-primary {
  background: var(--accent);
  color: #000;
}

.btn-danger {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--border);
}

/* ── Toggle switch ── */
.toggle {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.thumb {
  position: absolute;
  inset: 0;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: background 0.2s;
}

.thumb::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}

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

.toggle input:checked + .thumb::before {
  transform: translateX(20px);
}

/* ── Add form ── */
.add-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 14px;
  border: 1px dashed var(--border);
}

/* ── Inputs ── */
input[type=text],
input[type=number],
input[type=password],
select {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

input[type=text]:focus,
input[type=number]:focus,
input[type=password]:focus,
select:focus {
  border-color: var(--accent);
}

input[type=text].error,
input[type=number].error {
  border-color: var(--danger);
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.form-row {
  display: flex;
  gap: 8px;
}

.form-row > * {
  flex: 1;
}

/* ── Sites grid ── */
.site-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.site-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: opacity 0.2s;
}

.site-card.inactive {
  opacity: 0.45;
}

.site-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.site-emoji {
  font-size: 1.4rem;
  line-height: 1;
  margin-bottom: 4px;
}

/* ── Notify status ── */
.notify-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  background: var(--card);
  border-radius: 14px;
  border: 1px solid var(--border);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.active {
  background: var(--green);
}

.status-dot.inactive {
  background: var(--muted);
}

/* ── Section title ── */
.section-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

.empty-state .icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

/* ── Auth screen ── */
#auth-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.auth-card {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 28px;
  width: 100%;
  max-width: 340px;
  text-align: center;
}

.auth-card h1 {
  font-size: 1.8rem;
  margin-bottom: 8px;
}

.auth-card p {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input-wrap input {
  flex: 1;
  padding-right: 44px;
}

#auth-eye {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  opacity: 0.5;
  transition: opacity 0.2s;
  padding: 4px;
  line-height: 1;
}

#auth-eye:hover { opacity: 1; }

.auth-error {
  color: var(--danger);
  font-size: 0.8rem;
  margin-top: 12px;
  min-height: 18px;
}

/* ── Finds view ── */
.finds-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

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

.ad-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-decoration: none;
}

.ad-card:hover {
  border-color: var(--accent);
  background: rgba(126, 184, 247, 0.05);
}

.ad-card.starred {
  border-color: rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.05);
}

.ad-body {
  flex: 1;
  min-width: 0;
}

.ad-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ad-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 3px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ad-price {
  color: var(--green);
  font-weight: 600;
}

.star-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.3rem;
  line-height: 1;
  padding: 2px 4px;
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity 0.15s, transform 0.15s;
}

.star-btn:hover { opacity: 1; }
.star-btn.active { opacity: 1; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 40, 60, 0.95);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 0.85rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
}

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

/* ── Interval / settings rows ── */
.interval-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--card);
  border-radius: 14px;
  border: 1px solid var(--border);
}

.interval-row label {
  font-size: 0.85rem;
  color: var(--muted);
}

.interval-row select {
  width: auto;
  padding: 6px 10px;
}

/* ── Notify view misc ── */
.notify-hint {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
  padding: 0 8px;
}

/* ── Term card left/right layout ── */
.term-left {
  flex: 1;
  min-width: 0;
}

.term-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* ── Site card left layout ── */
.site-info {
  display: flex;
  flex-direction: column;
}
