:root {
  --bg: #0f1114;
  --panel: #1a1d23;
  --border: #2c313a;
  --accent: #4f8cff;
  --stage-bg: #000;
  --nav-h: 56px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: #e8eaed;
  font-family: "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
}

.navbar {
  min-height: var(--nav-h);
}

.app-shell {
  height: calc(100vh - var(--nav-h));
  padding: 0.75rem;
  overflow: hidden;
}

.app-shell > .row {
  height: 100%;
}

.sidebar-col {
  height: 100%;
  overflow-y: auto;
}

.intro-hint {
  color: #c8ccd2;
  font-size: 0.95rem;
  line-height: 1.45;
  margin: 0;
}

.stage-col {
  height: 100%;
  min-height: 0;
}

.stage-panel {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.stage-toolbar {
  flex: 0 0 auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

.canvas-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  background: #6e6e6e;
  border-radius: 0.35rem;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px;
}

#stage {
  background: var(--stage-bg);
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  cursor: default;
  box-shadow: 0 0 0 1px #222, 0 8px 32px rgba(0, 0, 0, 0.55);
  touch-action: none;
}

.image-slot {
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  padding: 0.65rem;
  margin-bottom: 0.5rem;
  transition: border-color 0.15s, background 0.15s;
}

.image-slot.active {
  border-color: var(--accent);
  background: rgba(79, 140, 255, 0.08);
}

.image-slot .slot-title {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.image-slot .thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 0.25rem;
  background: #000;
  border: 1px solid var(--border);
}

.form-control,
.form-select,
.form-range {
  background-color: #12151a;
  border-color: var(--border);
  color: #e8eaed;
}

.form-control:focus,
.form-select:focus {
  background-color: #12151a;
  border-color: var(--accent);
  color: #e8eaed;
  box-shadow: 0 0 0 0.2rem rgba(79, 140, 255, 0.25);
}

.form-control::placeholder {
  color: #6c757d;
}

.btn-primary {
  background-color: var(--accent);
  border-color: var(--accent);
}

.btn-primary:hover {
  background-color: #3a78ef;
  border-color: #3a78ef;
}

.btn-outline-light {
  border-color: var(--border);
  color: #c8ccd2;
}

.btn-outline-light:hover {
  background: #2a2f38;
  border-color: #3a4150;
  color: #fff;
}

.orient-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.orient-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.75rem 0.5rem;
  background: #12151a;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  color: #9aa0a8;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.orient-btn:hover {
  border-color: #3a4150;
  color: #e8eaed;
  background: #1a1f27;
}

.orient-btn.active {
  border-color: var(--accent);
  background: rgba(79, 140, 255, 0.12);
  color: #e8eaed;
}

.orient-label {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.orient-icon {
  display: block;
  border: 2px solid currentColor;
  border-radius: 2px;
  opacity: 0.85;
}

.orient-icon-landscape {
  width: 28px;
  height: 18px;
}

.orient-icon-portrait {
  width: 18px;
  height: 28px;
}

.orient-btn.active .orient-icon {
  opacity: 1;
  border-color: var(--accent);
}

#saveStatus.ok { color: #6dd58c; }
#saveStatus.err { color: #f28b82; }
#saveStatus.busy { color: #fdd663; }

@media (max-width: 991.98px) {
  body { overflow: auto; }
  .app-shell {
    height: auto;
    overflow: visible;
  }
  .app-shell > .row { height: auto; }
  .sidebar-col { height: auto; overflow: visible; }
  .stage-col { height: auto; }
  .stage-panel { height: auto; }
  .canvas-wrap {
    height: min(70vh, 720px);
    flex: none;
  }
}
