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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a2e;
  color: #eee;
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Settings Bar */
#settings-bar {
  display: flex;
  gap: 24px;
  padding: 12px 16px;
  background: #16213e;
  border-bottom: 1px solid #0f3460;
  flex-wrap: wrap;
  align-items: center;
}

.settings-group {
  display: flex;
  gap: 16px;
  align-items: center;
}

.settings-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #aaa;
}

.settings-group input[type="text"],
.settings-group input[type="password"],
.settings-group input[type="number"] {
  background: #1a1a2e;
  border: 1px solid #0f3460;
  border-radius: 4px;
  padding: 6px 10px;
  color: #eee;
  font-size: 14px;
}

.settings-group input[type="number"] {
  width: 80px;
}

.settings-group input[type="password"] {
  width: 200px;
}

.settings-group button {
  background: #0f3460;
  border: 1px solid #4a90d9;
  border-radius: 4px;
  padding: 6px 12px;
  color: #aaa;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.settings-group button:hover {
  background: #1a4a7a;
  color: #eee;
}

.settings-group input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

#storage-indicator {
  font-size: 13px;
  color: #666;
}

/* Main Content */
#main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Tree Panel */
#tree-panel {
  width: 40%;
  min-width: 300px;
  border-right: 1px solid #0f3460;
  display: flex;
  flex-direction: column;
  background: #16213e;
  overflow: hidden;
}

#tree-container {
  flex: 1;
  overflow: hidden;
}

/* Text Panel */
#text-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #1a1a2e;
}

#text-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  line-height: 1.7;
  font-size: 16px;
  display: flex;
  flex-direction: column;
}

#text-content.logprobs-view {
  display: block;
  white-space: pre-wrap;
}

/* Node styling in text view */
.node-text {
  cursor: pointer;
  border-radius: 3px;
  transition: box-shadow 0.15s ease;
}

.node-text:hover {
  box-shadow: 0 0 0 1px #4a90d9;
}

.node-text.selected {
  box-shadow: 0 0 0 2px #4a90d9;
}

/* Token styling */
.token {
  border-radius: 2px;
  transition: background-color 0.15s ease;
}

.token:hover {
  outline: 1px solid rgba(255, 255, 255, 0.3);
}

/* Partial token (spans node boundary) */
.token.partial-token {
  border-style: dashed;
  border-width: 1px;
  border-color: rgba(255, 255, 255, 0.3);
}

/* Logprob tooltip */
.token-tooltip {
  position: fixed;
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  z-index: 1000;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  max-width: 300px;
}

.token-tooltip .token-text {
  font-weight: 600;
  margin-bottom: 6px;
  color: #fff;
}

.token-tooltip .token-logprob {
  color: #aaa;
  margin-bottom: 8px;
}

.token-tooltip .top-k {
  border-top: 1px solid #0f3460;
  padding-top: 8px;
  margin-top: 4px;
}

.token-tooltip .top-k-item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 12px;
  color: #888;
  margin-top: 4px;
}

.token-tooltip .top-k-item .alt-token {
  color: #ccc;
}

/* Node actions */
#node-actions {
  display: flex;
  gap: 8px;
  padding: 16px 24px;
  background: #16213e;
  border-top: 1px solid #0f3460;
}

#node-actions.hidden {
  display: none;
}

#node-actions button {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

#node-actions button:hover {
  transform: translateY(-1px);
}

#node-actions button:active {
  transform: translateY(0);
}

#btn-generate {
  background: #e94560;
  color: #fff;
}

#btn-generate:hover {
  background: #ff6b6b;
}

#btn-split {
  background: #0f3460;
  color: #eee;
}

#btn-split:hover {
  background: #1a4a7a;
}

#btn-delete {
  background: #0f3460;
  color: #eee;
}

#btn-delete:hover {
  background: #1a4a7a;
}

/* Main editor textarea */
.main-editor {
  flex: 1;
  width: 100%;
  background: transparent;
  border: none;
  padding: 0;
  color: #eee;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.7;
  resize: none;
  outline: none;
}

.main-editor::placeholder {
  color: #666;
}

/* Tree visualization */
#tree-container svg {
  display: block;
  width: 100%;
  height: 100%;
}

.tree-node circle {
  fill: #2a3f5f;
  stroke: #4a90d9;
  stroke-width: 2px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tree-node circle:hover {
  fill: #3a5f8f;
  stroke-width: 3px;
}

.tree-node circle.selected {
  fill: #e94560;
  stroke: #fff;
  stroke-width: 3px;
  filter: drop-shadow(0 0 8px #e94560);
}

.tree-link {
  fill: none;
  stroke: #0f3460;
  stroke-width: 2px;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #1a1a2e;
}

::-webkit-scrollbar-thumb {
  background: #0f3460;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #1a4a7a;
}

/* Welcome Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal-overlay.hidden {
  display: none;
}

.modal-content {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 8px;
  padding: 24px 32px;
  max-width: 500px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.modal-content p {
  margin-bottom: 20px;
  line-height: 1.6;
  color: #ccc;
}

.modal-content button {
  background: #e94560;
  border: none;
  border-radius: 6px;
  padding: 10px 32px;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.modal-content button:hover {
  background: #ff6b6b;
}

/* Utility */
.hidden {
  display: none !important;
}

/* Loading state */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

.loading::after {
  content: 'Generating...';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #16213e;
  padding: 16px 24px;
  border-radius: 8px;
  border: 1px solid #0f3460;
}
