* {
  box-sizing: border-box;
}

:root {
  --font-sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --page-bg: #141414;
  --panel-bg: #1b1b1b;
  --card-bg: #1f1f1f;
  --text: #f2f2f2;
  --muted: #b0b0b0;
  --border: #2f2f2f;
  --ring: #5a5a5a;
  --button-bg: #f2f2f2;
  --button-text: #111111;
  --warn-bg: rgba(234, 179, 8, 0.1);
  --warn-border: rgba(234, 179, 8, 0.45);
  --warn-text: #fef9c3;
  --accent-bg: rgba(245, 158, 11, 0.16);
  --accent-text: #fcd34d;
  --success-color: rgb(134, 239, 172);
  --success-border: rgba(134, 239, 172, 0.3);
  --error-color: rgb(252, 165, 165);
  --error-border: rgba(252, 165, 165, 0.3);
  --info-color: rgb(147, 197, 253);
  --info-border: rgba(147, 197, 253, 0.3);
  --toast-bg: rgb(31, 31, 31);
  --toast-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

html[data-theme="light"] {
  --page-bg: #f8f8f8;
  --panel-bg: #ffffff;
  --card-bg: #ffffff;
  --text: #161616;
  --muted: #5b5b5b;
  --border: #e8e8e8;
  --ring: #c7c7c7;
  --button-bg: #171717;
  --button-text: #f2f2f2;
  --warn-bg: rgba(234, 179, 8, 0.12);
  --warn-text: #78350f;
  --accent-bg: rgba(245, 158, 11, 0.2);
  --accent-text: #92400e;
  --success-color: rgb(21, 128, 61);
  --success-border: rgba(21, 128, 61, 0.3);
  --error-color: rgb(185, 28, 28);
  --error-border: rgba(185, 28, 28, 0.3);
  --info-color: rgb(37, 99, 235);
  --info-border: rgba(37, 99, 235, 0.3);
  --toast-bg: rgb(255, 255, 255);
  --toast-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page-bg);
  color: var(--text);
  font-family: var(--font-sans);
}

.page {
  min-height: 100vh;
  margin: 0;
  padding: 2rem 0.85rem;
  position: relative;
}

.theme-button-container {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 2;
}

.theme-button {
  border: 1px solid var(--border);
  background: var(--panel-bg);
  color: var(--text);
  border-radius: 999px;
  width: 2.5rem;
  height: 2.5rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.shell {
  width: min(860px, 100%);
  margin: 0 auto;
}

.header {
  text-align: center;
  margin-bottom: 1.05rem;
}

.title {
  margin: 0;
  font-size: 2rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  display: inline-block;
  position: relative;
  padding-right: 0;
}

.title-text {
  display: inline-block;
  text-align: center;
}

.badge {
  display: inline-block;
  position: absolute;
  top: 50%;
  left: 100%;
  margin-left: 0.55rem;
  padding: 0.12rem 0.5rem;
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  border-radius: 4px;
  background: var(--accent-bg);
  color: var(--accent-text);
  border: 1px solid var(--warn-border);
  transform: translateY(-50%) rotate(-5deg);
}

.subtitle {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.alert-box {
  margin-bottom: 1rem;
  border-radius: 10px;
  border: 1px solid var(--warn-border);
  background: var(--warn-bg);
  color: var(--warn-text);
  padding: 1rem 1.1rem;
}

.alert-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.alert-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.alert-list {
  margin: 0;
  padding-left: 1rem;
  display: grid;
  gap: 0.25rem;
  font-size: 0.86rem;
}

.alert-item {
  line-height: 1.45;
}

.form {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 0.85rem;
}

.label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
}

.textarea {
  width: 100%;
  min-height: 120px;
  resize: none;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font-sans);
  padding: 0.75rem;
  outline-color: var(--ring);
}

.form-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  min-height: 1.6rem;
  margin-top: 0.35rem;
}

.generate-button {
  border: 0;
  border-radius: 8px;
  background: var(--button-bg);
  color: var(--button-text);
  padding: 0.65rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
}

