:root {
  --bg: #0d1117;
  --bg-elev: #161b22;
  --surface: #1a1f29;
  --surface-2: #21262d;
  --border: #2a313c;
  --text: #e6edf3;
  --text-2: #9aa4b2;
  --text-3: #6b7484;
  --primary: #6366f1;
  --primary-2: #8b5cf6;
  --planned: #6b7484;
  --progress: #4fc3f7;
  --done: #5ac8a5;
  --warning: #ffb74d;
  --radius-card: 12px;
  --radius-ctl: 8px;
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  font-family: 'Inter', 'Noto Sans TC', system-ui, sans-serif;
}

/* 亮色模式：完全依照品牌設計規範 */
:root[data-theme='light'] {
  --bg: #f5f7fa;        /* 頁面底色，非純白 */
  --bg-elev: #ffffff;   /* 卡片純白 */
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --border: #e2e8f0;
  --text: #333333;      /* 主要文字 */
  --text-2: #666666;    /* 次要文字 */
  --text-3: #94a3b8;
  --primary: #4a90e2;   /* 品牌藍 */
  --primary-2: #5b9ee8;
  --planned: #94a3b8;
  --progress: #4fc3f7;  /* 資訊 */
  --done: #5ac8a5;      /* 成功 */
  --warning: #ffb74d;   /* 警告 */
  --shadow: 0 2px 10px rgba(20, 40, 80, 0.08); /* 輕微擴散陰影 */
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-size: 16px; min-height: 100vh; }
.hidden { display: none !important; }
a { color: var(--progress); text-decoration: none; }

/* 登入 */
.login-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #1b2030 0%, var(--bg) 60%);
  padding: 24px;
}
:root[data-theme='light'] .login-overlay {
  background: radial-gradient(1200px 600px at 50% -10%, #e8eefb 0%, var(--bg) 60%);
}
.login-card {
  width: 100%; max-width: 360px; background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 32px 28px; box-shadow: var(--shadow); text-align: center;
}
.login-logo { font-size: 40px; }
.login-card h1 { font-size: 22px; margin: 12px 0 4px; }
.login-sub { color: var(--text-2); margin: 0 0 20px; font-size: 14px; }
.login-card input {
  width: 100%; padding: 12px 14px; margin-bottom: 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-ctl);
  font-size: 15px; outline: none;
}
.login-card input:focus { border-color: var(--primary); }
.login-error { color: #f06292; font-size: 13px; min-height: 18px; margin-top: 10px; }

/* 按鈕 */
.btn {
  border: none; border-radius: var(--radius-ctl); cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 600; padding: 9px 16px;
  transition: filter 0.15s, background 0.15s; white-space: nowrap;
}
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-block { width: 100%; padding: 11px; }
.btn-ghost { background: var(--surface-2); color: var(--text-2); }
.btn-ghost:hover { background: var(--border); color: var(--text); }
.btn-done { background: var(--done); color: #06281f; }
.btn-done:hover { filter: brightness(1.06); }
.btn-reopen { background: transparent; color: var(--warning); border: 1px solid var(--warning); }
.btn-danger { background: transparent; color: #f06292; border: 1px solid #f06292; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* 頂列 */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  background: var(--bg-elev); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; }
.brand-logo { font-size: 22px; }
.search-wrap { flex: 1; max-width: 460px; position: relative; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 14px; opacity: 0.7; }
.search-wrap input {
  width: 100%; padding: 9px 14px 9px 34px; background: var(--surface);
  color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-ctl);
  font-size: 14px; outline: none;
}
.search-wrap input:focus { border-color: var(--primary); }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* 版面：側邊欄 + 內容 */
.layout { display: grid; grid-template-columns: 240px 1fr; gap: 20px; padding: 22px 24px; align-items: start; max-width: 1500px; margin: 0 auto; }
.sidebar { display: flex; flex-direction: column; gap: 18px; position: sticky; top: 84px; }
.side-section {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-card); padding: 16px;
}
.side-title { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.side-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.side-item {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  border-radius: var(--radius-ctl); cursor: pointer; font-size: 14px;
  color: var(--text-2); transition: background 0.15s, color 0.15s;
}
.side-item:hover { background: var(--surface-2); color: var(--text); }
.side-item.active { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; }
.side-item .s-count {
  margin-left: auto; font-size: 12px; font-weight: 600; min-width: 22px; text-align: center;
  background: var(--surface-2); color: var(--text-2); padding: 1px 8px; border-radius: 10px;
}
.side-item.active .s-count { background: rgba(255, 255, 255, 0.25); color: #fff; }
.side-empty { color: var(--text-3); font-size: 13px; padding: 4px 12px; }

/* 卡片格 */
.content-head { margin-bottom: 14px; }
.result-info { color: var(--text-2); font-size: 13px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; align-items: start; }
.grid-empty { color: var(--text-3); text-align: center; padding: 60px 0; }

.card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-card); padding: 18px;
  display: flex; flex-direction: column; transition: border-color 0.15s, transform 0.1s;
}
.card:hover { border-color: var(--primary); transform: translateY(-2px); }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card-tagline { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 6px; }
.pill-status-planned { background: rgba(107, 116, 132, 0.18); color: var(--planned); }
.pill-status-progress { background: rgba(79, 195, 247, 0.16); color: var(--progress); }
.pill-status-done { background: rgba(90, 200, 165, 0.16); color: var(--done); }
.pill-cat { background: var(--surface-2); color: var(--text-2); }
.pill-draft { background: rgba(255, 183, 77, 0.16); color: var(--warning); }
.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: rgba(255, 183, 77, 0.16); color: var(--warning); }
.card-title { font-size: 16px; font-weight: 700; margin: 2px 0 4px; }
.card-meta { font-size: 12px; color: var(--text-3); margin-bottom: 8px; }
.card-summary { font-size: 13px; color: var(--text-2); line-height: 1.55; margin-bottom: 12px; }
.lists { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.list-block { font-size: 12.5px; }
.list-label { color: var(--text-3); font-weight: 600; margin-bottom: 3px; }
.list-block ul { margin: 0; padding-left: 18px; color: var(--text-2); }
.list-block li { margin: 2px 0; }
.list-done .list-label { color: var(--done); }
.list-todo .list-label { color: var(--warning); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tag { font-size: 11px; color: var(--text-2); background: var(--surface-2); padding: 2px 8px; border-radius: 6px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--border); padding-top: 12px; margin-top: auto; }
.card-date { font-size: 12px; color: var(--text-3); }
.card-actions { display: flex; gap: 8px; }

/* 新增待設計 視窗 */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50; padding: 24px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.55);
}
.modal-card {
  width: 100%; max-width: 440px; background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 26px; box-shadow: var(--shadow);
}
.modal-card h2 { margin: 0 0 4px; font-size: 19px; }
.modal-sub { color: var(--text-2); font-size: 13px; margin: 0 0 18px; line-height: 1.5; }
.modal-card label { display: block; font-size: 13px; color: var(--text-2); margin: 12px 0 5px; font-weight: 600; }
.modal-card .req { color: #f06292; margin-left: 2px; }
.modal-card input, .modal-card textarea, .modal-card select {
  width: 100%; padding: 10px 12px; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-ctl); font-size: 14px;
  outline: none; font-family: inherit; resize: vertical;
}
.modal-card input:focus, .modal-card textarea:focus, .modal-card select:focus { border-color: var(--primary); }

