.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.field.grow {
  flex: 1;
  min-height: 0;
}

.field.inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
}

.field span {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 70px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 8px 10px;
  min-height: 36px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  min-height: 36px;
  border: 1px solid transparent;
}

.btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
}

.btn.secondary {
  background: var(--surface-2);
  border-color: var(--border);
}

.btn.ghost {
  color: var(--text-muted);
}

.btn.danger {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.3);
}

.btn.small {
  padding: 4px 10px;
  font-size: 12px;
  min-height: 30px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.app-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 1600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.48);
}

.app-dialog {
  width: min(360px, 100%);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 16px;
  box-shadow: 0 22px 56px rgba(0, 0, 0, 0.42);
}

.app-dialog h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.app-dialog p {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.55;
}

.app-dialog-input {
  width: 100%;
  min-height: 38px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 8px 10px;
}

.download-overlay {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.download-panel {
  width: min(420px, 100%);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 16px;
  box-shadow: 0 22px 56px rgba(0, 0, 0, 0.42);
  pointer-events: auto;
}

.download-panel h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.download-panel p {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.55;
}

.download-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.app-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.file-btn {
  position: relative;
  cursor: pointer;
}

.editor-panel .panel-body {
  display: flex;
  flex-direction: column;
}

.todo-form-body .field textarea {
  min-height: 56px;
  resize: vertical;
}

.todo-core {
  padding: 8px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
}

.section-label {
  margin: 8px 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.todo-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 10px;
  font-size: 12px;
}

.todo-checks label {
  display: flex;
  align-items: center;
  gap: 4px;
}

.todo-group {
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.018);
  overflow: hidden;
}

.todo-group summary {
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  list-style: none;
  cursor: pointer;
}

.todo-group summary::-webkit-details-marker {
  display: none;
}

.todo-group summary::after {
  content: "›";
  margin-left: auto;
  color: var(--text-muted);
  transition: transform 0.16s ease;
}

.todo-group[open] summary {
  border-bottom: 1px solid var(--border);
}

.todo-group[open] summary::after {
  transform: rotate(90deg);
}

.todo-group > .field,
.todo-group > .todo-chip-grid,
.todo-group > .todo-two-col,
.todo-group > .todo-chars-head,
.todo-group > #todoChars,
.todo-group > .section-label {
  margin-left: 8px;
  margin-right: 8px;
}

.todo-group > .todo-chip-grid:first-of-type,
.todo-group > .todo-chars-head:first-of-type,
.todo-group > .field:first-of-type {
  margin-top: 8px;
}

.todo-chip-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

.todo-chip-grid label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 12px;
}

.todo-chip-grid input {
  width: 13px;
  height: 13px;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--primary);
}

.todo-chip-grid span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.todo-chip-grid label:has(input:checked) {
  color: var(--text);
  border-color: rgba(236, 72, 153, 0.45);
  background: rgba(236, 72, 153, 0.11);
}

.todo-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.todo-chars-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 12px;
}

.todo-char-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  padding: 8px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.todo-char-card .field {
  margin-bottom: 0;
}

.todo-char-card .field:has(.todo-char-outline) {
  grid-column: 1 / -1;
}

.todo-char-del {
  grid-column: 1 / -1;
  justify-self: end;
}

.todo-output-summary {
  position: sticky;
  bottom: var(--bottom-obstruction);
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(26, 29, 39, 0.96);
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.5;
}

.todo-output-summary strong {
  color: var(--text);
  font-weight: 700;
}

#apiModelManual {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 8px 10px;
  min-height: 36px;
}

@media (max-width: 1200px) and (min-width: 760px) and (min-aspect-ratio: 4/3) {
  .field {
    gap: 3px;
    margin-bottom: 7px;
  }

  .field span,
  .section-label,
  .todo-chars-head {
    font-size: 11px;
  }

  .field input,
  .field select,
  .field textarea,
  #apiModelManual {
    min-height: 30px;
    padding: 5px 7px;
    font-size: 12px;
    border-radius: 7px;
  }

  .todo-form-body .field textarea {
    min-height: 42px;
  }

  .todo-core {
    padding: 6px;
    margin-bottom: 6px;
  }

  .todo-group {
    margin-bottom: 6px;
  }

  .todo-group summary {
    min-height: 28px;
    padding: 5px 7px;
  }

  .todo-chip-grid {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .todo-chip-grid label {
    min-height: 28px;
    padding: 4px 6px;
    font-size: 11px;
  }

  .todo-char-card {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 6px;
  }

  .todo-output-summary {
    margin-top: 6px;
    padding: 6px 7px;
  }
}
