:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #0f766e;
  --primary-hover: #0d9488;
  --primary-soft: #ccfbf1;
  --primary-soft-text: #115e59;
  --accent: #10b981;
  --amber: #d97706;
  --amber-bg: #fef3c7;
  --danger: #dc2626;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
  --radius: 16px;
  --radius-sm: 11px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #090e17;
    --surface: #111827;
    --surface-subtle: #1e293b;
    --border: #263349;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #14b8a6;
    --primary-hover: #2dd4bf;
    --primary-soft: rgba(20, 184, 166, 0.18);
    --primary-soft-text: #5eead4;
    --accent: #34d399;
    --amber: #fbbf24;
    --amber-bg: rgba(251, 191, 36, 0.14);
    --danger: #f87171;
    --shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  }
}

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

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

.app-shell {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 14px calc(28px + env(safe-area-inset-bottom, 0px));
}

/* Top Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 2px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  flex-shrink: 0;
}

.brand-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-sub {
  margin: 1px 0 0;
  font-size: 0.74rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}

.icon-btn:active {
  transform: scale(0.96);
}

/* Google Sync Status & Settings Pill */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  max-width: 190px;
  flex-shrink: 0;
}

.status-pill-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.status-gear {
  flex-shrink: 0;
  opacity: 0.72;
}

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

.status-connected .status-dot {
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.22);
}

.status-expired {
  border-color: var(--amber);
  background: var(--amber-bg);
}

.status-expired .status-dot {
  background: var(--amber);
}

/* Main Navigation Tabs */
.main-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  margin-bottom: 12px;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 40px;
  padding: 0 6px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.tab-btn.active {
  background: var(--primary);
  color: #ffffff;
}

@media (prefers-color-scheme: dark) {
  .tab-btn.active {
    color: #042f2e;
  }
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--amber);
  color: #0f172a;
  font-size: 0.72rem;
  font-weight: 700;
}

/* Install Banner */
.install-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary-soft-text);
  font-size: 0.84rem;
}

/* 3 Capture Mode Buttons */
.capture-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-bottom: 12px;
}

.capture-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 13px 8px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.1s ease, border-color 0.15s ease;
}

.capture-card:active {
  transform: scale(0.97);
}

.capture-primary {
  background: linear-gradient(145deg, #0f766e, #065f46);
  border-color: transparent;
  color: #ffffff;
}

.capture-title {
  font-size: 0.86rem;
  font-weight: 700;
  margin-top: 2px;
}

.capture-sub {
  font-size: 0.7rem;
  opacity: 0.8;
}

/* Receipt Preview & Gemini Status Strip */
.receipt-strip {
  padding: 12px;
  margin-bottom: 12px;
  border-radius: var(--radius);
  border: 1.5px solid var(--primary);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.receipt-strip.scanning {
  animation: pulseBorder 1.3s infinite ease-in-out;
}

@keyframes pulseBorder {
  0%, 100% {
    border-color: var(--primary);
  }
  50% {
    border-color: var(--amber);
  }
}

.receipt-preview-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.receipt-thumb-wrap {
  width: 64px;
  height: 76px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}

.receipt-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.receipt-pdf-badge {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--primary);
}

.receipt-meta {
  flex: 1;
  min-width: 0;
}

.gemini-status {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 2px;
}

.receipt-file-info {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.receipt-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-ghost-sm {
  padding: 4px 9px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}

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

/* Form Cards */
.expense-form {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.card-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 14px;
  box-shadow: var(--shadow);
}

.field-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 7px;
}

.optional-tag {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

/* Hero Amount Input */
.amount-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.myr-eq-badge {
  font-size: 0.82rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-soft-text);
}

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

.currency-select {
  height: 50px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text);
  font-size: 0.98rem;
  font-weight: 700;
}

.amount-input {
  flex: 1;
  min-width: 0;
  height: 50px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text);
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.amount-input:focus,
.text-input:focus,
.currency-select:focus {
  outline: none;
  border-color: var(--primary);
}

/* FX Strip */
.fx-strip {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.fx-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.85rem;
}

