body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
    Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI', 'Segoe UI Symbol';
  background-color: #121212;
  color: #e0e0e0;
  margin: 0;
  padding: 2rem;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
}

main {
  width: 100%;
  max-width: 700px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

h1 {
  text-align: center;
  color: #ffffff;
  font-weight: 500;
}

#prompt-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-control {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
}

label {
  font-size: 0.9rem;
  color: #aaa;
}

.form-control textarea,
.form-control select,
#add-instruction-form input[type="text"] {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid #333;
  background-color: #2a2a2a;
  color: #e0e0e0;
  outline: none;
  transition: border-color 0.2s, background-color 0.2s;
  box-sizing: border-box;
  font-family: inherit;
}

.form-control textarea {
    resize: vertical;
}

.form-control textarea:focus,
.form-control select:focus,
#add-instruction-form input[type="text"]:focus {
  border-color: #8a63d2;
}

button {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  border: none;
  border-radius: 8px;
  background-color: #8a63d2;
  color: white;
  cursor: pointer;
  transition: background-color 0.2s;
}

button:hover {
  background-color: #7955b8;
}

button:disabled,
select:disabled,
textarea:disabled {
    background-color: #555;
    cursor: not-allowed;
    opacity: 0.7;
}

.response-wrapper {
  position: relative;
}

#response-container {
  background-color: #1e1e1e;
  border-radius: 8px;
  padding: 1.5rem;
  min-height: 100px;
  line-height: 1.6;
  border: 1px solid #333;
  word-wrap: break-word;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
}

#response-container pre {
  margin: 0;
  white-space: break-spaces;
}

#copy-button {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  padding: 0.5rem;
  border: none;
  border-radius: 6px;
  background-color: #3a3a3a;
  color: #e0e0e0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
  transition: opacity 0.2s, background-color 0.2s;
  z-index: 10;
}

#copy-button:hover {
  background-color: #4a4a4a;
  opacity: 1;
}

.loader {
  width: 48px;
  height: 48px;
  border: 5px solid #FFF;
  border-bottom-color: #8a63d2;
  border-radius: 50%;
  display: block;
  margin: 20px auto;
  box-sizing: border-box;
  animation: rotation 1s linear infinite;
}

@keyframes rotation {
  0% {
      transform: rotate(0deg);
  }
  100% {
      transform: rotate(360deg);
  }
}

.error {
    color: #ff5555;
}

/* Instructions Management Styles */
.instructions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.instructions-buttons {
  display: flex;
  gap: 0.5rem;
}

.instructions-buttons button {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  background-color: #3a3a3a;
  font-weight: 400;
}

.instructions-buttons button:hover {
  background-color: #4a4a4a;
}

.instructions-buttons button:disabled {
  background-color: #2a2a2a;
  opacity: 0.5;
}

#insert-instructions-popup {
    position: absolute;
    top: 40px;
    left: 0;
    width: 100%;
    background-color: #333;
    border: 1px solid #444;
    border-radius: 8px;
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
}

#insert-instructions-popup .popup-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #444;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#insert-instructions-popup .popup-item:last-child {
    border-bottom: none;
}
#insert-instructions-popup .popup-item:hover {
    background-color: #4a4a4a;
}
.popup-item.empty-state {
    padding: 1rem;
    color: #888;
    text-align: center;
    font-style: italic;
    cursor: default;
}

.modal-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-container[hidden] {
  display: none;
}

.modal-content {
  background-color: #2a2a2a;
  padding: 2rem;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  border: 1px solid #444;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 1.5rem;
  color: #aaa;
  cursor: pointer;
  border: none;
  background: none;
  line-height: 1;
  padding: 0;
}

.modal-content h2, .modal-content h3 {
    margin: 0;
    color: #fff;
    font-weight: 500;
}
.modal-content h3 {
    font-size: 1rem;
    color: #ccc;
    border-top: 1px solid #444;
    padding-top: 1.5rem;
    margin-bottom: 0.5rem;
}

#add-instruction-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

#add-instruction-form button {
    align-self: flex-end;
}

#saved-instructions-list {
    max-height: 30vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

#saved-instructions-list .empty-state {
    color: #888;
    font-style: italic;
}

.saved-instruction-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    background-color: #1e1e1e;
    border-radius: 6px;
    border: 1px solid #333;
}

.saved-instruction-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow: hidden;
}

.saved-instruction-item h4 {
    margin: 0;
    font-size: 1rem;
    color: #e0e0e0;
    font-weight: 500;
}

.saved-instruction-item p {
    margin: 0;
    color: #aaa;
    font-size: 0.9rem;
    overflow-wrap: break-word;
    word-break: break-word;
}

.delete-instruction-btn {
    background-color: #602828;
    color: #ffc0c0;
    border: none;
    border-radius: 4px;
    padding: 0.4rem 0.7rem;
    font-size: 0.8rem;
    cursor: pointer;
    flex-shrink: 0;
}

.delete-instruction-btn:hover {
    background-color: #7e3535;
    color: white;
}