:root {
  --accent-blue: #10a37f;
  --accent-yellow: #f59e0b;
  --glass: #212121;
  --glass-dark: #171717;
  --border: #424242;
  --text: #ececec;
  --muted: #b4b4b4;
  --bg-fallback: url('https://wallpapers-clan.com/wp-content/uploads/2025/04/charlie-brown-snoopy-stargazing-desktop-wallpaper-preview.jpg');
  --transition: all 0.2s ease-in-out;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: rgba(16, 163, 127, 0.4);
  color: var(--text);
}

html, body {
  width: 100%;
  min-height: 100%;
}

body {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background-color: var(--glass-dark);
  overflow-x: hidden;
  line-height: 1.5;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: linear-gradient(rgba(23, 23, 23, 0.85), rgba(23, 23, 23, 0.92)), var(--bg-fallback);
  background-size: cover;
  background-position: center;
  z-index: -1;
  transform: scale(1);
}

.app-shell {
  width: min(100%, 840px);
  padding: 32px;
  background: rgba(33, 33, 33, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  position: relative;
  overflow: hidden;
}

.app-shell::before {
  content: '';
  position: absolute;
  inset: 0;
  background: transparent;
  pointer-events: none;
  z-index: 0;
}

h1 {
  margin: 0 0 0.75rem 0;
  font-size: clamp(1.75rem, 5vw, 2.25rem);
  font-weight: 600;
  color: transparent;
  background: linear-gradient(135deg, #ffffff 30%, #a3e635 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
  text-align: center;
}

p {
  margin: 0 0 2rem 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
  text-align: center;
}

#chat-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
  z-index: 1;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #2f2f2f;
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 10px 16px;
  transition: var(--transition);
}

.input-wrapper:focus-within {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 1px var(--accent-blue);
}

textarea {
  flex: 1;
  width: 100%;
  border-radius: 0;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 4px 0;
  resize: none;
  font-size: 1rem;
  min-height: 24px;
  max-height: 200px;
  font-family: inherit;
  transition: none;
}

textarea:hover {
  background: transparent;
  border-color: transparent;
}

textarea:focus {
  outline: none;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

textarea::placeholder {
  color: #7d7d7d;
}

button {
  padding: 8px 16px;
  border: none;
  border-radius: 18px;
  background: var(--accent-blue);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
  text-transform: none;
  letter-spacing: normal;
  white-space: nowrap;
  flex-shrink: 0;
}

button:hover:not(:disabled) {
  background: #0d8b6c;
  color: #ffffff;
  transform: none;
  box-shadow: 0 0 12px rgba(16, 163, 127, 0.3);
}

button:disabled {
  opacity: 0.15;
  background: rgba(255, 255, 255, 0.1);
  color: var(--muted);
  cursor: not-allowed;
}

.char-count {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
  opacity: 0.7;
}

.char-count.warning {
  color: var(--accent-yellow);
}

.char-count.danger {
  color: #ef4444;
}

.response-area {
  margin-top: 1.5rem;
  padding: 8px 0;
  border-radius: 0;
  background: transparent;
  border: none;
  min-height: 60px;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  line-height: 1.75;
  word-wrap: break-word;
  color: var(--text);
  position: relative;
  z-index: 1;
}

.response-area.loading {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.response-area.loading::after {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid rgba(16, 163, 127, 0.2);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.response-controls {
  display: flex;
  gap: 8px;
  margin-top: 0.75rem;
  opacity: 0;
  transition: var(--transition);
}

.response-area:not(:empty) ~ .response-controls {
  opacity: 1;
}

.response-btn {
  padding: 6px 12px;
  font-size: 0.75rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  text-transform: none;
  letter-spacing: normal;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.response-btn:hover {
  background: #2f2f2f;
  border-color: #676767;
  color: var(--text);
}

.chat-history {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.history-title {
  font-size: 0.75rem;
  text-transform: none;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.history-item {
  padding: 10px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.875rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item:hover {
  background: #2f2f2f;
  border-color: transparent;
  color: var(--accent-blue);
}

@media (max-width: 768px) {
  .app-shell {
    padding: 20px;
    width: 100%;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }

  h1 {
    font-size: 1.6rem;
  }

  .input-wrapper {
    flex-direction: row;
    align-items: center;
  }

  textarea {
    min-height: 24px;
  }

  button {
    width: auto;
  }
}

@media (max-width: 480px) {
  .app-shell {
    padding: 16px;
    border-radius: 0;
  }

  h1 {
    font-size: 1.35rem;
  }

  p {
    font-size: 0.875rem;
  }
}