/* CalcHub - original styles. Dark calculator, light games vault. */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #101418;
  --panel: #171c22;
  --panel-2: #1f262e;
  --key: #262e38;
  --key-hover: #313c49;
  --accent: #f5a623;
  --accent-2: #2f9e6e;
  --text: #f2f4f6;
  --muted: #9aa5b1;
  --line: #2a323d;
  --light-bg: #f4f5f7;
  --light-card: #ffffff;
  --light-text: #1b2430;
  --radius: 14px;
}
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 560px; margin: 0 auto; padding: 18px 14px 40px; }
header.site { text-align: center; margin-bottom: 16px; }
header.site h1 { font-size: 26px; letter-spacing: .4px; }
header.site h1 span { color: var(--accent); }
header.site p { color: var(--muted); font-size: 14px; margin-top: 4px; }
nav.tools { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 14px 0 4px; }
nav.tools a {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  padding: 7px 12px; border-radius: 999px; font-size: 13px; text-decoration: none;
}
nav.tools a:hover { border-color: var(--accent); }
nav.tools a.active { background: var(--accent); color: #161616; border-color: var(--accent); }

/* Code mode row */
.code-row { display: flex; align-items: center; justify-content: space-between; margin: 12px 0 10px; }
.code-row .label { font-size: 13px; color: var(--muted); }
.code-dots { display: flex; gap: 6px; visibility: hidden; }
.code-dots.on { visibility: visible; }
.code-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: block; }
.code-dots i.filled { background: var(--accent); }
.switch { position: relative; display: inline-block; width: 46px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; background: var(--key); border-radius: 999px;
  transition: background .2s; cursor: pointer; border: 1px solid var(--line);
}
.switch .track:before {
  content: ""; position: absolute; width: 20px; height: 20px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%; transition: transform .2s;
}
.switch input:checked + .track { background: var(--accent-2); }
.switch input:checked + .track:before { transform: translateX(20px); }

