/* ── Reset & Base ───────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0A0B0F;
  --surface:   #171B21;
  --surface-2: #1E2530;
  --border:    #2A313B;
  --divider:   rgba(42,49,59,0.6);
  --text:      #E6EDF3;
  --text-2:    #8B949E;
  --text-3:    #59616B;
  --accent:    #7C3AED;
  --accent-hv: #6D28D9;
  --accent-fg: #ffffff;
  --success:   #10b981;
  --warn:      #f59e0b;
  --danger:    #ef4444;
  --info:      #3b82f6;
}
[data-theme="light"] {
  --bg:        #F0F2F5;
  --surface:   #ffffff;
  --surface-2: #F8FAFC;
  --border:    #E2E8F0;
  --divider:   rgba(226,232,240,0.8);
  --text:      #0F172A;
  --text-2:    #475569;
  --text-3:    #94A3B8;
}

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: monospace;
  background: var(--surface-2);
  padding: 1px 4px; border-radius: 3px; font-size: 12px;
}

/* ── Layout helpers ─────────────────────────────────── */
.container { max-width: 800px; margin: 0 auto; padding: 0 12px 12px; }
.flex      { display: flex; }
.flex-1    { flex: 1; }
.gap-2     { gap: 8px; }
.mb-1      { margin-bottom: 4px; }
.mb-3      { margin-bottom: 12px; }
.mt-3      { margin-top: 12px; }
.hidden    { display: none !important; }

/* ── Header ─────────────────────────────────────────── */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.header-logo { display: flex; align-items: center; gap: 10px; }
.logo-icon {
  width: 36px; height: 36px; background: var(--accent); border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0;
}
.logo-title { font-size: 15px; font-weight: 700; color: var(--text); }
.logo-sub   { font-size: 11px; color: var(--text-3); }
.header-actions { display: flex; gap: 4px; }
.icon-btn {
  width: 36px; height: 36px; border: none; background: none; cursor: pointer;
  font-size: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; transition: background 0.15s;
}
.icon-btn:hover { background: var(--surface-2); }

/* ── Card ───────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 600; color: var(--text);
}
.card-body  { padding: 12px 16px; }
.count-badge { font-size: 11px; color: var(--text-3); }

/* ── Buttons ────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 16px; border-radius: 8px; border: none;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all 0.15s; white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hv); }
.btn-publish  { background: rgba(16,185,129,0.15); color: var(--success); }
.btn-publish:hover:not(:disabled) { background: rgba(16,185,129,0.25); }
.btn-del      { background: rgba(239,68,68,0.12); color: var(--danger); }
.btn-del:hover:not(:disabled) { background: rgba(239,68,68,0.22); }
.btn-ghost    { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface); }
.btn-sm       { padding: 5px 10px; font-size: 12px; border-radius: 6px; }

/* ── Input ──────────────────────────────────────────── */
.input {
  padding: 8px 12px; border-radius: 8px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); font-size: 13px;
  outline: none; transition: border-color 0.15s;
}
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--text-3); }

