/* ===== CSS Variables & Reset ===== */
:root {
  --bg: #0f1117;
  --bg-card: #181b25;
  --bg-card-hover: #1e2230;
  --bg-input: #13161e;
  --border: #2a2e3d;
  --border-focus: #2dd4bf;
  --text: #e2e4ed;
  --text-muted: #8b8fa3;
  --text-dim: #5c6078;
  --accent: #2dd4bf;
  --accent-dim: #1a8a7a;
  --accent-glow: rgba(45, 212, 191, 0.15);
  --danger: #f87171;
  --danger-dim: #b94545;
  --warning: #fbbf24;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 12px rgba(0,0,0,0.3);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  --transition: 0.2s ease;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover, a:focus-visible { color: var(--text); text-decoration: underline; }

img, svg { display: block; max-width: 100%; }

.container { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 20px; }

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

.skip-link {
  position: absolute; top: -100%; left: 16px; z-index: 100;
  background: var(--accent); color: var(--bg); padding: 8px 16px;
  border-radius: var(--radius-sm); font-weight: 600;
}
.skip-link:focus { top: 16px; }

/* ===== Header ===== */
.site-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; gap: 16px;
}
.logo {
  display: flex; align-items: center; gap: 8px;
  color: var(--text); font-weight: 700; font-size: 1.1rem;
}
.logo:hover, .logo:focus-visible { text-decoration: none; color: var(--text); }
.logo-accent { color: var(--accent); }

.site-nav { display: flex; gap: 4px; }
.nav-link {
  padding: 6px 12px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 0.875rem; font-weight: 500;
}
.nav-link:hover, .nav-link:focus-visible,
.nav-link.active {
  color: var(--text); background: var(--bg-card-hover); text-decoration: none;
}

/* ===== Hero / Skill Bar ===== */
.hero-section { padding: 28px 0 8px; }
.skill-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.skill-select-wrap { flex: 1; min-width: 200px; }
.skill-select {
  width: 100%; padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-input);
  color: var(--text); font-size: 0.95rem; font-family: var(--font);
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%238b8fa3' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 36px;
}
.skill-select:focus { outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--accent-glow); }

.skill-new { display: flex; gap: 8px; }
.input-new-skill {
  padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-input);
  color: var(--text); font-size: 0.9rem; font-family: var(--font);
  width: 200px;
}
.input-new-skill:focus { outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--accent-glow); }

.empty-state {
  text-align: center; padding: 40px 20px; color: var(--text-muted);
  background: var(--bg-card); border-radius: var(--radius);
  border: 1px dashed var(--border); margin-top: 16px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 600; font-family: var(--font);
  border: 1px solid transparent; cursor: pointer;
  transition: all var(--transition); line-height: 1.2;
}
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-glow); }
.btn-primary { background: var(--accent); color: var(--bg); }
.btn-primary:hover { background: var(--accent-dim); }
.btn-accent { background: var(--accent); color: var(--bg); }
.btn-accent:hover { background: var(--accent-dim); }
.btn-outline { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-outline:hover { color: var(--text); border-color: var(--text-muted); }
.btn-danger { background: transparent; color: var(--danger); border-color: transparent; }
.btn-danger:hover { color: var(--danger-dim); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-full { width: 100%; }
.btn-add-milestone { padding: 10px 16px; font-size: 1.2rem; line-height: 1; align-self: flex-end; }

.btn-preset {
  padding: 4px 10px; border-radius: 999px; font-size: 0.78rem;
  background: var(--bg-input); color: var(--text-muted);
  border: 1px solid var(--border); cursor: pointer;
  font-family: var(--font); transition: all var(--transition);
}
.btn-preset:hover { color: var(--text); border-color: var(--accent); }

/* ===== Cards ===== */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
}
.card-title {
  font-size: 1rem; font-weight: 700; margin-bottom: 16px;
  color: var(--text);
}
.card-header-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; flex-wrap: wrap; gap: 8px;
}
.card-header-row .card-title { margin-bottom: 0; }
.history-actions { display: flex; gap: 8px; }

/* ===== Forms ===== */
.form-row { display: flex; gap: 12px; margin-bottom: 12px; }
.form-group { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.form-group-sm { flex: 0 0 100px; }
.form-label { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); }
.optional { font-weight: 400; color: var(--text-dim); }
.form-input {
  padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-input);
  color: var(--text); font-size: 0.9rem; font-family: var(--font);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus { outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--accent-glow); }

.preset-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.preset-label { font-size: 0.8rem; color: var(--text-dim); }

.form-row-milestone { align-items: flex-end; }

