/* ===== nav toggles (sound, achievements) ===== */
.icon-toggle { position: relative; height: 42px; min-width: 42px; padding: 0 .7rem; border-radius: 999px; border: 1.5px solid var(--line); display: inline-flex; align-items: center; justify-content: center; gap: .35rem; font-size: 1rem; transition: transform .3s cubic-bezier(.3,1.6,.5,1), border-color .2s; }
.icon-toggle:hover { border-color: var(--ink); transform: translateY(-2px); }
.icon-toggle b { font-family: var(--mono); font-size: .75rem; }
#sound-btn .snd-on, #sound-btn.on .snd-off { display: none; }
#sound-btn.on .snd-on { display: inline; }
#trophy-btn.bump { animation: bump .6s cubic-bezier(.3,1.8,.5,1); }
@keyframes bump { 40% { transform: scale(1.3) rotate(-10deg); } }
@media (max-width: 520px) { .icon-toggle { min-width: 38px; height: 38px; padding: 0 .5rem; } #trophy-btn b { display: none; } }

/* ===== flash a section the chat links to ===== */
.flash-section { animation: flashSection 1.6s ease; border-radius: var(--radius); }
@keyframes flashSection { 0%, 100% { box-shadow: 0 0 0 0 transparent; } 25% { box-shadow: 0 0 0 6px var(--lime); } }

/* ===== chat ===== */
.chat-fab { position: fixed; left: 18px; bottom: 18px; z-index: 90; display: inline-flex; align-items: center; gap: .55rem; padding: .85rem 1.2rem .85rem 1rem; border-radius: 999px; background: var(--ink); color: var(--bg); font-weight: 600; box-shadow: 0 16px 34px -14px rgba(31,59,255,.7); transition: transform .3s cubic-bezier(.3,1.6,.5,1), opacity .2s; }
.chat-fab:hover { transform: translateY(-3px) rotate(-1deg); }
.chat-fab.hidden { opacity: 0; pointer-events: none; transform: translateY(20px); }
.chat-spark { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--lime); color: #16161D; animation: spin 6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.chat { position: fixed; left: 18px; bottom: 18px; z-index: 95; width: min(400px, calc(100vw - 36px)); height: min(600px, calc(100vh - 110px)); display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 40px 80px -30px rgba(0,0,0,.45); overflow: hidden; animation: rise .35s cubic-bezier(.3,1.5,.5,1); }
.chat[hidden] { display: none; }
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.1rem; background: var(--ink); color: var(--bg); }
.chat-head b { font-family: var(--serif); font-weight: 400; font-size: 1.4rem; display: block; line-height: 1; }
.chat-head small { font-family: var(--mono); font-size: .7rem; color: var(--lime); }
.chat-x { width: 34px; height: 34px; border-radius: 50%; font-size: 1.4rem; color: var(--bg); }
.chat-x:hover { background: rgba(255,255,255,.12); }
.chat-log { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .7rem; }
.chat .msg { max-width: 88%; padding: .7rem .9rem; border-radius: 16px; font-size: .95rem; line-height: 1.5; }
.chat .msg p + p { margin-top: .4rem; }
.chat .msg ul { padding-left: 1.1rem; margin: .3rem 0; }
.chat .msg li { margin: .15rem 0; }
.chat .msg a { color: var(--blue); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.chat .msg.bot { align-self: flex-start; background: var(--bg-2); border-bottom-left-radius: 4px; }
.chat .msg.me { align-self: flex-end; background: var(--blue); color: #fff; border-bottom-right-radius: 4px; }
.chat .msg.typing { display: flex; gap: 4px; padding: .9rem; }
.chat .msg.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-2); animation: dots 1s infinite; }
.chat .msg.typing i:nth-child(2) { animation-delay: .15s; }
.chat .msg.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes dots { 50% { transform: translateY(-4px); opacity: .4; } }
.chat-suggest { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0 1rem .8rem; }
.chat-suggest[hidden] { display: none; }
.chat-suggest button { font-size: .8rem; padding: .4rem .7rem; border-radius: 999px; border: 1.5px solid var(--line); transition: border-color .2s, background .2s; }
.chat-suggest button:hover { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 8%, transparent); }
.chat-form { display: flex; gap: .5rem; padding: .8rem .8rem .4rem; border-top: 1px solid var(--line); }
.chat-note { font-family: var(--mono); font-size: .65rem; color: var(--ink-2); text-align: center; padding: 0 .8rem .6rem; }
.chat-form input { flex: 1; border: 1.5px solid var(--line); border-radius: 999px; padding: .65rem 1rem; background: var(--bg); color: var(--ink); font: inherit; outline: none; }
.chat-form input:focus { border-color: var(--blue); }
.chat-form button { width: 42px; height: 42px; border-radius: 50%; background: var(--orange); color: #fff; font-size: 1.1rem; font-weight: 700; }
@media (max-width: 520px) {
  .chat-fab-label { display: none; }
  .chat-fab { padding: .8rem; }
  .chat { left: 8px; bottom: 8px; width: calc(100vw - 16px); height: calc(100vh - 90px); }
}

/* ===== achievements ===== */
.trophies { position: fixed; inset: 0; z-index: 110; background: rgba(13,14,26,.55); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 16px; animation: fade .25s; }
.trophies[hidden] { display: none; }
.trophies-card { position: relative; width: min(520px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--card); border-radius: var(--radius); padding: 2rem; animation: rise .4s cubic-bezier(.3,1.5,.5,1); }
.trophies-card h3 { font-family: var(--serif); font-weight: 400; font-size: 2.2rem; color: var(--blue); margin: .3rem 0 .8rem; }
.trophy-bar { height: 10px; border-radius: 999px; background: var(--bg-2); overflow: hidden; margin-bottom: 1.2rem; }
.trophy-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), var(--lime)); border-radius: 999px; transition: width .6s; }
.trophy-list { list-style: none; display: grid; gap: .5rem; }
.trophy-list li { display: flex; align-items: center; gap: .8rem; padding: .6rem .8rem; border-radius: 12px; background: var(--bg); opacity: .6; }
.trophy-list li.got { opacity: 1; background: color-mix(in srgb, var(--lime) 22%, var(--bg)); }
.trophy-list .t-ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-size: 1.2rem; background: var(--card); flex: none; }
.trophy-list b { display: block; font-size: .95rem; }
.trophy-list small { color: var(--ink-2); font-size: .8rem; }
.ach-toast { position: fixed; top: 86px; left: 50%; z-index: 140; display: flex; align-items: center; gap: .8rem; padding: .7rem 1.2rem .7rem .8rem; border-radius: 999px; background: var(--ink); color: var(--bg); box-shadow: 0 20px 40px -15px rgba(0,0,0,.5); transform: translateX(-50%); pointer-events: none; }
.ach-toast[hidden] { display: none; }
.ach-toast.show { animation: achIn 3.2s cubic-bezier(.3,1.5,.5,1) forwards; }
@keyframes achIn {
  0% { opacity: 0; transform: translate(-50%, -20px) scale(.9); }
  10%, 85% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -10px); }
}
.ach-ico { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--lime); font-size: 1.1rem; }
.ach-toast small { display: block; font-family: var(--mono); font-size: .65rem; color: var(--lime); text-transform: uppercase; letter-spacing: .08em; }
.ach-toast b { font-size: .95rem; }