.fx-rate-input {
  width: 115px;
  height: 36px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: right;
}

.fx-hint {
  margin: 5px 0 0;
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* Date & Description */
.two-col-fields {
  display: grid;
  grid-template-columns: 142px 1fr;
  gap: 10px;
}

@media (max-width: 420px) {
  .two-col-fields {
    grid-template-columns: 1fr;
  }
}

.text-input {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text);
  font-size: 1rem; /* >=16px prevents mobile auto-zoom */
  font-family: inherit;
}

/* Tactile Chips for Category & Payment Method */
.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  min-height: 40px;
  max-width: 100%;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  text-align: left;
  line-height: 1.25;
  cursor: pointer;
  transition: all 0.12s ease;
}

.chip:active {
  transform: scale(0.96);
}

.chip.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

@media (prefers-color-scheme: dark) {
  .chip.selected {
    color: #042f2e;
  }
}

.section-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.selected-pill-hint {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 7px;
}

.cards-drawer-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 9px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px dashed var(--border);
  background: var(--surface-subtle);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}

.cards-grid {
  margin-top: 9px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
}

.cards-grid .chip {
  border-radius: 10px;
  text-align: left;
  padding: 8px 11px;
  font-size: 0.82rem;
  line-height: 1.25;
}

/* Primary Save Button */
.btn-submit {
  width: 100%;
  height: 54px;
  border: none;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #0f766e, #059669);
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(15, 118, 110, 0.35);
}

.btn-submit:disabled {
  opacity: 0.6;
  cursor: wait;
}

.btn-submit:active:not(:disabled) {
  transform: scale(0.99);
}

/* A4 Multi-Receipt Batch Tab */
.batch-capture-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
  margin-bottom: 10px;
}

.batch-hint-banner {
  margin: 0 0 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px dashed var(--border);
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.batch-default-bar {
  margin-bottom: 12px;
  padding: 11px 13px;
}

.batch-default-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.batch-default-controls {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  min-width: 210px;
}

.batch-select {
  height: 40px;
  padding: 0 9px;
  border-radius: 9px;
  border: 1.5px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
  width: 100%;
  min-width: 0;
}

.batch-items-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.batch-item-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 12px 13px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.batch-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.batch-item-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.batch-pos-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-soft-text);
}

.batch-fx-badge {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--primary);
}

.batch-grid-top {
  display: grid;
  grid-template-columns: 138px 86px 1fr;
  gap: 7px;
}

@media (max-width: 410px) {
  .batch-grid-top {
    grid-template-columns: 1fr 1fr;
  }
  .batch-grid-top .batch-date-input {
    grid-column: 1 / -1;
  }
}

.batch-grid-two {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 7px;
}

@media (max-width: 440px) {
  .batch-grid-two {
    grid-template-columns: 1fr;
  }
}

.batch-input {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 6px 10px;
  border-radius: 9px;
  border: 1.5px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}

.batch-amount-input {
  font-weight: 700;
}

.batch-input:focus,
.batch-select:focus {
  outline: none;
  border-color: var(--primary);
}

/* History & Summary Tab */
.pending-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
  border-radius: var(--radius);
  border: 1.5px solid var(--amber);
  background: var(--amber-bg);
}

.pending-sub {
  margin: 3px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.summary-card {
  margin-bottom: 12px;
}

.summary-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.month-select {
  height: 40px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1.5px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 700;
}

.summary-total-box {
  text-align: right;
}

.summary-big-total {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
}

.breakdown-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.bar-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 6px 8px;
  margin: 0 -8px;
  width: calc(100% + 16px);
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, opacity 0.14s ease;
}

.bar-row:hover {
  background: rgba(20, 184, 166, 0.07);
}

.bar-row.is-active {
  background: rgba(20, 184, 166, 0.14);
  border-color: rgba(20, 184, 166, 0.65);
}

.bar-row.is-dimmed {
  opacity: 0.46;
}

.bar-cat-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.bar-active-tag {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--primary);
  color: #ffffff;
  flex-shrink: 0;
}

