/* ═══════════════════════════════════════════════════════════════
   Tactify — Apple-inspired clean theme
   Accent: #0071e3 (Apple blue)
   Font: SF Pro / system stack
   ═══════════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --blue:        #0071e3;
  --blue-dark:   #0058b0;
  --blue-light:  rgba(0,113,227,0.08);
  --blue-ring:   rgba(0,113,227,0.22);

  --bg:          #f5f5f7;
  --surface:     #ffffff;
  --surface-2:   #f5f5f7;
  --text:        #1d1d1f;
  --text-2:      #6e6e73;
  --text-3:      #98989d;
  --border:      #d2d2d7;
  --border-light:#e8e8ed;

  --green:       #1d9954;
  --green-light: rgba(29,153,84,0.08);
  --amber:       #bf6b00;
  --amber-light: rgba(191,107,0,0.08);
  --red:         #d70015;
  --red-light:   rgba(215,0,21,0.08);

  --shadow-xs:   0 1px 2px rgba(0,0,0,0.06);
  --shadow-sm:   0 2px 8px rgba(0,0,0,0.08);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.12);

  --radius-sm:   6px;
  --radius:      10px;
  --radius-md:   14px;
  --radius-lg:   18px;

  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif;

  --primary:      var(--blue);
  --primary-dark: var(--blue-dark);
  --success:      var(--green);
  --warning:      var(--amber);
  --danger:       var(--red);
  --info:         var(--blue);
  --gray-icon:    var(--text-2);
}

[data-theme="dark"] {
  --bg:          #000000;
  --surface:     #1c1c1e;
  --surface-2:   #2c2c2e;
  --text:        #f5f5f7;
  --text-2:      #98989d;
  --text-3:      #6e6e73;
  --border:      #3a3a3c;
  --border-light:#2c2c2e;
  --shadow-xs:   0 1px 2px rgba(0,0,0,0.3);
  --shadow-sm:   0 2px 8px rgba(0,0,0,0.4);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.6);
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s, color 0.2s;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── App Header ─────────────────────────────────────────────── */
.app-header {
  background: rgba(255,255,255,0.82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 100;
}
[data-theme="dark"] .app-header {
  background: rgba(28,28,30,0.82);
}
.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.app-logo {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  transition: opacity 0.15s;
}
.app-logo:hover { opacity: 0.75; text-decoration: none; color: var(--text); }
.app-logo span { font-weight: 400; color: var(--text-2); font-size: 14px; }
.app-version { font-size: 11px; color: var(--text-3); font-weight: 400; }

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

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.btn:active { opacity: 0.75; }
.btn i { color: var(--text-2); font-size: 12px; }

.btn-primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); color: #fff; }
.btn-primary i { color: rgba(255,255,255,0.85); }

.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover { background: #b0000f; border-color: #b0000f; color: #fff; }

.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-sm i { font-size: 11px; }

.btn-icon {
  width: 32px; height: 32px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s;
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); }
.btn-icon i { color: inherit; }

/* ── Tab bar ────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.15s;
  user-select: none;
}
.tab-item:hover { color: var(--text); }
.tab-item.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab-item i { font-size: 13px; }

/* ── Container ──────────────────────────────────────────────── */
.container { max-width: 960px; margin: 0 auto; padding: 24px 20px; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 10px;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.18s;
}
.card:hover { box-shadow: var(--shadow-sm); }
.card-title { font-weight: 600; font-size: 15px; line-height: 1.4; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--text-2); margin-top: 4px; }
.card-description { font-size: 13px; color: var(--text-2); margin-top: 6px; line-height: 1.45; }
.card-actions { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; align-items: center; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge-primary  { background: var(--blue-light); color: var(--blue); border-color: var(--blue-ring); }
.badge-success  { background: var(--green-light); color: var(--green); border-color: rgba(29,153,84,0.2); }
.badge-warning  { background: var(--amber-light); color: var(--amber); border-color: rgba(191,107,0,0.2); }
.badge-danger   { background: var(--red-light); color: var(--red); border-color: rgba(215,0,21,0.2); }
.badge-gray     { background: var(--surface-2); color: var(--text-2); border-color: var(--border); }
.badge-completed { background: var(--green-light); color: var(--green); border-color: rgba(29,153,84,0.2); }

.id-badge {
  font-family: ui-monospace, 'SF Mono', monospace;
  font-size: 11px;
  color: var(--text-2);
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-2);
  margin-bottom: 5px;
  text-transform: uppercase;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-ring);
}
.form-textarea { min-height: 80px; resize: vertical; }
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 32px;
  cursor: pointer;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 15px;
}
.checkbox-group input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--blue);
  cursor: pointer;
}
.form-hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* Type-specific fields */
.type-fields {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 12px;
  border: 1px solid var(--border-light);
}
.type-fields-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: 12px;
}

/* ── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 300;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
@media (min-width: 640px) {
  .modal-overlay { align-items: center; padding: 24px; }
}
.modal {
  background: var(--surface);
  width: 100%;
  max-width: 640px;
  max-height: 92dvh;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
@media (min-width: 640px) {
  .modal { border-radius: var(--radius-lg); max-height: 88vh; }
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: var(--surface);
}
.modal-title { font-size: 17px; font-weight: 600; letter-spacing: -0.2px; }
.modal-close {
  width: 28px; height: 28px;
  border-radius: 50%; border: none;
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.12s;
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-shrink: 0;
  background: var(--surface-2);
}

/* ── Breadcrumb ─────────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 13px;
  overflow-x: auto;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
}
.bc-item {
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-2);
  transition: background 0.12s, color 0.12s;
}
.bc-item:hover { background: var(--surface-2); color: var(--text); }
.bc-item.active { background: var(--blue-light); color: var(--blue); font-weight: 500; cursor: default; }
.bc-item.result { font-style: italic; }
.bc-sep { color: var(--border); font-size: 11px; }

/* ── Task items ─────────────────────────────────────────────── */
.task-item {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 13px 15px;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-xs);
  margin-bottom: 8px;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.task-item:hover { box-shadow: var(--shadow-sm); border-color: var(--border); }
.task-item.completed { opacity: 0.55; background: var(--surface-2); }
.task-item.completed .task-title { text-decoration: line-through; color: var(--text-2); }
.task-item.scheduled-today  { border-left: 3px solid var(--amber); }
.task-item.scheduled-future { border-left: 3px solid var(--blue); }
.task-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
@media (max-width: 640px) { .task-row { display: grid; gap: 8px; } }
.task-info { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: 15px; line-height: 1.35; }
.task-description { font-size: 13px; color: var(--text-2); margin-top: 4px; }
.task-cost { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; color: var(--green); font-size: 13px; }
.task-actions { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }

/* ── Results grid ───────────────────────────────────────────── */
.results-section { margin-top: 16px; }
.results-label { font-size: 12px; font-weight: 500; color: var(--text-2); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.04em; }
.results-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.result-card {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 12px;
  border: 1px solid var(--border-light);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}
.result-card:hover { border-color: var(--blue); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.result-card.has-child { background: var(--blue-light); border-color: var(--blue-ring); }
.result-card-type { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); margin-bottom: 4px; }
.result-card-name { font-weight: 600; font-size: 14px; color: var(--text); }
.result-card-child { font-size: 12px; color: var(--blue); display: flex; align-items: center; gap: 4px; margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border-light); }
.result-card.lucky-way { border: 2px solid var(--green) !important; background: var(--green-light) !important; }
.result-card.lucky-way .result-card-type { color: var(--green); }

/* ── Task detail blocks ─────────────────────────────────────── */
.task-details-block { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border-light); font-size: 14px; }
.task-detail-item { display: grid; gap: 2px; margin-bottom: 10px; }
.task-detail-label { font-weight: 500; color: var(--text-2); min-width: 110px; flex-shrink: 0; font-size: 13px; }
.task-detail-value { color: var(--text); font-size: 14px; }
.task-detail-value a { color: var(--blue); }