/* ===== playground ===== */
.pg { display: grid; grid-template-columns: 1.5fr 1fr; gap: 1.5rem; margin-top: 2.5rem; }
.pg-stage { position: relative; aspect-ratio: 4/3; border-radius: var(--radius); overflow: hidden; background: #0E0F1C; border: 1px solid var(--line); }
.pg-stage canvas { width: 100%; height: 100%; object-fit: contain; display: block; }
.pg-empty, .pg-loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .8rem; color: #B9B8C8; text-align: center; padding: 1rem;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,.03) 0 1px, transparent 1px 26px), repeating-linear-gradient(90deg, rgba(255,255,255,.03) 0 1px, transparent 1px 26px), #0E0F1C; }
.pg-empty[hidden], .pg-loading[hidden] { display: none; }
.pg-icon { font-size: 3rem; color: var(--lime); animation: spin 8s linear infinite; }
.pg-loading i { width: 46px; height: 46px; border-radius: 50%; border: 4px solid rgba(255,255,255,.12); border-top-color: var(--lime); animation: spin 1s linear infinite; }
.pg-side { display: flex; flex-direction: column; gap: 1rem; }
.pg-buttons { display: flex; flex-wrap: wrap; gap: .6rem; }
.pg-buttons [hidden] { display: none; }
.pg-upload { cursor: pointer; }
.pg-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.pg-stats div { background: var(--bg); padding: .8rem; }
.pg-stats span { display: block; font-family: var(--mono); font-size: .65rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.pg-stats b { font-family: var(--serif); font-weight: 400; font-size: 1.6rem; color: var(--blue); }
.pg-list { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; min-height: 2rem; }
.pg-list li { display: inline-flex; gap: .4rem; padding: .3rem .7rem; border-radius: 999px; background: var(--bg-2); font-size: .85rem; }
.pg-note { font-size: .85rem; color: var(--ink-2); }
@media (max-width: 860px) { .pg { grid-template-columns: 1fr; } }

/* ===== GitHub ===== */
.gh-card { margin-top: 2.5rem; padding: 1.4rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); }
.gh-head { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem; }
.gh-head .plink { margin: 0; }
.gh-heat { display: grid; grid-template-rows: repeat(7, 12px); grid-auto-flow: column; grid-auto-columns: 12px; gap: 3px; overflow-x: auto; padding-bottom: .4rem; }
.gh-heat i, .gh-legend i { width: 12px; height: 12px; border-radius: 3px; background: var(--bg-2); }
.gh-heat i.pad { background: transparent; }
.gh-heat .l1, .gh-legend .l1 { background: color-mix(in srgb, var(--blue) 30%, var(--bg-2)); }
.gh-heat .l2, .gh-legend .l2 { background: color-mix(in srgb, var(--blue) 55%, var(--bg-2)); }
.gh-heat .l3, .gh-legend .l3 { background: color-mix(in srgb, var(--blue) 80%, var(--bg-2)); }
.gh-heat .l4, .gh-legend .l4 { background: var(--lime); }
.gh-legend { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: .6rem; font-family: var(--mono); font-size: .7rem; color: var(--ink-2); }
.gh-sub { font-family: var(--mono); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); margin: 2rem 0 1rem; }
.gh-repos { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.gh-repo { display: flex; flex-direction: column; gap: .5rem; padding: 1.2rem; border-radius: 18px; border: 1px solid var(--line); background: var(--card); transition: transform .3s cubic-bezier(.3,1.6,.5,1), border-color .2s; }
.gh-repo:hover { transform: translateY(-4px); border-color: var(--blue); }
.gh-repo b { font-family: var(--mono); font-size: .95rem; color: var(--blue); }
.gh-repo p { color: var(--ink-2); font-size: .9rem; flex: 1; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gh-meta { display: flex; flex-wrap: wrap; gap: .8rem; font-family: var(--mono); font-size: .72rem; color: var(--ink-2); }
.gh-meta span { display: inline-flex; align-items: center; gap: .35rem; }
.gh-meta i { width: 10px; height: 10px; border-radius: 50%; }

/* ===== contact form ===== */
.contact-form { margin-top: 2.5rem; max-width: 760px; padding: 1.6rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); display: grid; gap: 1rem; position: relative; }
.cf-title { font-family: var(--serif); font-size: 1.6rem; line-height: 1.1; }
.cf-title .mono { color: var(--ink-2); font-size: .75rem; display: block; margin-top: .3rem; }
.cf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.contact-form label { display: flex; flex-direction: column; gap: .35rem; font-size: .85rem; font-weight: 600; }
.contact-form input, .contact-form textarea { font: inherit; font-weight: 400; color: var(--ink); background: var(--bg); border: 1.5px solid var(--line); border-radius: 14px; padding: .75rem .9rem; outline: none; transition: border-color .2s, box-shadow .2s; }
.contact-form input:focus, .contact-form textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue) 14%, transparent); }
.contact-form textarea { resize: vertical; min-height: 110px; }
.contact-form .hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.cf-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; }
.cf-foot .pill:disabled { opacity: .6; }
.cf-status { font-size: .9rem; }
.cf-status.ok { color: #1E8E3E; font-weight: 600; }
.cf-status.err { color: #D92D20; }
@media (max-width: 600px) { .cf-grid { grid-template-columns: 1fr; } }

/* homepage writing reuses .post-grid / .post-card from pages.css */
.writing .post-grid { margin-top: 2.5rem; }
@media (max-width: 520px) {
  .nav .brand { font-size: 1.2rem; }
  .nav-right { gap: .4rem; }
  .nav-right .theme-toggle, .nav-right .icon-toggle { width: 36px; min-width: 36px; height: 36px; padding: 0; }
  .burger { width: 36px; }
}