.active-filter-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(20, 184, 166, 0.5);
  background: rgba(20, 184, 166, 0.11);
}

.active-filter-text {
  font-size: 0.79rem;
  font-weight: 600;
  color: var(--text);
  min-width: 0;
}

.active-filter-clear-btn {
  padding: 3px 8px;
  border: 1px solid rgba(20, 184, 166, 0.55);
  border-radius: 999px;
  background: transparent;
  color: var(--primary);
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

.bar-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 600;
}

.bar-track {
  height: 7px;
  border-radius: 999px;
  background: var(--surface-subtle);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
}

.summary-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.section-heading {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 700;
}

.history-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.history-bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 10px;
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.08);
}

.history-bulk-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-bulk-count {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}

.btn-danger-sm {
  height: 34px;
  padding: 0 12px;
  border: none;
  border-radius: 8px;
  background: var(--danger);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-danger-sm:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.txn-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  transition: border-color 0.14s ease, background 0.14s ease;
}

.txn-item.selectable {
  cursor: pointer;
  user-select: none;
}

.txn-item.selected {
  border-color: rgba(239, 68, 68, 0.7);
  background: rgba(239, 68, 68, 0.09);
}

.txn-check-wrap {
  display: flex;
  align-items: center;
  padding-top: 2px;
  flex-shrink: 0;
}

.txn-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--danger);
  cursor: pointer;
}

.txn-right-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.confirm-dialog-box {
  width: min(390px, 92vw);
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}

.confirm-dialog-title {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 800;
}

.confirm-dialog-msg {
  margin: 0 0 16px;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.confirm-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.txn-left {
  min-width: 0;
  flex: 1;
}

.txn-desc {
  font-size: 0.92rem;
  font-weight: 700;
  margin-bottom: 3px;
}

.txn-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  font-size: 0.73rem;
  color: var(--text-muted);
}

.txn-tag {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.txn-tag.pending {
  border-color: var(--amber);
  color: var(--amber);
}

.txn-right {
  text-align: right;
  flex-shrink: 0;
}

.txn-amount {
  font-size: 0.98rem;
  font-weight: 800;
}

.txn-link {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.74rem;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.txn-delete-btn {
  margin-top: 4px;
  padding: 2px 6px;
  border: none;
  background: transparent;
  color: var(--danger);
  font-size: 0.73rem;
  cursor: pointer;
}

.empty-state {
  padding: 22px 10px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* Buttons */
.btn-small,
.btn-primary-sm {
  height: 38px;
  padding: 0 14px;
  border: none;
  border-radius: 9px;
  background: var(--primary);
  color: #ffffff;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

@media (prefers-color-scheme: dark) {
  .btn-small,
  .btn-primary-sm {
    color: #042f2e;
  }
}

.btn-outline-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text);
  font-size: 0.81rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(2, 6, 23, 0.68);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

@media (min-width: 600px) {
  .modal-backdrop {
    align-items: center;
    padding: 16px;
  }
}

.modal-sheet {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (min-width: 600px) {
  .modal-sheet {
    border-radius: 20px;
  }
}

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

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

.modal-body {
  padding: 14px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.settings-block {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.settings-block:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.settings-block h3 {
  margin: 0 0 4px;
  font-size: 0.94rem;
}

.settings-help {
  margin: 0 0 9px;
  font-size: 0.79rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.settings-help a {
  color: var(--primary);
  font-weight: 600;
}

.input-with-btn {
  display: flex;
  gap: 8px;
}

.mt-sm {
  margin-top: 10px;
}

.settings-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.settings-connected-note {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: var(--primary);
  font-weight: 600;
}

.mono-textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84rem;
  line-height: 1.45;
}

/* Lightbox */
.lightbox-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px;
  max-width: 96vw;
  max-height: 92vh;
}

.lightbox-img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 12px;
  object-fit: contain;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 200;
  max-width: 92vw;
  padding: 11px 16px;
  border-radius: 12px;
  background: #0f172a;
  color: #f8fafc;
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

@media (prefers-color-scheme: dark) {
  .toast {
    background: #f8fafc;
    color: #0f172a;
  }
}