/* ── Gallery ────────────────────────────────────────────────── */
.gallery-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.gallery-thumb {
  width: 80px; height: 80px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  border: 1.5px solid var(--border);
  flex-shrink: 0;
}
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.2s; }
.gallery-thumb:hover img { transform: scale(1.06); }
.gallery-upload {
  width: 80px; height: 80px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-3);
  transition: border-color 0.15s, color 0.15s;
}
.gallery-upload:hover { border-color: var(--blue); color: var(--blue); }

/* ── Lightbox ───────────────────────────────────────────────── */
.lightbox-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 1000;
  display: none; align-items: center; justify-content: center; flex-direction: column;
}
.lightbox-overlay.open { display: flex; }
.lightbox-img { max-width: 90vw; max-height: 75vh; border-radius: var(--radius-sm); }
.lightbox-caption { color: rgba(255,255,255,0.65); margin-top: 14px; font-size: 13px; max-width: 600px; text-align: center; }
.lightbox-controls { display: flex; gap: 12px; margin-top: 14px; }
.lightbox-arrow {
  background: rgba(255,255,255,0.12); border: none; border-radius: 50%;
  width: 44px; height: 44px;
  color: #fff; font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.lightbox-arrow:hover { background: rgba(255,255,255,0.25); }
.lightbox-close {
  position: absolute; top: 16px; right: 16px;
  background: rgba(255,255,255,0.12); border: none; border-radius: 50%;
  width: 40px; height: 40px;
  color: #fff; font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ── Attachments ────────────────────────────────────────────── */
.attachments-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.attachment-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 13px;
}
.attachment-item i { color: var(--text-2); }
.attachment-item a { flex: 1; color: var(--text); }
.attachment-item a:hover { color: var(--blue); text-decoration: none; }

/* ── Map ────────────────────────────────────────────────────── */
#task-map { width: 100%; height: 280px; border-radius: var(--radius); border: 1px solid var(--border-light); margin-top: 8px; overflow: hidden; }

/* ── Empty state ────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 64px 24px; color: var(--text-2); }
.empty-state i { font-size: 40px; color: var(--text-3); opacity: 0.5; margin-bottom: 16px; display: block; }
.empty-state div { font-size: 17px; font-weight: 600; color: var(--text-2); }
.empty-state p { margin-top: 6px; font-size: 14px; color: var(--text-3); }

/* ── Action bar ─────────────────────────────────────────────── */
.action-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }

/* ── Filter pills ───────────────────────────────────────────── */
.filter-bar { display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; margin-bottom: 16px; }
.filter-pill {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  white-space: nowrap;
  transition: all 0.12s;
  text-decoration: none;
}
.filter-pill:hover { border-color: var(--blue); color: var(--blue); text-decoration: none; }
.filter-pill.active { background: var(--blue-light); color: var(--blue); border-color: var(--blue-ring); }

/* ── Auth ───────────────────────────────────────────────────── */
.auth-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg); }
.auth-card { background: var(--surface); border-radius: var(--radius-lg); padding: 36px 32px; width: 100%; max-width: 400px; border: 1px solid var(--border-light); box-shadow: var(--shadow-lg); }
.auth-logo { text-align: center; font-size: 22px; font-weight: 700; margin-bottom: 28px; color: var(--blue); }
.auth-title { text-align: center; font-size: 20px; font-weight: 600; letter-spacing: -0.3px; margin-bottom: 24px; }
.auth-footer { text-align: center; margin-top: 24px; font-size: 14px; color: var(--text-2); }
.alert { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; }
.alert-danger  { background: var(--red-light); color: var(--red); border: 1px solid rgba(215,0,21,0.2); }
.alert-success { background: var(--green-light); color: var(--green); border: 1px solid rgba(29,153,84,0.2); }

/* ── Admin ──────────────────────────────────────────────────── */
.admin-sidebar { min-height: calc(100vh - 52px); background: var(--surface); border-right: 1px solid var(--border-light); width: 210px; flex-shrink: 0; padding: 12px 0; }
.admin-nav-item { display: flex; align-items: center; gap: 8px; padding: 9px 18px; color: var(--text-2); font-size: 14px; cursor: pointer; transition: background 0.12s, color 0.12s; }
.admin-nav-item:hover { background: var(--surface-2); color: var(--text); }
.admin-nav-item.active { background: var(--blue-light); color: var(--blue); font-weight: 500; }
.admin-layout { display: flex; }
.admin-content { flex: 1; padding: 24px; min-width: 0; }
.admin-section-title { font-size: 17px; font-weight: 600; letter-spacing: -0.2px; margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--border-light); }

