:root {
  --bg: #101216;
  --bg-2: #232831;
  --fg: #ece9e2;
  --muted: #9aa0aa;
  --brass: #d9b45a;
  --tech: #8ccfff;
  --q: #f08a4b;
  --panel: rgba(20, 23, 29, .82);
  --line: rgba(255, 255, 255, .12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

#app {
  display: flex;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}

#stage {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  background: radial-gradient(120% 90% at 50% 40%, var(--bg-2) 0%, var(--bg) 70%);
  touch-action: none;
  container: stage / size;
}

#stage canvas { display: block; }

.labels {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* ---- üst bilgi ---- */
.title {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 2;
  pointer-events: none;
}
.brand {
  display: inline-block;
  margin-bottom: 12px;
  pointer-events: auto;
  opacity: .92;
  transition: opacity .15s;
}
.brand:hover { opacity: 1; }
.brand img { display: block; width: auto; height: 22px; }
.title h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: .2px;
}
.title p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.toolbar {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  display: flex;
  gap: 10px;
  align-items: center;
}

.views {
  display: flex;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
  backdrop-filter: blur(8px);
}
.views button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 7px;
  cursor: pointer;
}
.views button:hover { color: var(--fg); }
.views button.on { background: rgba(255, 255, 255, .1); color: var(--fg); }

.switch {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 12px 7px 8px;
  white-space: nowrap;
  cursor: pointer;
  backdrop-filter: blur(8px);
}
.switch .track {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 10px;
  background: #3a3f48;
  transition: background .2s;
}
.switch .thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s;
}
.switch[aria-checked="true"] .track { background: #2f86c7; }
.switch[aria-checked="true"] .thumb { transform: translateX(14px); }
.switch:focus-visible, .views button:focus-visible { outline: 2px solid var(--tech); outline-offset: 2px; }

.hint {
  position: absolute;
  left: 16px;
  bottom: 12px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
  z-index: 2;
}

#loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
  z-index: 3;
  pointer-events: none;
}
#loading.err { color: var(--q); }

/* ---- 3D etiketler ---- */
.tag {
  background: rgba(12, 16, 22, .86);
  border: 1px solid rgba(140, 207, 255, .55);
  border-radius: 6px;
  padding: 4px 8px;
  color: var(--fg);
  white-space: nowrap;
  font-size: 12px;
  line-height: 1.3;
}
.tag b { display: block; font-weight: 650; }
.tag span { color: var(--tech); font-size: 11px; }
.dimtag {
  color: var(--q);
  font: 700 12px/1 system-ui, sans-serif;
  background: rgba(12, 16, 22, .7);
  padding: 2px 4px;
  border-radius: 4px;
}
.lvl {
  color: var(--tech);
  font: 700 10px/1 system-ui, sans-serif;
  letter-spacing: .8px;
}

/* ---- teknik çizim paneli ---- */
#sheet {
  flex: 0 0 auto;
  width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #f4f4f2;
  color: #111;
  transition: width .3s ease;
}
#app.tech #sheet { width: min(46vw, 820px); border-left: 1px solid #000; }

.sheet-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid #ddd;
  font-size: 13px;
  white-space: nowrap;
}
.sheet-bar a { color: #1f6fb2; text-decoration: none; }
.sheet-bar a:hover { text-decoration: underline; }
.sheet-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px;
  display: grid;
  place-items: center;
}
.sheet-body img {
  width: 100%;
  height: auto;
  max-height: 100%;
  object-fit: contain;
  background: #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .15);
}

.sheet-body a { display: contents; }

/* 3D alanı daralınca (mobil ya da çizim paneli açıkken) araç çubuğu alta iner */
@container stage (max-width: 700px) {
  .toolbar { top: auto; bottom: 14px; right: 50%; transform: translateX(50%); }
  .hint { display: none; }
  .title h1 { font-size: 17px; }
  .brand { margin-bottom: 8px; }
  .brand img { height: 18px; }
}

@media (max-width: 760px) {
  #app { flex-direction: column; }
  #sheet { width: 100% !important; height: 0; transition: height .3s ease; }
  #app.tech #sheet { height: 46%; border-left: 0; border-top: 1px solid #000; }
}

@media (prefers-reduced-motion: reduce) {
  #sheet, .switch .track, .switch .thumb { transition: none; }
}