.generate-button:disabled,
.copy-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.feedback-button:disabled,
#feedback-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.error-message {
  margin: 0 0 0.75rem;
  color: var(--error-color);
  font-weight: 600;
  font-size: 0.9rem;
  text-align: center;
}

.results-section {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  transition: opacity 0.2s ease-in-out;
}

.feedback-and-rating-wrapper {
  display: flex;
  justify-content: center;
  margin: 0.5rem 0 0.35rem 0;
  padding: 0;
}

.rating-actions-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.rating-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}

.rating-button {
  border: none;
  background: transparent;
  color: var(--muted);
  width: 2.9rem;
  height: 2.9rem;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: color 0.2s ease, filter 0.2s ease;
  filter: grayscale(0%);
}

.rating-button .icon svg {
  width: 1.55rem;
  height: 1.55rem;
}

.rating-button:hover:not(:disabled) {
  color: var(--text);
  filter: drop-shadow(0 0 6px rgba(242, 242, 242, 0.2));
}

.rating-button.rating-up.active-up {
  color: #4ade80;
  filter: drop-shadow(0 0 8px rgba(74, 222, 128, 0.3));
}

.rating-button.rating-down.active-down {
  color: #f87171;
  filter: drop-shadow(0 0 8px rgba(248, 113, 113, 0.3));
}

.rating-button:active:not(:disabled) {
  filter: drop-shadow(0 0 10px rgba(242, 242, 242, 0.3));
}

.feedback-section {
  margin-top: 0.5rem;
}

.feedback-form {
  display: grid;
  gap: 1rem;
}

.feedback-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.feedback-form-panel {
  display: block;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  padding: 1rem;
}

.feedback-textarea {
  width: 100%;
  min-height: 70px;
  resize: none;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 0.85rem;
  font-family: var(--font-sans);
  padding: 0.6rem;
  outline-color: var(--ring);
}

.feedback-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
  align-items: flex-end;
}

.feedback-input {
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 0.85rem;
  font-family: var(--font-sans);
  padding: 0.5rem 0.6rem;
  outline-color: var(--ring);
}

.feedback-submit-btn {
  border: 0;
  border-radius: 6px;
  background: var(--button-bg);
  color: var(--button-text);
  padding: 0.5rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
  white-space: nowrap;
  transition: opacity 0.2s ease;
}

.feedback-submit-btn:hover:not(:disabled) {
  opacity: 0.85;
}

.feedback-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.feedback-section-centered {
  display: flex;
  justify-content: center;
  margin-top: 0.35rem;
  width: 100%;
}

.feedback-section-centered .feedback-form-panel {
  width: 100%;
  max-width: 450px;
}


.block-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.block-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.block-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.block-title {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
}

.result-card {
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  padding: 0.75rem 0.85rem;
}

.copy-button {
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  width: 1.75rem;
  height: 1.75rem;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
}



.card-body {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.card-body-mono {
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.45;
}

.card-body-text {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  line-height: 1.5;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  background: var(--toast-bg);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  font-size: 0.84rem;
  font-weight: 600;
  box-shadow: var(--toast-shadow);
  z-index: 50;
  font-family: var(--font-sans);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: slideIn 0.3s ease-out;
}

.toast.success {
  color: var(--success-color);
  border: 1px solid var(--success-border);
}

.toast.error {
  color: var(--error-color);
  border: 1px solid var(--error-border);
}

.toast.info {
  color: var(--info-color);
  border: 1px solid var(--info-border);
}

.toast-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon svg {
  display: block;
}

.is-hidden {
  display: none;
}

@keyframes slideIn {
  from {
    transform: translateY(10px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 600px) {
  .page {
    padding: 1.1rem 0.65rem;
  }

  .theme-button-container {
    position: static;
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.5rem;
  }

  .title {
    font-size: 1.5rem;
  }

  .badge {
    position: static;
    transform: none;
    margin-left: 0.4rem;
    vertical-align: middle;
  }
}

textarea::placeholder {
  color: var(--muted);
}

textarea:focus,
button:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