/* ===== Dashboard Grid ===== */
.tracker-section { padding: 20px 0 40px; }
.dashboard-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}
.dashboard-left { display: flex; flex-direction: column; gap: 20px; }
.dashboard-right { display: flex; flex-direction: column; gap: 20px; }

/* ===== Stats ===== */
.stats-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
}
.stat-box {
  background: var(--bg-input); border-radius: var(--radius-sm);
  padding: 16px; text-align: center; border: 1px solid var(--border);
}
.stat-box-streak { border-color: var(--accent); }
.stat-value {
  display: block; font-size: 1.6rem; font-weight: 800;
  color: var(--accent); line-height: 1.2;
}
.stat-label { display: block; font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

/* ===== Milestones ===== */
.milestone-list { list-style: none; display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.milestone-item {
  background: var(--bg-input); border-radius: var(--radius-sm);
  padding: 12px 14px; border: 1px solid var(--border);
}
.milestone-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.milestone-name { font-size: 0.875rem; font-weight: 600; }
.milestone-progress-text { font-size: 0.78rem; color: var(--text-muted); }
.milestone-bar-bg {
  width: 100%; height: 6px; background: var(--bg-card);
  border-radius: 999px; overflow: hidden;
}
.milestone-bar-fill {
  height: 100%; background: var(--accent); border-radius: 999px;
  transition: width 0.4s ease;
}
.milestone-complete .milestone-bar-fill { background: var(--warning); }
.milestone-complete .milestone-name { color: var(--warning); }

/* ===== History ===== */
.history-list { display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow-y: auto; }
.history-list::-webkit-scrollbar { width: 6px; }
.history-list::-webkit-scrollbar-track { background: var(--bg-input); border-radius: 3px; }
.history-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.history-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--bg-input); border: 1px solid var(--border);
}
.history-date { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; min-width: 80px; }
.history-hours { font-size: 0.875rem; font-weight: 700; color: var(--accent); min-width: 50px; }
.history-note { font-size: 0.8rem; color: var(--text-dim); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-delete { padding: 4px 8px; font-size: 0.75rem; }

.history-empty { text-align: center; padding: 24px; color: var(--text-dim); font-size: 0.875rem; }

/* ===== Guide Section ===== */
.guide-section { padding: 40px 0 60px; border-top: 1px solid var(--border); }
.section-title {
  font-size: 1.4rem; font-weight: 800; margin-bottom: 28px;
  text-align: center;
}
.guide-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px;
}
.guide-block {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
}
.guide-block-title {
  font-size: 1rem; font-weight: 700; margin-bottom: 10px;
  color: var(--accent);
}
.guide-block p { font-size: 0.9rem; color: var(--text-muted); line-height: 1.7; margin-bottom: 8px; }
.guide-block p:last-child { margin-bottom: 0; }

/* ===== Ad ===== */
.ad-wrap { padding: 8px 0; min-height: 0; }

/* ===== Footer ===== */
.site-footer {
  margin-top: auto; border-top: 1px solid var(--border);
  background: var(--bg-card); padding: 20px 0;
}
.footer-inner {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
}
.footer-copy { font-size: 0.8rem; color: var(--text-dim); }
.footer-nav { display: flex; gap: 16px; }
.footer-nav a { font-size: 0.8rem; color: var(--text-muted); }
.footer-nav a:hover { color: var(--text); }

/* ===== Print ===== */
@media print {
  .site-header, .site-footer, .ad-wrap, .card-log, .card-milestones,
  .history-actions, .btn, .preset-row, .form-row, form { display: none !important; }
  body { background: #fff; color: #000; }
  .card { border: 1px solid #ccc; background: #fff; }
  .stat-box { border: 1px solid #ccc; }
  .stat-value { color: #000; }
  .guide-section { display: none; }
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 640px) {
  .header-inner { height: auto; padding: 12px 0; flex-direction: column; gap: 8px; }
  .site-nav { flex-wrap: wrap; justify-content: center; }
  .skill-bar { flex-direction: column; align-items: stretch; }
  .skill-new { flex-direction: column; }
  .input-new-skill { width: 100%; }
  .form-row { flex-direction: column; }
  .form-group-sm { flex: 1; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 16px; }
  .guide-grid { grid-template-columns: 1fr; }
  .footer-inner { flex-direction: column; text-align: center; }
}

@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 1.3rem; }
}



/* Factory-injected deployment helpers. The AI owns the site design above this block. */
.ad-unit {
  width: min(100%, 720px);
  min-height: 120px;
  margin: 24px auto;
  display: block;
}

.legal-page {
  width: min(900px, calc(100% - 32px));
  margin: 40px auto;
}

.factory-fallback-nav {
  width: min(900px, calc(100% - 32px));
  margin: 24px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  font-size: 0.95rem;
}

.factory-fallback-nav a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}