/* ── Platform Pills ─────────────────────────────────── */
.pills-row { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  padding: 5px 10px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-2);
  font-size: 12px; font-weight: 500; cursor: pointer; transition: all 0.15s;
}
.pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Stats ──────────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; padding: 12px 0;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 8px; text-align: center;
}
.stat-val    { font-size: 26px; font-weight: 700; color: var(--text); }
.stat-lbl    { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.stat-card.ready .stat-val { color: var(--info); }
.stat-card.done  .stat-val { color: var(--success); }
.stat-card.fail  .stat-val { color: var(--danger); }

/* ── Tabs ───────────────────────────────────────────── */
.tab-bar {
  display: flex; gap: 4px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 4px; margin-bottom: 12px;
}
.tab-btn {
  flex: 1; padding: 7px 4px; border: none; background: none;
  color: var(--text-2); font-size: 12px; font-weight: 500;
  border-radius: 6px; cursor: pointer; transition: all 0.15s;
}
.tab-btn.active { background: var(--accent); color: #fff; }

/* ── Status Badges ──────────────────────────────────── */
.badge { display: inline-block; padding: 3px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-ready { background: rgba(59,130,246,0.15);  color: var(--info); }
.badge-pub   { background: rgba(245,158,11,0.15); color: var(--warn); }
.badge-done  { background: rgba(16,185,129,0.15); color: var(--success); }
.badge-fail  { background: rgba(239,68,68,0.15);  color: var(--danger); }

/* ── Link rows ──────────────────────────────────────── */
.link-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--divider); transition: background 0.1s;
}
.link-row:last-child { border-bottom: none; }
.link-row:hover { background: var(--surface-2); }
.thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); flex-shrink: 0; }
.thumb-placeholder {
  width: 44px; height: 44px; border-radius: 8px; flex-shrink: 0;
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.link-info  { flex: 1; min-width: 0; }
.link-name  { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-url   { font-size: 11px; color: var(--accent); display: block; margin-top: 2px; }
.link-memo  { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.post-link  { font-size: 11px; color: var(--text-2); display: block; margin-top: 2px; }
.link-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.plat-st    { font-size: 10px; color: var(--text-3); text-align: right; }

/* ── File rows ──────────────────────────────────────── */
.file-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--divider); transition: background 0.1s;
}
.file-row:last-child { border-bottom: none; }
.file-row:hover { background: var(--surface-2); }
.file-info { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.file-icon { font-size: 20px; flex-shrink: 0; }
.file-name { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.file-meta { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* Blog-specific row */
.blog-row       { flex-wrap: wrap; align-items: flex-start; }
.blog-controls  { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; margin-top: 4px; }
.mode-btns      { display: flex; gap: 3px; }
.mode-btn {
  width: 28px; height: 26px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-2);
  font-size: 12px; font-weight: 700; border-radius: 5px; cursor: pointer; transition: all 0.15s;
}
.mode-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.prod-select {
  font-size: 11px; padding: 4px 6px; border-radius: 6px;
  background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--border); max-width: 130px;
}
.prod-select:focus { outline: none; border-color: var(--accent); }

/* ── Empty & Hint ───────────────────────────────────── */
.empty-msg { padding: 32px 16px; text-align: center; color: var(--text-3); font-size: 13px; }
.hint-bar  { padding: 8px 16px; font-size: 11px; color: var(--text-3); border-bottom: 1px solid var(--border); }
.label-sm  { font-size: 11px; font-weight: 500; color: var(--text-3); }

/* ── No-server screen ───────────────────────────────── */
#no-server {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(100vh - 62px); padding: 24px;
}
.no-server-inner { text-align: center; max-width: 320px; }
.no-server-icon  { font-size: 64px; margin-bottom: 16px; }
.no-server-title { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.no-server-desc  { font-size: 13px; color: var(--text-2); line-height: 1.6; margin-bottom: 16px; }
.no-server-steps {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 16px; margin-bottom: 20px; text-align: left;
}
.step { font-size: 12px; color: var(--text-2); padding: 4px 0; }

/* ── Settings overlay ───────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.72);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.overlay-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 24px; width: 100%; max-width: 380px;
}
.overlay-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.overlay-desc  { font-size: 12px; color: var(--text-2); line-height: 1.6; }
.overlay-hint  { font-size: 11px; color: var(--text-3); margin-top: 8px; }

/* ── Toast ──────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  left: 50%; transform: translateX(-50%) translateY(80px);
  opacity: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: 24px; padding: 10px 20px; font-size: 13px; font-weight: 500; color: var(--text);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4); transition: all 0.3s; z-index: 300; white-space: nowrap;
}
#toast.show     { transform: translateX(-50%) translateY(0); opacity: 1; }
#toast.toast-ok    { border-color: var(--success); color: var(--success); }
#toast.toast-error { border-color: var(--danger);  color: var(--danger);  }
#toast.toast-warn  { border-color: var(--warn);    color: var(--warn);    }
