/* ---------- Theme colors ---------- */
:root, :root[data-theme="light"] {
  --bg: #eef3fb;
  --grid: rgba(30, 80, 170, .07);
  --blob-opacity: .45;
  --card: rgba(255, 255, 255, .78);
  --card-border: rgba(255, 255, 255, .9);
  --card-shadow: 0 10px 40px rgba(20, 50, 110, .12);
  --text: #15203a;
  --muted: #5a6680;
  --accent: #1565d8;
  --accent-strong: #0f52b5;
  --accent-soft: rgba(21, 101, 216, .1);
  --input: rgba(255, 255, 255, .9);
  --line: rgba(20, 50, 110, .14);
  --danger: #c62f3c;
  --success-bg: #e3f6ea; --success-text: #17643a;
  --error-bg: #fde7e9; --error-text: #9c1f2b;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #060a16;
  --grid: rgba(110, 160, 255, .07);
  --blob-opacity: .55;
  --card: rgba(14, 21, 40, .72);
  --card-border: rgba(120, 160, 255, .14);
  --card-shadow: 0 10px 40px rgba(0, 0, 0, .45);
  --text: #e7ecf7;
  --muted: #95a1bd;
  --accent: #5ea2ff;
  --accent-strong: #84b8ff;
  --accent-soft: rgba(94, 162, 255, .14);
  --input: rgba(5, 10, 24, .6);
  --line: rgba(120, 160, 255, .16);
  --danger: #ff6b78;
  --success-bg: rgba(40, 170, 100, .16); --success-text: #7fe0a8;
  --error-bg: rgba(220, 50, 70, .18); --error-text: #ff9aa4;
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  transition: background .3s, color .3s;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { margin: 0; font-size: clamp(2rem, 5vw, 2.8rem); line-height: 1.1; letter-spacing: -.02em; }
h2 { margin: 0 0 14px; font-size: .8rem; text-transform: uppercase; letter-spacing: .14em; color: var(--accent); }
h3 { margin: 0; font-size: 1.02rem; }
h3 span { font-weight: 400; color: var(--muted); }
p { margin: 4px 0; }
ul { margin: 6px 0 0; padding-left: 20px; }
li { margin: 2px 0; }
.muted { color: var(--muted); }

/* ---------- Animated background ---------- */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: var(--bg); transition: background .3s; }
.bg::after {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px),
                    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 20%, #000 40%, transparent 100%);
          mask-image: radial-gradient(ellipse 80% 70% at 50% 20%, #000 40%, transparent 100%);
}
.blob {
  position: absolute; border-radius: 50%; filter: blur(90px); opacity: var(--blob-opacity);
  animation: drift 24s ease-in-out infinite alternate;
}
.b1 { width: 560px; height: 560px; background: #1d6ff2; top: -180px; left: -140px; }
.b2 { width: 480px; height: 480px; background: #22c3ee; top: 35%; right: -180px; animation-delay: -8s; }
.b3 { width: 440px; height: 440px; background: #5b45ff; bottom: -200px; left: 20%; animation-delay: -16s; }
@keyframes drift {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(80px, 60px) scale(1.15); }
  100% { transform: translate(-40px, 100px) scale(.95); }
}
@media (prefers-reduced-motion: reduce) { .blob { animation: none; } html { scroll-behavior: auto; } }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 20px; padding: 12px max(16px, calc((100% - 900px) / 2));
  background: var(--card); border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; }
.brand:hover { text-decoration: none; }
.logo {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, #1565d8, #22c3ee); color: #fff; font-size: .85rem; letter-spacing: .02em;
}
.nav-links { display: flex; align-items: center; gap: 18px; margin-left: auto; font-size: .95rem; }
.nav-links a { color: var(--muted); }
.nav-links a:hover { color: var(--accent); text-decoration: none; }
.theme-toggle {
  display: flex; padding: 3px; border-radius: 999px; background: var(--accent-soft); border: 1px solid var(--line);
}
.theme-toggle button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: 5px 12px; border-radius: 999px; font: inherit; font-size: .85rem;
}
.theme-toggle button[aria-pressed="true"] { background: var(--accent); color: #fff; }

/* ---------- Layout ---------- */
.page { max-width: 900px; margin: 0 auto; padding: 28px 16px 40px; display: grid; gap: 20px; }
.page.narrow { max-width: 440px; padding-top: 60px; }
.page.wide { max-width: 980px; }
.card {
  background: var(--card); border: 1px solid var(--card-border); border-radius: 18px;
  padding: 32px 36px; box-shadow: var(--card-shadow);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.resume section + section { margin-top: 28px; }
.item + .item { margin-top: 16px; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 12px; flex-wrap: wrap; }
.dates { color: var(--muted); font-size: .9rem; }
footer { text-align: center; color: var(--muted); font-size: .82rem; }

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: linear-gradient(90deg, #1565d8, #22c3ee, #5b45ff);
}
.hero-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.title { margin-top: 8px; color: var(--muted); font-size: 1.12rem; }
.contact { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 14px 0 0; color: var(--muted); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

/* The blue square */
.ow-box {
  flex: none; width: 96px; height: 96px; border: 0; border-radius: 8px; cursor: pointer;
  background: #1565d8; color: #fff; font: 700 1.6rem system-ui, sans-serif;
  box-shadow: 0 8px 24px rgba(21, 101, 216, .4); transition: transform .1s, background .15s;
}
.ow-box:hover { background: #0f52b5; }
.ow-box:active, .ow-box.hit { transform: scale(.88); }

/* ---------- Skills ---------- */
.skill-row { display: grid; grid-template-columns: 200px 1fr; gap: 6px 16px; align-items: start; }
.skill-row + .skill-row { margin-top: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 2px 10px; border-radius: 999px; font-size: .88rem;
  background: var(--accent-soft); color: var(--accent-strong); border: 1px solid var(--line);
}

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--input); color: var(--text);
  font: inherit; font-size: .95rem; font-weight: 600; cursor: pointer; transition: transform .1s, background .15s;
}
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(135deg, #1565d8, #1d8fe8); color: #fff; border-color: transparent; }
.btn-primary:hover { background: linear-gradient(135deg, #0f52b5, #1565d8); }
.btn-small { padding: 5px 12px; font-size: .85rem; }
.btn.danger, .linklike.danger, .icon-btn.danger { color: var(--danger); }
.linklike { border: 0; background: none; color: var(--muted); font: inherit; cursor: pointer; padding: 0; }
.linklike:hover { color: var(--accent); }
form.inline { display: inline; margin: 0; }

.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-size: .9rem; font-weight: 600; }
.form small { font-weight: 400; color: var(--muted); }
.form input, .form textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--input); color: var(--text); font: inherit; font-weight: 400;
}
.form textarea { resize: vertical; }
.form input:focus, .form textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.form button[type="submit"] { justify-self: start; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.span-2 { grid-column: 1 / -1; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.narrow-form { max-width: 420px; }
.h-small { font-size: 1.6rem; margin-bottom: 18px; }

/* ---------- Flash messages ---------- */
.flashes { max-width: 900px; margin: 16px auto 0; padding: 0 16px; display: grid; gap: 8px; }
.flash { padding: 12px 16px; border-radius: 12px; font-weight: 600; transition: opacity .6s; }
.flash-success { background: var(--success-bg); color: var(--success-text); }
.flash-error { background: var(--error-bg); color: var(--error-text); }
.flash.fade { opacity: 0; }

/* ---------- Admin ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs a {
  padding: 8px 16px; border-radius: 10px; color: var(--muted); font-weight: 600;
  background: var(--card); border: 1px solid var(--line);
}
.tabs a:hover { text-decoration: none; color: var(--accent); }
.tabs a.active { background: var(--accent); color: #fff; border-color: transparent; }
.badge {
  display: inline-block; padding: 0 8px; border-radius: 999px; font-size: .75rem; font-weight: 700;
  background: var(--danger); color: #fff; vertical-align: middle;
}
.edit-items { display: grid; gap: 12px; }
.edit-item { position: relative; padding: 16px; padding-top: 40px; border: 1px solid var(--line); border-radius: 12px; }
.item-tools { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; }
.icon-btn {
  width: 30px; height: 28px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--input); color: var(--text); cursor: pointer; font-size: .9rem;
}
.icon-btn:hover { border-color: var(--accent); }
.add-btn { margin-top: 12px; }
.savebar {
  position: sticky; bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: 14px; background: var(--card); border: 1px solid var(--line);
  box-shadow: var(--card-shadow); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
#editor-form { display: grid; gap: 20px; }
#dirty-note.unsaved { color: var(--accent); font-weight: 600; }
.reset-form { text-align: right; }
.message { padding: 16px 0; border-top: 1px solid var(--line); }
.message:first-of-type { border-top: 0; padding-top: 0; }
.message-body { white-space: pre-wrap; margin: 8px 0 10px; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.upload { margin-top: 16px; }

/* ---------- Phones ---------- */
@media (max-width: 640px) {
  .topbar { gap: 10px; }
  .brand-name, .theme-toggle span { display: none; }
  .nav-links { gap: 12px; font-size: .9rem; }
  .card { padding: 22px 18px; border-radius: 14px; }
  .ow-box { width: 64px; height: 64px; font-size: 1.2rem; }
  .grid-2, .skill-row { grid-template-columns: 1fr; }
  .skill-row { gap: 6px; }
}

/* ---------- Printing / "Save as PDF" ---------- */
@media print {
  .bg, .topbar, .flashes, .hero-actions, .ow-box, #contact, footer { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border: 0; padding: 0; background: none; }
  .page { padding: 0; }
}
