:root {
  --paper: #f8f7f3;
  --surface: #fff;
  --ink: #172739;
  --muted: #66717e;
  --line: #e1e5e9;
  --accent: #1556d9;
  --tint: #eaf0fc;
  --hover: #f0f4fa;
  --soft: #f5f7fa;
  --primary-text: #fff;
  --primary-hover: #1148bb;
  --notice-text: #345178;
  --control-height: 40px;
  --control-radius: 4px;
  --nav-active: var(--accent);
  --nav-highlight: rgb(21 86 217 / 8%);
  --nav-sweep: rgb(21 86 217 / 15%);
  --nav-sweep-end: var(--nav-sweep);
  color-scheme: light;
  font: 15px/1.6 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}
:root[data-theme="dark"] {
  --paper: #141c28;
  --surface: #1c2736;
  --ink: #edf2f9;
  --muted: #acb9cb;
  --line: #364357;
  --accent: #91b5ff;
  --tint: #243756;
  --hover: #2c3b51;
  --soft: #192332;
  --primary-text: #13243e;
  --primary-hover: #b0caff;
  --notice-text: #c3d7fa;
  --nav-active: #fff;
  --nav-highlight: rgb(255 255 255 / 8%);
  --nav-sweep: rgb(80 145 255 / 15%);
  --nav-sweep-end: rgb(105 240 174 / 15%);
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button, .button {
  border: 0; border-radius: var(--control-radius); padding: 8px 12px;
  min-height: var(--control-height); font-size: 13px; font-weight: 500;
  background: transparent; color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
button:hover, .button:hover { background: var(--hover); }
button[aria-pressed="true"] { color: var(--accent); }
.primary { background: var(--accent); border-color: var(--accent); color: var(--primary-text); }
.primary:hover { background: var(--primary-hover); color: var(--primary-text); }
svg { width: 18px; height: 18px; stroke-width: 1.6; flex-shrink: 0; }
:focus-visible { outline: 3px solid #86aafa; outline-offset: 4px; }
.skip-link { position: absolute; top: -70px; z-index: 10; background: var(--surface); padding: 10px; }
.skip-link:focus { top: 5px; }
.header {
  min-height: 80px; display: flex; gap: 18px; align-items: center;
  padding: 16px 32px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.brand img { width: 52px; height: 32px; object-fit: contain; }
:root[data-theme="dark"] .brand img { filter: brightness(0) invert(1); }
.theme-toggle { width: var(--control-height); height: var(--control-height); flex-shrink: 0; }
.header .create-top {
  height: var(--control-height); padding: 0 12px; white-space: nowrap;
  color: var(--accent); background: transparent;
}
.header .create-top:hover { background: var(--hover); }
.brand-light { font-weight: 400; margin-left: 5px; }
.search {
  display: flex; gap: 12px; align-items: center; background: transparent;
  height: var(--control-height); border: 0; border-bottom: 1px solid var(--line);
  padding: 0 0 0 2px; flex: 1; max-width: 520px; margin: 0 auto;
}
.search:focus-within { border-bottom-color: var(--accent); }
.search input {
  width: 100%; min-width: 0; border: 0; border-radius: 0;
  background: transparent; padding: 0; height: 100%; font-size: 13px;
}
.search > svg { color: var(--muted); }
.search button { width: 40px; height: 40px; padding: 0; flex-shrink: 0; }
.account {
  width: var(--control-height); height: var(--control-height); flex-shrink: 0;
  border: 0; border-radius: var(--control-radius);
  display: flex; align-items: center; justify-content: center;
}
.account:hover { background: var(--hover); }
.layout { display: flex; max-width: 1600px; margin: auto; }
.sidebar { position: relative; width: 218px; flex-shrink: 0; padding: 28px 18px; }
.sidebar a {
  position: relative; isolation: isolate; overflow: hidden;
  display: flex; align-items: center; gap: 12px; padding: 10px 13px;
  margin-bottom: 5px; border-radius: 12px; border-left: 2px solid transparent;
  color: var(--muted); font-size: 13px;
}
.sidebar a:hover { color: var(--ink); }
.sidebar a { transition: color 200ms ease-in-out; }
.sidebar a[aria-current="page"] {
  color: var(--nav-active); font-weight: 500;
  background: linear-gradient(90deg,
    var(--nav-highlight), transparent 80%);
}
.sidebar-indicator {
  position: absolute; left: 18px; top: 0; width: 4px; height: 22px;
  border-radius: 4px; background: var(--nav-active); pointer-events: none;
  z-index: 2;
}
.sidebar-indicator::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  animation: indicator-flash 2.5s linear infinite;
}
@keyframes indicator-flash {
  0%, 10%, 20%, 100% { background: transparent; box-shadow: none; }
  5% { background: #fff; box-shadow: 0 0 15px 2px #ffffff80; }
  15% { background: #448aff; box-shadow: 0 0 15px 2px #448aff80; }
}
.sidebar a[aria-current="page"]::after {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(90deg, transparent,
    var(--nav-sweep), var(--nav-sweep-end), transparent);
  background-size: 200% 100%; animation: menu-sweep 7s linear infinite;
}
@keyframes menu-sweep {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar a { transition: none; }
  .sidebar a[aria-current="page"]::after { animation: none; }
  .sidebar-indicator::after { animation: none; }
}
.nav-divider { height: 1px; background: var(--line); margin: 20px 12px; }
.nav-label { font-size: 10px; letter-spacing: 1.5px; margin: 30px 13px 10px; color: var(--muted); }
.sidebar .help-link { margin-top: 42px; }
.sidebar small { color: var(--muted); font-size: 11px; margin-left: 13px; }
main { padding: 36px 44px 70px; flex: 1; min-width: 0; max-width: 1240px; }
main:focus { outline: none; }
main.home-page { padding-top: 16px; }
main.home-page > .chips:first-child { margin-top: 0; margin-bottom: 0; }
.home-page .hero { margin-top: 28px; }
h1, h2, h3, p { margin: 0; }
h1 { font: 400 clamp(32px, 3.4vw, 52px)/1.12 Georgia, serif; letter-spacing: -1.6px; }
h2 { font: 400 27px/1.25 Georgia, serif; letter-spacing: -.6px; }
h3 { font-size: 17px; line-height: 1.45; font-weight: 600; }
.eyebrow { font-size: 11px; letter-spacing: 1.2px; color: var(--muted); margin-bottom: 14px; }
.muted, .meta { color: var(--muted); font-size: 13px; }
.chips, .actions { display: flex; gap: 9px; flex-wrap: wrap; }
.chips { margin: 18px 0; gap: 4px 24px; }
.chips a {
  padding: 7px 0; min-height: 36px; border-bottom: 1px solid transparent;
  font-size: 13px; color: var(--muted);
}
.chips a:hover { color: var(--ink); }
.chips .selected { color: var(--accent); border-bottom-color: var(--accent); }
.filter-context {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  margin: 16px 0; font-size: 13px; color: var(--muted);
}
.filter-context a { color: var(--accent); text-decoration: underline; text-underline-offset: 4px; }
.mobile-menu-toggle { display: none; }
#mobile-menu nav { display: grid; gap: 8px; }
#mobile-menu nav a {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px;
}
#mobile-menu nav a:hover { color: var(--accent); }
.hero { display: grid; grid-template-columns: 1.35fr 1fr; gap: 40px; align-items: center; margin: 42px 0; }
.hero p { color: var(--muted); margin: 21px 0 24px; max-width: 390px; }
.cover {
  --cover: #0a346e; background: var(--cover); color: #f1f5ff;
  min-height: 190px; padding: 23px; display: flex; flex-direction: column;
  justify-content: space-between; position: relative; overflow: hidden;
  border-radius: 10px; isolation: isolate;
}
.cover.math {
  background:
    radial-gradient(ellipse at 85% 30%, #256cac44, transparent 65%),
    linear-gradient(115deg, #0c2e5e, #103f76 62%, #15507d);
}
.cover::before {
  content: ""; position: absolute; z-index: -1; pointer-events: none;
  inset: -8% -15% -8% 12%;
  background-position: right center; background-size: auto 100%;
  background-repeat: no-repeat;
}
.cover.math::before { background-image: url("/assets/himpunan.svg"); }
.cover.math .pattern { text-shadow: 0 2px 18px #06224466; }
.cover.code {
  background: linear-gradient(115deg, #143d40, #1c5757 65%, #236b63);
}
.cover.code::before { background-image: url("/assets/algoritma.svg"); }
.cover.art {
  background: linear-gradient(115deg, #62483f, #805d4e 60%, #987255);
}
.cover.art::before { background-image: url("/assets/ragam-rupa.svg"); }
.cover small { font-size: 11px; letter-spacing: 1.3px; }
.cover .pattern { font: 400 clamp(28px, 3vw, 43px)/1.2 Georgia, serif; margin: 18px 0; }
.hero .cover { min-height: 260px; padding: 32px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin: 30px 0 22px; }
.results-title { font-size: 27px; line-height: 1.25; letter-spacing: -.6px; }
.text-link { font-size: 13px; color: var(--accent); display: inline-flex; align-items: center; gap: 7px; }
.hero-link { min-height: 40px; font-weight: 500; border-bottom: 1px solid var(--accent); }
.hero-link svg { transition: transform .15s ease; }
.hero-link:hover svg { transform: translateX(3px); }
@media(prefers-reduced-motion:reduce) { .hero-link svg { transition: none; } }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.work-card { min-width: 0; display: flex; flex-direction: column; }
.work-card > .work-link { display: block; }
.work-card .cover { aspect-ratio: 16 / 9; min-height: 0; padding: 20px; }
.work-card .cover .pattern { margin: 8px 0; }
.card-details {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) 28px;
  gap: 12px; margin-top: 14px; align-items: start;
}
.card-copy { min-width: 0; }
.card-menu { position: relative; }
.card-menu summary {
  display: flex; align-items: center; justify-content: center;
  width: 28px; min-height: 36px; cursor: pointer; list-style: none;
  border-radius: 50%; color: var(--muted);
}
.card-menu summary::-webkit-details-marker { display: none; }
.card-menu summary:hover { background: var(--tint); color: var(--ink); }
.card-menu summary svg { width: 20px; height: 20px; }
.card-menu-panel {
  position: absolute; right: 0; top: 38px; z-index: 2;
  min-width: 160px; padding: 6px; border-radius: 12px;
  background: var(--surface); box-shadow: 0 8px 30px #0003;
}
.card-menu-panel button { width: 100%; justify-content: flex-start; }
.author-avatar-link { display: block; margin-top: 3px; }
.work-card h3 {
  font-size: 16px; line-height: 24px; min-height: 48px; max-height: 48px;
  margin-bottom: 0; overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  line-clamp: 2;
}
.work-card a:hover h3 { color: var(--accent); }
.author {
  display: flex; align-items: center; min-width: 0;
  padding-top: 5px; color: var(--muted); font-size: 13px;
}
.author:hover { color: var(--ink); }
.author-avatar {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; flex: 0 0 36px;
  overflow: hidden; border-radius: 50%; background: var(--tint);
  color: var(--accent); font-size: 12px; font-weight: 600; letter-spacing: .2px;
}
.author-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.author-name {
  min-width: 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; line-height: 20px;
}
.card-stats {
  margin: 3px 0 0 48px; display: flex; align-items: center;
  gap: 8px; flex-wrap: nowrap; color: var(--muted); font-size: 12px;
}
.card-stats .author { flex: 0 1 auto; padding: 0; font-size: 12px; }
.verified-badge { display: inline-flex; flex: 0 0 14px; margin-left: 4px; }
.admin-badge { color: var(--accent); }
.card-stats .verified-badge svg { width: 14px; height: 14px; }
.card-stats .admin-badge { flex-basis: 17px; }
.card-stats .admin-badge svg {
  width: 17px; height: 17px;
}
.admin-shield { fill: #2474e5; stroke: none; }
.admin-check {
  fill: none; stroke: #fff; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.card-stats .like-count, .card-stats .view-count, .card-stats time { flex-shrink: 0; }
.card-stats time { white-space: nowrap; }
.view-count, .like-count {
  display: inline-flex; gap: 5px; align-items: center; color: var(--muted);
  font-size: 12px; white-space: nowrap;
}
.card-stats svg { width: 16px; height: 16px; }
.section-subtitle { color: var(--muted); margin: 14px 0 24px; max-width: 600px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 36px; margin: 32px 0; }
.field { padding: 24px 0; background: transparent; border-bottom: 1px solid var(--line); }
a.field:hover h3 { color: var(--accent); }
.field svg { color: var(--accent); margin-bottom: 16px; }
.field p { font-size: 13px; color: var(--muted); margin-top: 6px; }
.back { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 25px; font-size: 13px; color: var(--muted); }
.reading { max-width: 740px; margin: auto; }
.reading h1 { margin: 10px 0 25px; }
.byline { display: flex; align-items: center; gap: 12px; margin: 15px 0; }
.byline .avatar { padding: 10px; color: var(--muted); }
.byline .avatar svg { display: block; }
.byline button { margin-left: auto; }
.reading .cover { min-height: 250px; margin: 30px 0; }
.article-body p { font: 18px/1.95 Georgia, serif; margin: 22px 0; }
.source { padding: 18px 0; border-top: 1px solid var(--line); margin: 30px 0; }
.actions { padding: 20px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 28px 0; }
.actions button { font-size: 13px; padding: 8px 10px; }
.reading .actions button[data-action="like"][aria-pressed="true"] {
  color: #c73561;
}
:root[data-theme="dark"] .reading .actions button[data-action="like"][aria-pressed="true"] {
  color: #ff789d;
}
.reading .actions button[data-action="save"][aria-pressed="true"] {
  color: var(--accent);
}
.reading .actions button[data-action="like"][aria-pressed="true"] svg,
.reading .actions button[data-action="save"][aria-pressed="true"] svg {
  fill: currentColor; stroke: currentColor;
}
.comments h2 { margin-bottom: 20px; }
.comment { padding: 18px 0; border-bottom: 1px solid var(--line); }
.comment p { margin: 8px 0; }
input, textarea, select {
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 4px;
  width: 100%; background: var(--surface); color: var(--ink);
}
label { display: block; font-size: 13px; margin: 20px 0; }
label input, label textarea, label select { margin-top: 8px; }
textarea { resize: vertical; }
.comment-form { margin: 24px 0; }
.comment-form .button { margin-top: 10px; }
.empty { padding: 60px 25px; text-align: center; }
.empty svg { width: 28px; height: 28px; color: var(--accent); margin-bottom: 12px; }
.empty p { color: var(--muted); margin: 13px 0 22px; }
.editor { max-width: 780px; margin: auto; }
.editor textarea { min-height: 240px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.notice {
  color: var(--muted); padding: 16px 0; border-bottom: 1px solid var(--line);
  font-size: 13px; margin: 25px 0;
}
.mobile-nav { display: none; }
#back-to-top {
  position: fixed; right: 24px; bottom: 24px; z-index: 25;
  width: 46px; height: 46px; padding: 0; border-radius: 50%;
  background: var(--surface); color: var(--accent);
  box-shadow: 0 4px 20px #0002;
  transition: background 180ms, transform 180ms;
}
#back-to-top[hidden] { display: none; }
#back-to-top:hover { background: var(--tint); transform: translateY(-2px); }
@media(max-width:900px) {
  #back-to-top { right: 16px; bottom: calc(90px + env(safe-area-inset-bottom)); }
}
@media(prefers-reduced-motion:reduce) {
  #back-to-top { transition: none; }
}
#toast { position: fixed; bottom: 25px; left: 50%; transform: translateX(-50%); background: #172739; color: white; border-radius: 10px; padding: 13px 20px; max-width: calc(100% - 28px); z-index: 30; display: none; font-size: 13px; }
#toast.visible { display: block; }
dialog { border: 1px solid var(--line); background: var(--surface); border-radius: 16px; width: min(480px, calc(100% - 30px)); color: var(--ink); padding: 25px; }
dialog::backdrop { background: #17273977; }
dialog .section-heading { margin-top: 0; }
@media(min-width:1600px) { main { padding-top: 45px; } }
@media(max-width:1100px) {
  .sidebar { width: 190px; padding: 25px 10px; }
  main { padding: 30px 25px; }
  .header { padding: 16px 24px; gap: 16px; }
  .grid { gap: 18px; }
  .hero { gap: 25px; }
}
@media(max-width:800px) {
  .sidebar { display: none; }
  .mobile-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; justify-content: space-around; background: var(--surface); border-top: 1px solid var(--line); padding: 9px 4px max(9px, env(safe-area-inset-bottom)); z-index: 20; }
  .mobile-nav a { display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 10px; min-width: 48px; padding: 5px; }
  main { padding-bottom: 115px; }
  .header { flex-wrap: wrap; padding: 16px 20px; gap: 14px; }
  .brand { margin-right: auto; }
  .search { order: 4; max-width: none; flex-basis: 100%; }
  .create-top { display: none; }
  .mobile-menu-toggle { display: inline-flex; width: 40px; height: 40px; padding: 0; }
  .header .account { display: none; }
  .hero { margin: 30px 0; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #toast { bottom: 90px; }
}
@media(max-width:540px) {
  .header { gap: 10px; }
  .brand { gap: 5px; font-size: 14px; }
  .brand img { width: 48px; }
  main { padding: 26px 20px 115px; }
  .hero, .field-grid, .form-row { grid-template-columns: 1fr; }
  .hero { gap: 25px; }
  .hero .cover { min-height: 210px; }
  .grid { grid-template-columns: 1fr; gap: 28px; }
  h1 { font-size: 36px; }
  h2 { font-size: 25px; }
  .section-heading { align-items: flex-start; }
  .section-heading .text-link { flex-shrink: 0; margin-top: 6px; }
  .byline { flex-wrap: wrap; }
  .byline button { margin-left: 0; }
  .actions { gap: 7px; }
  .actions button { padding: 10px; }
}