/* ── Misc UI ────────────────────────────────────────────────── */
.bookmark-btn { background: none; border: none; cursor: pointer; color: var(--text-3); font-size: 16px; padding: 3px; transition: color 0.15s; }
.bookmark-btn:hover, .bookmark-btn.active { color: var(--amber); }

.context-box { padding: 9px 12px; background: var(--surface-2); border-radius: var(--radius-sm); margin-bottom: 12px; font-size: 13px; color: var(--text-2); border: 1px solid var(--border-light); }

.search-box { position: relative; }
.search-box i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; font-size: 13px; }
.search-box input { padding-left: 34px; }

.view-toggle { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.view-toggle-btn { padding: 6px 10px; background: var(--surface); border: none; cursor: pointer; color: var(--text-2); font-size: 14px; transition: background 0.12s, color 0.12s; }
.view-toggle-btn:hover { background: var(--surface-2); }
.view-toggle-btn.active { background: var(--blue); color: #fff; }

.theme-toggle { display: flex; align-items: center; gap: 5px; padding: 6px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; font-size: 13px; color: var(--text-2); transition: border-color 0.12s; }
.theme-toggle:hover { border-color: var(--blue); color: var(--blue); }
.theme-toggle i { font-size: 13px; }

.lang-toggle { display: flex; align-items: center; gap: 4px; padding: 6px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; color: var(--text-2); transition: border-color 0.12s; }
.lang-toggle:hover { border-color: var(--blue); color: var(--blue); }

.task-link { color: var(--blue); text-decoration: underline; cursor: pointer; font-weight: 500; }

.stat-box { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; background: var(--surface-2); border-radius: var(--radius-sm); border: 1px solid var(--border-light); font-size: 12px; color: var(--text-2); }
.stat-box.green { background: var(--green-light); border-color: rgba(29,153,84,0.2); color: var(--green); }

/* ── Mission state cards ────────────────────────────────────── */
.mission-card-completed { opacity: 0.65; background: var(--surface-2) !important; }
.mission-card-completed .card-title { color: var(--text-2); }
.badge-completed { background: var(--green-light); color: var(--green); border-color: rgba(29,153,84,0.2); }

.btn-uncomplete { background: var(--amber-light); color: var(--amber); border-color: rgba(191,107,0,0.25); font-weight: 500; }
.btn-uncomplete:hover { background: rgba(191,107,0,0.15); color: var(--amber); }

.mission-completed-card { opacity: 0.6; background: var(--surface-2) !important; border-style: dashed !important; }
.mission-completed-card:hover { opacity: 0.85; }
.mission-completed-card .card-title { text-decoration: line-through; color: var(--text-2); }

/* ── Mission URL ────────────────────────────────────────────── */
.mission-url-row { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.mission-url-text { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; font-family: ui-monospace, monospace; }
.btn-copy-url {
  width: 26px; height: 26px; padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; color: var(--text-2);
  font-size: 12px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color 0.12s, color 0.12s;
}
.btn-copy-url:hover { border-color: var(--blue); color: var(--blue); }

/* ── Notification bell ──────────────────────────────────────── */
.notif-bell { position: relative; cursor: pointer; padding: 6px 8px; border-radius: var(--radius-sm); transition: background 0.12s; }
.notif-bell:hover { background: var(--surface-2); }
.notif-badge { position: absolute; top: 2px; right: 2px; background: var(--red); color: #fff; font-size: 9px; font-weight: 700; border-radius: 10px; padding: 1px 4px; min-width: 15px; text-align: center; }
.notif-panel {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  width: 300px; max-height: 380px; overflow-y: auto;
  z-index: 200; display: none;
}
.notif-panel.open { display: block; }
.notif-panel-header { padding: 12px 16px; border-bottom: 1px solid var(--border-light); display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 600; }
.notif-item { display: block; padding: 11px 16px; border-bottom: 1px solid var(--border-light); transition: background 0.12s; text-decoration: none; }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-2); text-decoration: none; }
.notif-item-unread { background: var(--blue-light); }
.notif-item-title { font-size: 13px; font-weight: 500; color: var(--text); }
.notif-item-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ── Library ────────────────────────────────────────────────── */
.lib-header {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-xs);
}
.lib-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.lib-title    { font-size: 17px; font-weight: 600; letter-spacing: -0.2px; }
.lib-subtitle { font-size: 13px; color: var(--text-2); margin-top: 2px; }

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

/* Category pill */
.lib-cat-pill {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}

/* ── LIST ROW ───────────────────────────────────────────────── */
.lib-row {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  transition: box-shadow 0.18s, border-color 0.18s;
}
.lib-row:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border);
}