/* Calculator */
.calc { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.display {
  background: #0b0e11; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; min-height: 78px; text-align: right; overflow-x: auto;
}
.display .expr { color: var(--muted); font-size: 15px; min-height: 20px; word-break: break-all; }
.display .result { font-size: 32px; font-weight: 600; line-height: 1.2; word-break: break-all; }
.display .result.error { color: #e5484d; font-size: 22px; }
.keys { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 12px; }
.keys button {
  background: var(--key); color: var(--text); border: none; border-radius: 10px;
  font-size: 18px; padding: 13px 4px; cursor: pointer; font-family: inherit;
}
.keys button:hover { background: var(--key-hover); }
.keys button:active { transform: scale(.97); }
.keys button.op { background: #3a2f14; color: var(--accent); }
.keys button.fn { background: #1d2a33; color: #7cc4ff; font-size: 15px; }
.keys button.eq { background: var(--accent); color: #161616; font-weight: 700; }
.keys button.clr { background: #3a1d1d; color: #ff8a8a; }
.keys button.wide { grid-column: span 2; }
.hint { color: var(--muted); font-size: 12px; text-align: center; margin-top: 12px; line-height: 1.5; }

/* Info sections */
section.info { margin-top: 26px; }
section.info h2 { font-size: 19px; margin-bottom: 8px; }
section.info p, section.info li { color: #c9d1d9; font-size: 14.5px; line-height: 1.65; }
section.info ul { padding-left: 20px; }
.faq { margin-top: 10px; }
.faq details { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; }
.faq summary { cursor: pointer; font-weight: 600; font-size: 14.5px; }
.faq p { margin-top: 8px; }
footer.site { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 34px; line-height: 1.7; }

/* Tool pages */
.tool { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-top: 14px; }
.tool label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; }
.tool label:first-child { margin-top: 0; }
.tool input, .tool select {
  width: 100%; background: #0b0e11; color: var(--text); border: 1px solid var(--line);
  border-radius: 9px; padding: 11px 12px; font-size: 16px; font-family: inherit;
}
.tool .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tool button.go {
  width: 100%; margin-top: 16px; background: var(--accent); color: #161616; border: none;
  border-radius: 10px; padding: 13px; font-size: 16px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.tool .out {
  margin-top: 16px; background: #0b0e11; border: 1px solid var(--line); border-radius: 10px;
  padding: 14px; font-size: 16px; line-height: 1.6; display: none;
}
.tool .out.show { display: block; }
.tool .out b { color: var(--accent); font-size: 20px; }
.tool .note { color: var(--muted); font-size: 13px; margin-top: 10px; line-height: 1.5; }
.page-head { text-align: center; margin: 8px 0 4px; }
.page-head h1 { font-size: 24px; }
.page-head p { color: var(--muted); font-size: 14px; margin-top: 5px; }

/* Games vault */
.vault {
  position: fixed; inset: 0; z-index: 50; background: var(--light-bg); color: var(--light-text);
  display: none; flex-direction: column;
}
.vault.open { display: flex; }
.vault-top {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  background: #16191d; color: #fff; flex-wrap: wrap;
}
.vault-top .brand { font-weight: 700; font-size: 17px; white-space: nowrap; }
.vault-top .brand span { color: var(--accent); }
.vault-top input[type="search"] {
  flex: 1; min-width: 150px; padding: 9px 12px; border-radius: 999px; border: none;
  font-size: 15px; font-family: inherit; background: #262c33; color: #fff; outline: none;
}
.vault-top input[type="search"]::placeholder { color: #8b949e; }
.vault-top .count { font-size: 13px; color: #9aa5b1; white-space: nowrap; }
.vault-top button.close {
  background: #e5484d; color: #fff; border: none; border-radius: 8px;
  padding: 8px 14px; font-size: 14px; cursor: pointer; font-family: inherit;
}
.vault-body { display: flex; flex: 1; min-height: 0; }
.vault-side {
  width: 168px; flex-shrink: 0; background: #fff; border-right: 1px solid #e2e5e9;
  padding: 10px 8px; overflow-y: auto;
}
.vault-side button {
  display: block; width: 100%; text-align: left; background: none; border: none;
  padding: 9px 10px; border-radius: 8px; font-size: 14px; cursor: pointer;
  color: var(--light-text); font-family: inherit;
}
.vault-side button:hover { background: #f0f1f3; }
.vault-side button.active { background: #16191d; color: #fff; font-weight: 600; }
.vault-side button .n { float: right; color: #8b949e; font-size: 12px; }
.vault-side button.active .n { color: #c9d1d9; }
.vault-main { flex: 1; overflow-y: auto; padding: 16px; min-width: 0; }
.vault-main h2 { font-size: 18px; margin-bottom: 4px; }
.vault-main .sub { color: #5c6672; font-size: 13px; margin-bottom: 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.card {
  background: var(--light-card); border: 1px solid #e2e5e9; border-radius: 12px;
  overflow: hidden; cursor: pointer; text-align: left; padding: 0; font-family: inherit;
  transition: transform .12s, box-shadow .12s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.14); }
.card .thumb { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: #dfe3e8; }
.card .tile {
  width: 100%; aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center;
  font-size: 40px; font-weight: 800; color: #fff;
}
.card .name { font-size: 13.5px; font-weight: 600; padding: 8px 10px 2px; color: var(--light-text); }
.card .cat { font-size: 12px; color: #7a8592; padding: 0 10px 9px; }
.empty { color: #5c6672; padding: 30px 10px; text-align: center; font-size: 15px; }

/* Player */
.player { display: none; flex: 1; flex-direction: column; min-height: 0; background: #000; }
.player.open { display: flex; }
.player-bar {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: #16191d; color: #fff;
}
.player-bar .title { flex: 1; font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-bar button {
  background: #262c33; color: #fff; border: none; border-radius: 8px;
  padding: 8px 12px; font-size: 13.5px; cursor: pointer; font-family: inherit;
}
.player-bar button:hover { background: #333a42; }
.player iframe { flex: 1; width: 100%; border: none; background: #000; min-height: 0; }

@media (max-width: 640px) {
  .keys button { font-size: 16px; padding: 12px 4px; }
  .display .result { font-size: 27px; }
  .vault-side { width: 128px; }
  .vault-side button { font-size: 13px; padding: 8px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 9px; }
  .card .tile { font-size: 30px; }
}
