/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', sans-serif;
  background: #1e1e2e;
  color: #cdd6f4;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

/* ===== App Header ===== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #181825;
  border-bottom: 1px solid #313244;
  flex-shrink: 0;
  z-index: 100;
  gap: 10px;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon { font-size: 22px; }

.brand-name {
  font-size: 15px;
  font-weight: 700;
  color: #cba6f7;
  letter-spacing: -0.3px;
}

.brand-tagline {
  font-size: 11px;
  color: #6c7086;
}

.app-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.action-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.toolbar-label {
  font-size: 11px;
  color: #a6adc8;
}

.toolbar-select {
  border: 1px solid #45475a;
  border-radius: 8px;
  padding: 6px 8px;
  background: #1e1e2e;
  color: #cdd6f4;
  font-size: 12px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.12s ease, transform 0.1s ease;
  white-space: nowrap;
}

.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(0.96); }

.btn-primary  { background: #89b4fa; color: #1e1e2e; }
.btn-secondary { background: #313244; color: #cdd6f4; }
.btn-danger   { background: #f38ba8; color: #1e1e2e; }

/* ===== Editor Layout ===== */
.editor-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ===== Panels ===== */
.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-panel {
  width: 55%;
  min-width: 280px;
  flex-shrink: 0;
}

.preview-panel {
  flex: 1;
  min-width: 280px;
}

/* ===== Panel Toolbar ===== */
.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: #181825;
  border-bottom: 1px solid #313244;
  flex-shrink: 0;
  height: 40px;
  gap: 8px;
}

.panel-title {
  font-size: 12px;
  font-weight: 700;
  color: #a6adc8;
  white-space: nowrap;
}

.panel-hint {
  font-size: 11px;
  color: #6c7086;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Blockly Area ===== */
#blocklyDiv {
  flex: 1;
  min-height: 0;
}

/* ===== Resize Handle ===== */
.resize-handle {
  width: 5px;
  background: #313244;
  cursor: col-resize;
  flex-shrink: 0;
  transition: background 0.15s;
  position: relative;
}

.resize-handle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 3px;
  height: 40px;
  background: #45475a;
  border-radius: 2px;
}

.resize-handle:hover,
.resize-handle.dragging {
  background: #45475a;
}

.resize-handle:hover::after,
.resize-handle.dragging::after {
  background: #89b4fa;
}

/* ===== Preview Panel ===== */
.tab-bar {
  display: flex;
  gap: 2px;
}

.tab-btn {
  padding: 4px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #6c7086;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s;
}

.tab-btn:hover { color: #cdd6f4; background: #2a2a3e; }
.tab-btn.active { background: #313244; color: #89b4fa; }

.preview-content {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #11111b;
  padding: 16px;
}

.preview-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, .35);
}

.preview-frame.device-tablet {
  width: min(900px, 100%);
  height: min(100%, 1100px);
}

.preview-frame.device-mobile {
  width: min(430px, 100%);
  height: min(100%, 860px);
}

.code-view {
  width: 100%;
  height: 100%;
  padding: 16px 20px;
  overflow: auto;
  background: #11111b;
  font-family: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', 'Courier New', monospace;
  font-size: 12.5px;
  line-height: 1.65;
  color: #a6e3a1;
  white-space: pre;
  tab-size: 2;
}

.status-bar {
  height: 28px;
  border-top: 1px solid #313244;
  background: #181825;
  color: #6c7086;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
}

#statusMessage {
  color: #a6adc8;
}

#statusMeta {
  color: #89b4fa;
}

.status-shortcuts {
  margin-left: auto;
}

@media (max-width: 1200px) {
  .brand-tagline {
    display: none;
  }
}

@media (max-width: 980px) {
  .status-shortcuts {
    display: none;
  }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #313244; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #45475a; }