/* 分類設定清單 */
.cat-edit-list { list-style: none; margin: 6px 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; }
.cat-edit-list li { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: var(--radius-ctl); padding: 8px 12px; font-size: 14px; }
.cat-edit-list .cat-name { flex: 1; }
.cat-edit-list .cat-del { background: none; border: none; color: #f06292; cursor: pointer; font-size: 16px; line-height: 1; }
.cat-empty-hint { color: var(--text-3); font-size: 13px; padding: 8px 0; }
.repo-track-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.repo-track-list .repo-empty { color: var(--text-3); font-size: 13px; padding: 8px 0; }
.repo-label { display: flex; align-items: center; gap: 14px; width: 100%; padding: 9px 12px; background: var(--surface-2); border-radius: var(--radius-ctl); cursor: pointer; font-size: 13px; }
.repo-label input { flex-shrink: 0; width: 16px; height: 16px; margin: 0; }
.repo-label .repo-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.repo-label .repo-owner { flex-shrink: 0; color: var(--text-3); font-size: 12px; }
.cat-add-row { display: flex; gap: 8px; }
.cat-add-row input { flex: 1; padding: 9px 12px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-ctl); font-size: 14px; outline: none; }
.cat-add-row input:focus { border-color: var(--primary); }

/* 應用程式複選 */
.app-check-group { display: flex; flex-wrap: wrap; gap: 8px; }
.app-check {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-ctl); padding: 7px 12px; font-size: 13px; color: var(--text-2);
}
.app-check input { width: auto; margin: 0; }
.app-check-empty { color: var(--text-3); font-size: 13px; }

/* 開啟按鈕 */
.btn-open { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; }
.btn-open:hover { filter: brightness(1.08); }
.host-tip { font-size: 12px; color: var(--text-3); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* 說明視窗 */
.modal-help { max-width: 560px; max-height: 82vh; display: flex; flex-direction: column; }
.help-body { overflow-y: auto; padding-right: 6px; }
.help-body h3 { font-size: 15px; margin: 18px 0 6px; color: var(--text); }
.help-body h3:first-child { margin-top: 4px; }
.help-body p { font-size: 14px; color: var(--text-2); line-height: 1.6; margin: 0 0 6px; }
.help-body ul { margin: 0 0 6px; padding-left: 20px; }
.help-body li { font-size: 14px; color: var(--text-2); line-height: 1.6; margin: 4px 0; }
.help-body b { color: var(--text); }
.help-body code {
  background: var(--surface-2); color: var(--primary);
  padding: 1px 6px; border-radius: 5px; font-size: 13px;
}

.site-footer { text-align: center; color: var(--text-3); font-size: 13px; padding: 28px 0 36px; }

/* 響應式：手機與平板，側邊欄折到上方，卡片單欄 */
@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; padding: 12px 16px; }
  .search-wrap { order: 3; max-width: none; flex-basis: 100%; }
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .sidebar { position: static; }
  .grid { grid-template-columns: 1fr; }
}
