* {
  box-sizing: border-box;
}

:root {
  --alfa-bg-deep: #0f1f3a;
  --alfa-bg-mid: #131a26;
  --alfa-panel: #1e2b45;
  --alfa-panel-border: #2a477c;
  --alfa-primary: #1976d2;
  --alfa-primary-hover: #2196f3;
  --alfa-status: #0e4b96;
  --alfa-text: #d4d4d4;
}

:root[data-theme="light"] {
  --alfa-bg-deep: #dce8fb;
  --alfa-bg-mid: #edf3ff;
  --alfa-panel: #f4f8ff;
  --alfa-panel-border: #b8cced;
  --alfa-primary: #1d4ed8;
  --alfa-primary-hover: #2563eb;
  --alfa-status: #0f3f8a;
  --alfa-text: #1f2937;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: "Inter", "Segoe UI", sans-serif;
  background: #1e1e1e;
  color: var(--alfa-text);
}

body {
  overflow: hidden;
  background: linear-gradient(180deg, var(--alfa-bg-deep) 0%, var(--alfa-bg-mid) 36%, #1e1e1e 100%);
}

.app-shell,
.prompt-screen,
.workspace-screen {
  height: 100%;
}

.prompt-screen,
.workspace-screen {
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

.top-bar {
  height: 40px;
  padding: 0 16px;
  background: #16233b;
  border-bottom: 1px solid #23457d;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.title {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}

:root[data-theme="light"] .title {
  color: #10233f;
}

.theme-toggle {
  border: 1px solid #2f578f;
  background: #203860;
  color: #e5edf8;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.theme-toggle:hover {
  background: #2a4a83;
}

:root[data-theme="light"] .theme-toggle {
  border-color: #8da9d3;
  background: #e6eefc;
  color: #1f365d;
}

:root[data-theme="light"] .theme-toggle:hover {
  background: #d6e4fa;
}

.brand-logo {
  width: 20px;
  height: 20px;
  object-fit: contain;
  filter: drop-shadow(0 0 6px rgba(33, 150, 243, 0.35));
}

.prompt-main {
  position: relative;
  flex: 1;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at center, #1b2f54 0%, #151d2f 48%, #1e1e1e 100%);
  padding: 24px;
}

.hero {
  width: min(900px, 100%);
  text-align: center;
}

.hero-banner {
  width: min(520px, 86%);
  max-height: 132px;
  object-fit: contain;
  margin: 0 auto 24px;
  filter: drop-shadow(0 12px 28px rgba(14, 57, 125, 0.65));
}

:root[data-theme="light"] .hero-banner,
:root[data-theme="light"] .quick-banner {
  filter: brightness(0) saturate(100%) opacity(0.82) drop-shadow(0 8px 18px rgba(29, 78, 216, 0.18));
}

:root[data-theme="light"] .brand-logo {
  filter: drop-shadow(0 0 4px rgba(29, 78, 216, 0.22)) contrast(1.05);
}

.hero h1 {
  margin: 0;
  font-size: clamp(32px, 6vw, 52px);
  color: #fff;
}

.hero h1 span {
  color: #66b6ff;
}

.hero p {
  margin: 14px auto 24px;
  max-width: 700px;
  color: #9ca3af;
  font-size: 18px;
}

.prompt-card {
  margin: 0 auto;
  width: min(820px, 100%);
  border: 1px solid #3e3e42;
  border-radius: 14px;
  background: linear-gradient(180deg, #20293a 0%, #1e2432 100%);
  overflow: hidden;
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.4);
}

:root[data-theme="light"] .prompt-card {
  border-color: #cad7eb;
  background: linear-gradient(180deg, #ffffff 0%, #eff4fc 100%);
  box-shadow: 0 16px 34px rgba(40, 72, 122, 0.16);
}

#prompt-input {
  display: block;
  width: 100%;
  min-height: 110px;
  resize: vertical;
  border: 0;
  outline: none;
  background: transparent;
  color: #fff;
  padding: 16px;
  font-size: 18px;
}

:root[data-theme="light"] #prompt-input {
  color: #1f2937;
}

.prompt-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #333;
  padding: 12px 16px;
}

.prompt-actions span {
  font-size: 11px;
  color: #7d818a;
}

#generate-button {
  border: 0;
  border-radius: 8px;
  padding: 10px 22px;
  background: var(--alfa-primary);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

#generate-button:hover {
  background: var(--alfa-primary-hover);
}

#generate-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.error-message {
  margin: 16px auto 0;
  max-width: 760px;
  border: 1px solid rgba(239, 68, 68, 0.6);
  background: rgba(127, 29, 29, 0.2);
  color: #fca5a5;
  border-radius: 8px;
  padding: 12px;
}

.status-bar {
  height: 24px;
  padding: 0 12px;
  background: var(--alfa-status);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  flex-shrink: 0;
}

.workspace-main {
  flex: 1;
  display: flex;
  min-height: 0;
}

.top-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.menu-items {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: #9ca3af;
}

.quick-launch {
  background: #203860;
  border: 1px solid #2f578f;
  border-radius: 4px;
  font-size: 11px;
  padding: 5px 10px;
  color: #d1d5db;
  display: flex;
  align-items: center;
  gap: 8px;
}

