/* Minimal, content-first styling (mobile-first) */
:root{
  --bg:#ffffff;
  --surface:#ffffff;
  --fg:#0f172a;
  --muted:#475569;
  --link:#7c3aed;
  --accent:#7c3aed;
  --accent-hover:#6d28d9;
  --accent-soft:#ede9fe;
  --border:#e5e7eb;
  --max: 760px;
  --pad: 18px;
  --radius: 10px;
  --header-h: 72px;
}

:root[data-theme="dark"]{
  --bg:#0f1214;            /* page background (Perplexity-like) */
  --surface:#11161b;       /* surface / cards */
  --fg:#cfd6dd;            /* primary text (soft white) */
  --muted:#9ca3af;         /* secondary text */
  --link:#f4c95d;          /* chosen accent (warm gold) */
  --accent:#f4c95d;        /* accent */
  --accent-hover:#e3b545;  /* accent hover */
  --accent-soft:#2a2415;   /* soft accent background */
  --border:#1f242b;        /* subtle outlines */
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font: 16px/1.7 ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  color:var(--fg);
  background:var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a{ color:var(--link); text-decoration: underline; text-underline-offset: 3px; transition: color 120ms ease, text-decoration-thickness 120ms ease; }
a:hover{ text-decoration-thickness: 2px; color: var(--accent-hover); }

.wrap{
  max-width: var(--max);
  width: 100%;
  margin: 0 auto;
  padding: 24px var(--pad) 64px;
  flex: 1;
  display: flex;
  flex-direction: column;
}
body > .wrap{
  min-height: calc(100vh - var(--header-h));
}

header{
  position: sticky;
  top: 0;
  background: var(--bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
header .wrap{
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 16px;
  padding-top: 18px;
  padding-bottom: 18px;
}

nav{
  display:flex;
  align-items:center;
  gap: 22px;
  justify-content:center;
}
nav a{
  text-decoration:none;
  color:var(--muted);
  font-weight: 520;
}
nav a[aria-current="page"]{ color: var(--fg); }

.section-nav{
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  margin: 14px 0 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.section-nav a{
  text-decoration: none;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid transparent;
}
.section-nav a[aria-current="page"]{
  color: var(--fg);
  border-color: var(--border);
  background: var(--accent-soft);
}
.section-nav a:hover{
  text-decoration: none;
  color: var(--fg);
  border-color: var(--border);
}

.writing-toggle{
  display: flex;
  width: 100%;
  max-width: 960px;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}
.writing-toggle button{
  flex: 1;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 10px;
  font: inherit;
  font-size: 18px;
  cursor: pointer;
  transition: color 120ms ease, background 120ms ease, border-color 120ms ease;
}
.writing-toggle button.is-active{
  color: #0f172a;
  background: #d6b862;
  border-color: #d6b862;
}
.writing-toggle button:hover{
  color: inherit;
  background: transparent;
  border-color: #d6b862;
}
.writing-toggle button.is-active:hover{
  color: #0f172a;
  background: #d6b862;
  border-color: #d6b862;
}

.writing-panel{
  margin-top: 32px;
}
.writing-list{
  display: grid;
  gap: 36px;
  margin-top: 16px;
}
.writing-preview{
  padding: 6px 0;
}
.preview-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.preview-title{
  display: block;
  font-weight: 650;
  color: var(--fg);
  font-size: 18px;
  margin: 0;
}
.preview-views{
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}
.preview-meta-top{
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 8px;
}
.preview-excerpt{
  margin: 4px 0 10px;
  color: var(--muted);
}
.preview-meta{
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  color: var(--muted);
  justify-content: space-between;
}
.button-link{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 32px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  text-decoration: none;
  color: var(--fg);
  background: transparent;
  transition: border-color 140ms ease, color 120ms ease, background 140ms ease;
  min-width: 210px;
  justify-content: center;
}
.meta-time{
  margin-left: auto;
  white-space: nowrap;
}
.preview-readmore{
  margin-top: 4px;
}

.back-link-top{
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}
.back-link-top a{
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}
.back-link-top a:hover{
  text-decoration: underline;
  color: var(--fg);
}

.floating-back{
  display: none;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  margin-bottom: 16px;
  align-self: flex-end;
  position: relative;
  right: 0;
  bottom: 0;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--fg);
  text-decoration: none;
  font-size: 15px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
  z-index: 30;
}
.floating-back:hover{
  border-color: var(--accent);
  color: var(--fg);
  background: color-mix(in srgb, var(--surface) 88%, var(--accent-soft) 12%);
}

@media (max-width: 720px){
  .floating-back{
    display: inline-flex;
  }
}
@media (max-width: 720px){
  .preview-meta{
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .button-link.preview-readmore{
    width: 100%;
    justify-content: center;
  }
}
.button-link:hover{
  border-color: var(--accent);
  color: var(--fg);
  background: color-mix(in srgb, var(--surface) 90%, var(--accent-soft) 10%);
}

.menu-btn{
  display:none;
  border: 1px solid var(--border);
  background: transparent;
  padding: 8px 10px;
  border-radius: var(--radius);
  font: inherit;
  color: var(--fg);
}

.theme-switch{
  display:flex;
  align-items:center;
  gap: 10px;
  justify-content: flex-end;
  position: relative;
}
.theme-main{
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  padding: 10px 12px;
  border-radius: 14px;
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}
.theme-options{
  display: inline-flex;
  gap: 8px;
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%) scaleX(0);
  transform-origin: right center;
  opacity: 0;
  transition: transform 160ms ease, opacity 160ms ease;
}
.theme-options[hidden]{
  display: inline-flex;
}
.theme-options.is-open{
  transform: translateY(-50%) scaleX(1);
  opacity: 1;
}
.theme-options button{
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  padding: 9px 12px;
  border-radius: 12px;
  font: inherit;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
}

@media (max-width: 720px){
  nav{ display:none; }
  nav.open{
    display:flex;
    flex-direction:column;
    align-items:center;
    gap: 10px;
    padding-top: 10px;
  }
  header .wrap{
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .menu-btn{ display:inline-flex; align-self:flex-end; }
}

main{
  padding-top: 28px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

h1{
  font-size: 28px;
  line-height: 1.25;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}
.article-header{
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.article-date{
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.article-subtitle{
  color: var(--muted);
  margin: 0;
  font-size: 17px;
}
h2{
  font-size: 22px;
  margin: 32px 0 12px;
}
h3{
  font-size: 17px;
  margin: 24px 0 8px;
}
p{ margin: 0 0 14px; }

hr{
  border:0;
  border-top: 1px solid var(--border);
  margin: 26px 0;
}
.section-divider{
  border: 0;
  border-top: 1px solid var(--border);
  margin: 36px 0 20px;
}
.section-divider.narrow{
  max-width: 560px;
  margin: 18px 0 0;
}

.small{ font-size: 13px; color: var(--muted); }
.kicker{ color: var(--muted); margin-top: 6px; }
.compact-kicker{ margin-top: 1px; }

.list{
  list-style:none;
  padding:0;
  margin: 10px 0 0;
}
.list li{ margin: 10px 0 0; }
.list a{ text-decoration:none; }
.list a:hover{ text-decoration: underline; }

.contact-list{
  margin-top: 0;
}

.contact-links{
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 6px 0 18px;
}
.contact-links a{
  text-decoration: none;
}
.contact-links a:hover{
  text-decoration: underline;
}

.bullets{
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
  display: grid;
  gap: 18px;
}
.bullets li{
  position: relative;
  padding-left: 18px;
  line-height: 1.6;
}
.bullets li::before{
  content: "•";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent);
  font-weight: 900;
  font-size: 18px;
}

.grid{
  display:grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.grid-collections{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.card{
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 140ms ease, box-shadow 160ms ease, transform 120ms ease, background 140ms ease;
}
.card a{ text-decoration:none; }
.card a:hover{ text-decoration: underline; }
.card:hover,
.card:focus-visible{
  border-color: var(--accent);
  box-shadow: 0 6px 16px rgba(0,0,0,0.12);
  transform: translateY(-1px);
  background: color-mix(in srgb, var(--surface) 92%, var(--accent-soft) 8%);
  outline: none;
}
.card:active{
  transform: translateY(0);
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  border-color: var(--accent-hover);
}

.footer{
  margin-top: auto;
  padding-top: 18px;
  padding-left: var(--pad);
  padding-right: var(--pad);
  border-top: 1px solid var(--border);
  display:flex;
  justify-content:space-between;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
  max-width: var(--max);
  width: 100%;
  min-width: 100%;
  margin-left: auto;
  margin-right: auto;
  align-self: stretch;
}
.footer-spacer{
  margin-top: 28px;
}
.footer.no-border{
  border-top: 0;
}
.footer a{ color: var(--muted); text-decoration:none; }
.footer a:hover{ text-decoration: underline; }
.footer .theme-switch{
  margin-left: auto;
}
