:root {
  --bg1: #f6f7fb;
  --bg2: #dfe3ec;
  --ink: #1d2433;
  --muted: #5d6779;
  --card: rgba(255, 255, 255, 0.86);
  --line: rgba(29, 36, 51, 0.12);
  --accent: #7a56bb;
  --font: "Sarabun", "Noto Sans Thai", "Leelawadee UI", "Thonburi", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  color: var(--ink);
  font: 15px/1.45 var(--font);
  background: radial-gradient(120% 90% at 50% 35%, var(--bg1) 0%, var(--bg2) 100%);
  -webkit-tap-highlight-color: transparent;
}

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline: none;
}

.top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: max(12px, env(safe-area-inset-top)) 16px 0;
  pointer-events: none;
}
.top h1 { margin: 0; font-size: 19px; line-height: 1.25; }
.top h1 span {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: var(--muted);
  border-radius: 999px;
  padding: 1px 8px;
  vertical-align: 3px;
}
.top p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }

.loading {
  position: fixed;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  font-size: 14px;
}

.hint {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--panel-h, 230px) + 10px);
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.6s;
}
.hint.gone { opacity: 0; }

/* ---------- แผงล่าง (มือถือ) ---------- */
.panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 12px max(12px, env(safe-area-inset-bottom));
  background: var(--card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  max-height: 62vh;
  overflow-y: auto;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.tabs button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 2px 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: 600 12.5px/1.2 var(--font);
  cursor: pointer;
}
.tabs button i {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--sw);
}
.tabs button[aria-selected="true"] {
  border-color: var(--sw);
  box-shadow: inset 0 0 0 1.5px var(--sw);
}

.info h2 { margin: 10px 0 0; font-size: 18px; line-height: 1.2; }
.info .th { margin: 0 0 8px; color: var(--muted); font-size: 13.5px; }

.actions, .tools { display: flex; flex-wrap: wrap; gap: 8px; }
.tools { margin-top: 8px; }

button.act, .tools button {
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 10px;
  font: 600 14px/1.2 var(--font);
  cursor: pointer;
}
button.act {
  border: 0;
  color: #fff;
  background: var(--accent);
}
button.act:active { filter: brightness(0.92); }
.tools button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}
.tools button[aria-pressed="false"] { color: var(--muted); }

details { margin-top: 10px; font-size: 13.5px; }
summary { cursor: pointer; color: var(--muted); padding: 4px 0; }
details p { margin: 6px 0; }
details ul { margin: 4px 0; padding-left: 18px; }
details code { font-size: 12px; color: var(--muted); }
.files a { color: var(--accent); }

/* ---------- จอกว้าง: แผงด้านซ้าย ---------- */
@media (min-width: 820px) {
  .top { padding: 18px 24px 0; }
  .top h1 { font-size: 22px; }
  .panel {
    top: 92px;
    bottom: auto;
    left: 20px;
    right: auto;
    width: 320px;
    max-height: calc(100vh - 112px);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 14px;
    box-shadow: 0 6px 24px rgba(20, 30, 50, 0.08);
  }
  .tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hint { bottom: 18px; left: calc(50% + 170px); }
}