:root[data-theme="light"] .quick-launch {
  background: #e8f0ff;
  border-color: #b8cced;
  color: #1f365d;
}

.quick-banner {
  width: 52px;
  height: 14px;
  object-fit: contain;
}

.solution-panel {
  width: 288px;
  border-right: 1px solid var(--alfa-panel-border);
  background: var(--alfa-panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-header {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #333;
  text-transform: uppercase;
  font-size: 11px;
  color: #9ca3af;
  font-weight: 600;
}

:root[data-theme="light"] .panel-header,
:root[data-theme="light"] .history-header,
:root[data-theme="light"] .prompt-actions span,
:root[data-theme="light"] .menu-items,
:root[data-theme="light"] .history-prompt,
:root[data-theme="light"] .history-date,
:root[data-theme="light"] .tree-caret,
:root[data-theme="light"] .line-numbers,
:root[data-theme="light"] .editor-empty {
  color: #5f6f87;
}

:root[data-theme="light"] .history-empty {
  color: #6a7b93;
}

.panel-header button {
  border: 0;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
}

.tree-container {
  flex: 1;
  overflow: auto;
  padding: 8px 0;
}

.history-panel {
  border-top: 1px solid #333;
  min-height: 180px;
  max-height: 240px;
  display: flex;
  flex-direction: column;
}

.history-header {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  text-transform: uppercase;
  color: #9ca3af;
  font-weight: 600;
}

.history-header button {
  border: 0;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
}

.history-empty {
  color: #6b7280;
  font-size: 12px;
  padding: 12px;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
}

.history-item {
  padding: 8px 12px;
  border-top: 1px solid #303030;
  cursor: pointer;
}

.history-item:hover {
  background: #2a2d2e;
}

:root[data-theme="light"] .history-item {
  border-top-color: #d4deed;
}

:root[data-theme="light"] .history-item:hover,
:root[data-theme="light"] .tree-row:hover {
  background: #e6eefc;
}

:root[data-theme="light"] .tree-row.selected {
  background: #d8e7ff;
}

.history-title {
  font-size: 12px;
  color: #f3f4f6;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

:root[data-theme="light"] .history-title,
:root[data-theme="light"] .tree-label,
:root[data-theme="light"] .code-content {
  color: #1f2937;
}

.history-prompt {
  margin-top: 3px;
  font-size: 11px;
  color: #9ca3af;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-date {
  margin-top: 4px;
  font-size: 10px;
  color: #6b7280;
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 5px;
  padding-bottom: 5px;
  font-size: 13px;
  cursor: pointer;
}

.tree-row:hover {
  background: #2a2d2e;
}

.tree-row.selected {
  background: #37373d;
}

.tree-caret {
  width: 10px;
  text-align: center;
  color: #9ca3af;
}

.tree-icon {
  width: 14px;
}

.tree-label {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.editor-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #141b29;
}

.editor-empty {
  flex: 1;
  display: grid;
  place-items: center;
  color: #6b7280;
}

.editor-view {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.editor-tab {
  height: 36px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  color: #fff;
  background: #1b2f54;
  border-bottom: 1px solid #2a4a83;
}

:root[data-theme="light"] .top-bar {
  background: #e8f0ff;
  border-bottom-color: #b8cced;
}

:root[data-theme="light"] .prompt-main {
  background: radial-gradient(circle at center, #f5f9ff 0%, #e8f0ff 45%, #dce8fb 100%);
}

:root[data-theme="light"] .hero h1,
:root[data-theme="light"] .status-bar,
:root[data-theme="light"] .editor-tab {
  color: #10233f;
}

:root[data-theme="light"] .hero p {
  color: #4f6079;
}

:root[data-theme="light"] .solution-panel,
:root[data-theme="light"] .editor-panel,
:root[data-theme="light"] .editor-tab {
  background: #f7faff;
}

:root[data-theme="light"] .editor-tab {
  border-bottom-color: #c6d6ee;
}

:root[data-theme="light"] .status-bar {
  background: #d1e1fb;
}

:root[data-theme="light"] .line-numbers {
  border-right-color: #d2deef;
}

:root[data-theme="light"] .token-string {
  color: #b45309;
}

:root[data-theme="light"] .token-keyword {
  color: #1d4ed8;
}

:root[data-theme="light"] .token-comment {
  color: #15803d;
}

@media (max-width: 980px) {
  .menu-items {
    display: none;
  }

  .quick-launch {
    padding: 4px 8px;
  }

  .quick-banner {
    display: none;
  }

  .solution-panel {
    width: 250px;
  }
}

.editor-content {
  flex: 1;
  display: flex;
  overflow: auto;
}

.line-numbers {
  min-width: 54px;
  text-align: right;
  padding: 12px 8px;
  border-right: 1px solid #333;
  color: #6b7280;
  line-height: 1.6;
  user-select: none;
}

.code-content {
  margin: 0;
  padding: 12px 14px;
  line-height: 1.6;
  font-family: "Fira Code", Consolas, monospace;
  font-size: 14px;
  white-space: pre;
  color: #d4d4d4;
}

.token-string {
  color: #fdba74;
}

.token-keyword {
  color: #60a5fa;
}

.token-comment {
  color: #22c55e;
}
