*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: #111827;
  background: #f3f4f6;
}

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

.app-header {
  padding: 0.75rem 1.5rem;
  background: #111827;
  color: #f9fafb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.app-header h1 {
  font-size: 1.25rem;
  margin: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.file-input-label {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.75rem;
  border-radius: 0.375rem;
  background: #4b5563;
  color: #f9fafb;
  font-size: 0.875rem;
  cursor: pointer;
}

.file-input-label input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

button {
  padding: 0.35rem 0.75rem;
  border-radius: 0.375rem;
  border: none;
  background: #2563eb;
  color: #f9fafb;
  font-size: 0.875rem;
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

button:hover:not(:disabled) {
  background: #1d4ed8;
}

.current-session-btn.is-current {
  background: #059669;
}

.current-session-btn.is-current:hover:not(:disabled) {
  background: #047857;
}

.status-message {
  font-size: 0.75rem;
  min-height: 1em;
}

.status-message--clickable {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
}

.app-main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  grid-template-rows: 1fr;
  gap: 1rem;
  padding: 1rem 1.5rem;
}

.profiles-panel {
  background: #ffffff;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem 1rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.details-panel {
  background: #ffffff;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem 1rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.panel-header h2,
.panel-header h3 {
  margin: 0;
  font-size: 1rem;
}

.panel-actions {
  display: flex;
  gap: 0.25rem;
}

.profiles-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  border-radius: 0.375rem;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
}

.profile-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.6rem;
  gap: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
}

.profile-item:nth-child(odd) {
  background: #f3f4f6;
}

.profile-item.selected {
  background: #dbeafe;
}

.profile-item.drag-over {
  outline: 2px dashed #2563eb;
}

.profile-item.inactive {
  opacity: 0.85;
}

.profile-item.inactive .profile-subtitle,
.profile-item.inactive .profile-meta {
  color: #9ca3af;
}

.profile-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.profile-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-subtitle {
  font-size: 0.75rem;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-meta {
  font-size: 0.75rem;
  color: #6b7280;
}

.details-panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.placeholder {
  font-size: 0.9rem;
  color: #6b7280;
}

.profile-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.form-row label {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  gap: 0.15rem;
}

.form-row .wide {
  flex: 1 1 100%;
}

input[type="text"],
input[type="number"] {
  padding: 0.35rem 0.5rem;
  border-radius: 0.375rem;
  border: 1px solid #d1d5db;
  font-size: 0.875rem;
  min-width: 0;
}

.checkbox-inline {
  flex-direction: row;
  align-items: center;
  gap: 0.3rem;
}

.env-panel {
  margin-top: 0.5rem;
}

.env-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.25rem;
  table-layout: fixed;
}

.env-table th,
.env-table td {
  border: 1px solid #e5e7eb;
  padding: 0.25rem 0.35rem;
  font-size: 0.8rem;
}

.env-table th {
  background: #f3f4f6;
  text-align: left;
}

.env-handle-col {
  width: 1.75rem;
  text-align: center;
}

.env-key-col {
  width: 30%;
}

.env-value-col {
  width: 70%;
}

.env-actions-col {
  width: 5.5rem;
}

.env-row {
  background: #ffffff;
}

.env-row.drag-over {
  outline: 2px dashed #2563eb;
}

.env-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  color: #9ca3af;
  cursor: grab;
  font-size: 0.85rem;
}

.env-handle:active {
  cursor: grabbing;
}

.env-handle:hover {
  color: #4b5563;
}

.env-input {
  width: 100%;
  padding: 0.25rem 0.35rem;
  border-radius: 0.25rem;
  border: 1px solid transparent;
  font-size: 0.8rem;
  background: transparent;
}

.env-input:focus {
  outline: none;
  border-color: #2563eb;
  background: #eff6ff;
}

.env-row.invalid .env-input-key {
  border-color: #dc2626;
  background: #fef2f2;
}

.env-buttons {
  display: flex;
  gap: 0.25rem;
}

.env-buttons button {
  padding: 0.1rem 0.25rem;
  font-size: 0.7rem;
}

.env-delete-btn {
  background: #dc2626;
}

.env-delete-btn:hover:not(:disabled) {
  background: #b91c1c;
}

.validation-message {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: #b91c1c;
}

.preview-panel {
  padding: 0 1.5rem 1rem;
}

.preview-output {
  max-height: 260px;
  overflow: auto;
  background: #020617;
  color: #e5e7eb;
  padding: 0.75rem;
  border-radius: 0.5rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: 0.75rem;
}

details > summary {
  cursor: pointer;
  font-size: 0.85rem;
}

@media (max-width: 840px) {
  .app-main {
    grid-template-columns: minmax(0, 1fr);
  }
}