.lib-row-main {
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
}

.lib-row-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.lib-row-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  text-decoration: none;
  line-height: 1.3;
  transition: color 0.12s;
}
.lib-row-title:hover { color: var(--blue); text-decoration: none; }

.lib-row-desc-inline {
  font-size: 13px;
  color: var(--text-3);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.lib-row-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.lib-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 16px;
  border-left: 1px solid var(--border-light);
  background: var(--surface-2);
  flex-shrink: 0;
  align-self: stretch;
}

/* ── Meta items ─────────────────────────────────────────────── */
.lib-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
}
.lib-meta-item i { font-size: 11px; color: var(--text-3); }
.lib-meta-cost   { color: var(--green) !important; font-weight: 500; }
.lib-meta-cost i { color: var(--green) !important; }

/* ── CARD VIEW ──────────────────────────────────────────────── */
.lib-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}
.lib-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.18s, border-color 0.18s, transform 0.15s;
}
.lib-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border);
  transform: translateY(-2px);
}
.lib-card-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.lib-card-title { font-weight: 600; font-size: 15px; line-height: 1.35; letter-spacing: -0.1px; }
.lib-card-desc { font-size: 13px; color: var(--text-2); line-height: 1.45; }
.lib-card-meta { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 8px; border-top: 1px solid var(--border-light); }
.lib-card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border-light); }

/* ── Mobile ─────────────────────────────────────────────────── */
.hide-mobile { }
.hide-xs { }

@media (max-width: 640px) {
  body { font-size: 14px; }
  .container { padding: 14px 14px; }
  .hide-mobile { display: none !important; }
  .hide-xs     { display: none !important; }
  .admin-sidebar { display: none; }

  /* Header */
  .header-inner { padding: 0 14px; height: 48px; }
  .app-logo { font-size: 15px; }
  .header-actions { gap: 4px; }
  .btn { padding: 6px 10px; font-size: 13px; }
  .btn-sm { padding: 4px 8px; font-size: 12px; }

  /* Cards */
  .card { padding: 12px 14px; }
  .task-item { padding: 11px 13px; }

  /* Results — 2 cols */
  .results-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .result-card { padding: 10px 8px; }

  /* Modal — bottom sheet */
  .modal-overlay { align-items: flex-end !important; padding: 0 !important; }
  .modal { border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important; max-height: 92dvh; }

  /* Forms */
  .form-row { grid-template-columns: 1fr !important; }

  /* Library rows — stack */
  .lib-row { flex-direction: column; align-items: stretch; }
  .lib-row-head { flex-wrap: wrap; }
  .lib-row-desc-inline { white-space: normal; }
  .lib-row-actions { border-left: none; border-top: 1px solid var(--border-light); align-self: auto; }
  .lib-cards-grid { grid-template-columns: 1fr; }

  /* Tab, filter */
  .tab-item { padding: 10px 14px; font-size: 13px; }
  .filter-bar { flex-wrap: nowrap; }
  .filter-pill { flex-shrink: 0; font-size: 12px; padding: 4px 10px; }
}

@media (min-width: 641px) and (max-width: 900px) {
  .container { padding: 18px 16px; }
  .lib-row-desc-inline { max-width: 220px; }
}

/* Task card / detail layout classes */
.task-badges-row     { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin-bottom: 10px; }
.task-detail-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 12px; }
