/* --- ベース・変数設定 --- */
:root {
  --bg-color: #1e1e1e;
  --header-bg: #252526;
  --sidebar-bg: #252526;
  --editor-bg: #1e1e1e;
  --text-color: #d4d4d4;
  --accent-color: #0e639c;
  --accent-hover: #1177bb;
  --border-color: #3c3c3c;
  --error-color: #f44336;
}

.light-theme {
  --bg-color: #ffffff;
  --header-bg: #f3f3f3;
  --sidebar-bg: #f3f3f3;
  --editor-bg: #ffffff;
  --text-color: #333333;
  --accent-color: #007acc;
  --accent-hover: #0062a3;
  --border-color: #e0e0e0;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* --- ヘッダー --- */
.ide-header {
  height: 48px;
  background-color: var(--header-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
}

.project-title {
  font-weight: bold;
  font-size: 16px;
}

.header-actions {
  display: flex;
  gap: 8px;
}

/* --- ボタン類 --- */
.action-btn, .icon-btn, .icon-btn-sm, .tool-btn {
  background-color: var(--border-color);
  color: var(--text-color);
  border: none;
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 14px;
  cursor: pointer;
}

.action-btn.primary {
  background-color: var(--accent-color);
  color: #fff;
}

.action-btn.danger {
  background-color: var(--error-color);
  color: #fff;
}

.icon-btn {
  font-size: 18px;
  padding: 4px 8px;
}

/* --- メインレイアウト (スマホ優先) --- */
.ide-container {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

/* スマホ時：サイドバーはオーバーレイ（隠しメニュー） */
.file-sidebar {
  position: absolute;
  top: 0;
  left: -260px;
  width: 250px;
  height: 100%;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  z-index: 10;
  transition: left 0.3s ease;
  display: flex;
  flex-direction: column;
  padding: 12px;
}

.file-sidebar.open {
  left: 0;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-weight: bold;
}

.file-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
}

.file-list li {
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  margin-bottom: 4px;
}

.file-list li.active {
  background-color: var(--accent-color);
  color: #fff;
}

.sidebar-tools {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.tool-btn {
  width: 100%;
  text-align: left;
}

/* ワークスペース & エディタ */
.editor-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.tab-bar {
  display: flex;
  background-color: var(--header-bg);
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
}

.editor-container {
  flex: 1;
  position: relative;
}

/* 20pxフォント指定で自動ズーム防止 */
.code-editor {
  width: 100%;
  height: 100%;
  background-color: var(--editor-bg);
  color: var(--text-color);
  border: none;
  resize: none;
  padding: 12px;
  font-family: monospace;
  font-size: 20px;
  line-height: 1.5;
  outline: none;
}

/* デバッグパネル */
.debug-panel {
  height: 120px;
  background-color: var(--header-bg);
  border-top: 1px solid var(--border-color);
  display: none;
  flex-direction: column;
  padding: 8px 12px;
}

.debug-panel.active {
  display: flex;
}

.debug-header {
  display: flex;
  justify-content: space-between;
  font-weight: bold;
  margin-bottom: 8px;
}

.error-list {
  color: var(--error-color);
  font-size: 14px;
  overflow-y: auto;
  font-family: monospace;
}

/* プレビュー画面 */
.play-screen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg-color);
  z-index: 100;
  display: none;
  flex-direction: column;
}

.play-screen-overlay.active {
  display: flex;
}

.play-header {
  height: 48px;
  background-color: var(--header-bg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 12px;
}

.play-frame {
  flex: 1;
  border: none;
  width: 100%;
  height: 100%;
}

/* --- PC用レスポンシブ配置（1024px以上をPC基準に変更） --- */
@media (min-width: 1024px) {
  .file-sidebar {
    position: relative;
    left: 0;
    width: 240px;
  }

  .file-sidebar.closed {
    display: none;
  }
}