/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --border: #e2ddd8;
  --text: #2c2824;
  --text-secondary: #6b6560;
  --accent: #5a4a3a;
  --accent-light: #f0ebe5;
  --accent-hover: #4a3a2a;
  --success: #4a7c59;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.08);
}

html {
  font-size: 16px;
}

body {
  font-family: 'Georgia', 'Times New Roman', serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* Layout */
.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.02em;
}

header p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 0.3rem;
  font-style: italic;
}

/* Mode selector */
.mode-selector {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.mode-btn {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.6rem 1.4rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.mode-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.mode-description {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  font-style: italic;
  min-height: 1.4em;
}

/* Input area */
.input-section {
  margin-bottom: 1.5rem;
}

.input-section textarea {
  width: 100%;
  min-height: 150px;
  padding: 1rem 1.2rem;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.7;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  transition: border-color 0.2s ease;
  box-shadow: var(--shadow);
}

.input-section textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
}

.input-section textarea::placeholder {
  color: #b0a89e;
  font-style: italic;
}

/* Card footer & reveal button */
.card-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}

.reveal-btn {
  font-family: inherit;
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 2rem;
  text-align: center;
}

.reveal-btn:hover:not(:disabled) {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.reveal-btn.revealed {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  cursor: default;
}

/* Submit button */
.submit-row {
  display: flex;
  justify-content: center;
  margin-bottom: 2rem;
}

.submit-btn {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.7rem 2.5rem;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow);
}

.submit-btn:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-lg);
}

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

/* Results */
.results {
  display: none;
}

.results.visible {
  display: block;
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.result-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  position: relative;
}

.result-card .label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.result-card .content {
  font-size: 1rem;
  line-height: 1.8;
  white-space: pre-wrap;
  color: var(--text);
}

.result-card .content.loading {
  color: var(--text-secondary);
  font-style: italic;
}

.copy-btn {
  font-family: inherit;
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.copy-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.copy-btn.copied {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 0.5rem;
  vertical-align: middle;
}

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

/* Error */
.error-msg {
  background: #fdf0f0;
  border: 1px solid #e8c4c4;
  color: #8b3a3a;
  padding: 0.8rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  display: none;
}

.error-msg.visible {
  display: block;
}

/* Responsive */
@media (max-width: 768px) {
  .app {
    padding: 1rem;
  }

  .results-grid {
    grid-template-columns: 1fr;
  }

  .mode-selector {
    flex-wrap: wrap;
  }

  .mode-btn {
    flex: 1;
    min-width: 100px;
    text-align: center;
  }
}