/* Desmify: Desmos graphing calculator, dark mode. Expression list on the left, graph paper on the right. */
:root {
  --top: #262626;
  --list: #1e1e1e;
  --row: #1e1e1e;
  --rowline: #303030;
  --gut: #292929;
  --gutn: #8a8a8a;
  --graph: #141414;
  --text: #e8e8e8;
  --muted: #9a9a9a;
  --btn: #2c2c2c;
  --btnline: #454545;
  --blue: #2d70b3;
  --blue2: #5b9bd5;
  --red: #c74440;
  --green: #388c46;
  --purple: #6042a6;
  --orange: #fa7e19;
  --ui: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --math: "Times New Roman", Times, "Latin Modern Math", serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--graph); color: var(--text); font: 14px/1.4 var(--ui); overflow: hidden; }
[hidden] { display: none !important; }
a { color: var(--blue2); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { justify-content: center; text-align: center; }
.grow { flex: 1; }

/* top bar */
.top { height: 48px; background: var(--top); border-bottom: 1px solid #0b0b0b; display: flex; align-items: center; gap: 18px; padding: 0 14px; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 700; font-size: 17px; letter-spacing: 0.2px; }
.tabs { display: flex; gap: 2px; }
.tabs a { color: #c8c8c8; text-decoration: none; padding: 6px 12px; border-radius: 4px; font-size: 14px; }
.tabs a:hover { background: #333; }
.tabs a.on { color: #fff; background: #383838; }

/* buttons */
.btn { font: 14px var(--ui); color: var(--text); background: var(--btn); border: 1px solid var(--btnline); border-radius: 4px; padding: 6px 12px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover:not(:disabled) { background: #363636; border-color: #555; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.blue { background: var(--blue); border-color: #3a82c8; color: #fff; }
.btn.blue:hover:not(:disabled) { background: #3579bd; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--blue2); padding-left: 6px; padding-right: 6px; }
.btn.ghost:hover:not(:disabled) { background: #2a2a2a; border-color: transparent; }
.btn.danger { color: #e0807c; }
.btn.small { font-size: 12px; padding: 4px 8px; }
.btn.big { font-size: 16px; padding: 10px 18px; }
.acts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }

/* layout */
.view.make { display: flex; height: calc(100% - 48px); }
.list { width: 400px; flex: none; background: var(--list); border-right: 1px solid #0b0b0b; overflow-y: auto; box-shadow: 2px 0 6px rgba(0,0,0,0.35); z-index: 2; }
.stage { position: relative; flex: 1; min-width: 0; background: var(--graph); }
.pane { position: absolute; inset: 0; width: 100%; height: 100%; }
#orig { display: flex; align-items: center; justify-content: center; padding: 40px; }
#orig img, #orig video { max-width: 100%; max-height: 100%; box-shadow: 0 2px 16px rgba(0,0,0,0.5); }

/* expression rows */
.row { display: flex; border-bottom: 1px solid var(--rowline); background: var(--row); min-height: 58px; }
.gut { width: 44px; flex: none; background: var(--gut); display: flex; flex-direction: column; align-items: center; padding-top: 6px; gap: 6px; border-right: 1px solid var(--rowline); }
.row:focus-within .gut, .row.drag .gut { background: var(--blue); }
.row:focus-within .gut .n, .row.drag .gut .n { color: #fff; }
.n { font-size: 11px; color: var(--gutn); align-self: flex-start; padding-left: 6px; }
.ico { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; }
.ico.c-red { color: var(--red); background: var(--red); }
.ico.c-blue { color: var(--blue); background: var(--blue); }
.ico.c-green { color: var(--green); background: var(--green); }
.ico.c-purple { color: #8a6fd1; background: #8a6fd1; }
.ico.c-orange { color: var(--orange); background: var(--orange); }
.ico.img { border-radius: 3px; color: #8a8a8a; border-width: 2px; background: linear-gradient(135deg, transparent 55%, #8a8a8a 55% 70%, transparent 70%); }
.ico.folder-ico { border-radius: 2px; border: none; width: 20px; height: 14px; background: #8a8a8a; clip-path: polygon(0 0, 40% 0, 50% 18%, 100% 18%, 100% 100%, 0 100%); margin-top: 2px; }
.body { flex: 1; min-width: 0; padding: 12px 14px 12px 12px; }
.math { font: italic 20px var(--math); color: #f2f2f2; }
.math.big { font-size: 22px; font-style: normal; font-family: var(--ui); font-weight: 700; }
.math .eq, .math .val { font-style: normal; }
.math .muted { font: 14px var(--ui); }
.row.drag { outline: 2px dashed var(--blue2); outline-offset: -4px; }

/* segmented toggle */
.seg { display: inline-flex; margin-top: 8px; border: 1px solid var(--btnline); border-radius: 4px; overflow: hidden; flex-wrap: wrap; }
.seg button { font: 13px var(--ui); background: var(--btn); color: #cfcfcf; border: none; border-right: 1px solid var(--btnline); padding: 6px 12px; cursor: pointer; }
.seg button:last-child { border-right: none; }
.seg button:hover { background: #363636; }
.seg button.on { background: var(--blue); color: #fff; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: #cfcfcf; font-size: 13px; cursor: pointer; }
.check input { accent-color: var(--blue); width: 15px; height: 15px; }

/* Desmos-style slider */
.sl { padding: 2px 0 6px; }
.sl + .sl { margin-top: 6px; }
.sl .math { display: flex; align-items: baseline; gap: 6px; }
.sl .val { font-family: var(--ui); font-size: 17px; color: #f2f2f2; }
.sl .auto { font: 11px var(--ui); color: var(--muted); border: 1px solid #3a3a3a; border-radius: 3px; padding: 0 4px; margin-left: 4px; }
.sl .track { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.sl .lim { font: 12px var(--ui); color: var(--muted); min-width: 22px; }
.sl .lim:last-child { text-align: right; }
.sl input[type=range] { flex: 1; -webkit-appearance: none; appearance: none; background: transparent; height: 22px; margin: 0; --c: var(--blue2); }
.sl input[type=range]::-webkit-slider-runnable-track { height: 2px; background: #5a5a5a; }
.sl input[type=range]::-moz-range-track { height: 2px; background: #5a5a5a; }
.sl input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--c); margin-top: -7px; border: none; box-shadow: 0 0 0 0 rgba(91,155,213,0.35); transition: box-shadow 0.12s; }
.sl input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--c); border: none; }
.sl input[type=range]:hover::-webkit-slider-thumb, .sl input[type=range]:focus::-webkit-slider-thumb { box-shadow: 0 0 0 6px rgba(91,155,213,0.3); }
.sl input[type=range]:focus { outline: none; }

/* file */
.file { display: flex; align-items: center; gap: 10px; }
.file img { width: 54px; height: 54px; object-fit: cover; border-radius: 3px; background: #000; border: 1px solid #3a3a3a; }
.fmeta { flex: 1; min-width: 0; }
.fmeta > div:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.fold { background: none; border: none; color: #f2f2f2; font: 15px var(--ui); cursor: pointer; padding: 6px 0; display: flex; align-items: center; gap: 6px; }
.caret { display: inline-block; transition: transform 0.15s; color: var(--muted); }
.fold[aria-expanded=true] .caret { transform: rotate(90deg); }
#advBody { margin-top: 6px; }

.stats .count { font: 700 34px var(--ui); color: #fff; letter-spacing: -0.5px; }
.count i { font: italic 400 20px var(--math); color: #cfcfcf; letter-spacing: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; }
.foot { color: #777; font-size: 11.5px; padding: 12px 16px 24px; margin: 0; }

/* stage chrome */
.stabs { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 5; display: flex; background: #262626; border: 1px solid #3c3c3c; border-radius: 6px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.4); }
.stabs button { font: 13px var(--ui); color: #cfcfcf; background: none; border: none; padding: 7px 14px; cursor: pointer; border-right: 1px solid #3c3c3c; }
.stabs button:last-child { border-right: none; }
.stabs button.on { background: var(--blue); color: #fff; }
#cv { background: var(--graph); }
.empty { position: absolute; inset: 0; z-index: 4; display: flex; align-items: center; justify-content: center; padding: 24px;
  background-color: var(--graph);
  background-image: linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px), linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px; background-position: center; }
.emptyin { max-width: 560px; text-align: center; background: rgba(20,20,20,0.92); padding: 28px 30px; border: 1px solid #333; border-radius: 6px; }
.emptyin h1 { font: italic 400 40px/1.1 var(--math); margin: 0 0 12px; color: #fff; }
.emptyin p { color: #c4c4c4; font-size: 15px; }
.busy { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 6; background: #262626; border: 1px solid #3c3c3c; border-radius: 6px; padding: 10px 14px; display: flex; align-items: center; gap: 12px; box-shadow: 0 2px 12px rgba(0,0,0,0.5); font-size: 13px; }
.bar { width: 160px; height: 4px; background: #3a3a3a; border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--blue2); transition: width 0.15s; }
.bar.indet i { width: 35%; animation: indet 1.1s ease-in-out infinite; }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }

/* gallery */
.view.gallery { height: calc(100% - 48px); overflow-y: auto; padding: 28px 28px 60px; }
.ghead h1 { font: italic 400 36px var(--math); margin: 0 0 4px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-top: 22px; }
.gcard { background: #1e1e1e; border: 1px solid #303030; border-radius: 6px; overflow: hidden; text-decoration: none; color: var(--text); display: block; transition: border-color 0.12s, transform 0.12s; }
.gcard:hover { border-color: var(--blue2); transform: translateY(-2px); }
.gcard .ph { aspect-ratio: 1; background: #141414; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.gcard img { width: 100%; height: 100%; object-fit: contain; }
.gcard .gi { padding: 10px 12px; border-top: 1px solid #303030; }
.gcard .gt { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gcard .gm { color: var(--muted); font-size: 12px; margin-top: 2px; }
.gm i { font-family: var(--math); }
.tag { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; border: 1px solid #444; border-radius: 3px; padding: 0 4px; margin-left: 6px; color: #bbb; }

/* modals */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal .card { background: #222; border: 1px solid #3c3c3c; border-radius: 8px; padding: 22px 24px; width: min(520px, 100%); box-shadow: 0 10px 40px rgba(0,0,0,0.6); }
.modal h2 { margin: 0 0 12px; font: italic 400 26px var(--math); }
.modal ol { padding-left: 20px; color: #d8d8d8; line-height: 1.7; }
kbd { font: 12px var(--ui); background: #333; border: 1px solid #4a4a4a; border-bottom-width: 2px; border-radius: 3px; padding: 0 5px; }
code { background: #333; padding: 1px 5px; border-radius: 3px; }
.modal h3 { font: 700 14px var(--ui); margin: 16px 0 4px; color: #fff; }
.modal .card { max-height: calc(100vh - 32px); overflow-y: auto; }
.btn.bm { background: #2d70b3; color: #fff; border-color: #3a82c8; cursor: grab; padding: 3px 10px; font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #cfcfcf; }
.field input, .out input { font: 14px var(--ui); background: #161616; color: var(--text); border: 1px solid #454545; border-radius: 4px; padding: 8px 10px; }
.field input:focus, .out input:focus { outline: none; border-color: var(--blue2); }
.out { display: flex; gap: 8px; margin-top: 12px; }
.out input { flex: 1; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 60; background: #2f2f2f; border: 1px solid #4a4a4a; border-radius: 6px; padding: 10px 16px; box-shadow: 0 4px 18px rgba(0,0,0,0.5); }

@media (max-width: 860px) {
  body { overflow: auto; }
  .view.make { flex-direction: column; height: auto; }
  .list { width: 100%; border-right: none; box-shadow: none; overflow: visible; }
  .stage { height: 72vh; flex: none; order: -1; }
  .top { gap: 10px; padding: 0 10px; }
  .view.gallery { padding: 18px 16px 50px; height: auto; }
  .emptyin { padding: 20px 18px; }
  .emptyin h1 { font-size: 30px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
}
