*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f5f5f7;
  color: #1d1d1f;
  line-height: 1.6;
  min-height: 100vh;
}

#app {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Auth */
#auth-section {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.auth-card {
  background: #fff;
  border-radius: 12px;
  padding: 48px 40px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  width: 100%;
  max-width: 400px;
}

.auth-card h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 4px;
}

.subtitle {
  color: #6e6e73;
  font-size: 15px;
  margin-bottom: 32px;
}

#auth-form input {
  display: block;
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  font-size: 16px;
  margin-bottom: 12px;
  transition: border-color 0.2s;
}

#auth-form input:focus {
  outline: none;
  border-color: #0071e3;
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

.auth-buttons {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.auth-buttons button {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

#login-btn {
  background: #0071e3;
  color: #fff;
  border: none;
}

#login-btn:hover {
  background: #0077ed;
}

.secondary {
  background: #fff;
  color: #0071e3;
  border: 1px solid #0071e3;
}

.secondary:hover {
  background: #f0f7ff;
}

.error {
  color: #ff3b30;
  font-size: 14px;
  margin-top: 12px;
  min-height: 20px;
}

/* Header */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 0 16px;
  border-bottom: 1px solid #e5e5ea;
  margin-bottom: 24px;
}

header h1 {
  font-size: 24px;
  font-weight: 700;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

#user-display {
  color: #6e6e73;
  font-size: 14px;
}

.text-btn {
  background: none;
  border: none;
  color: #0071e3;
  font-size: 14px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.text-btn:hover {
  background: #f0f7ff;
}

/* Writing Area */
#writing-area {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

#text-input {
  width: 100%;
  min-height: 200px;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  padding: 16px;
  font-size: 16px;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  transition: border-color 0.2s;
}

#text-input:focus {
  outline: none;
  border-color: #0071e3;
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

.textarea-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}

#char-count {
  font-size: 13px;
  color: #8e8e93;
}

#char-count.near-limit {
  color: #ff3b30;
  font-weight: 600;
}

#submit-btn {
  background: #0071e3;
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

#submit-btn:hover {
  background: #0077ed;
}

#submit-btn:disabled {
  background: #8e8e93;
  cursor: not-allowed;
}

/* Results */
#results-area {
  margin-top: 24px;
  margin-bottom: 48px;
}

#loading {
  text-align: center;
  padding: 48px 0;
}

#loading p {
  color: #6e6e73;
  margin-top: 16px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e5e5ea;
  border-top-color: #0071e3;
  border-radius: 50%;
  margin: 0 auto;
  animation: spin 0.8s linear infinite;
}

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

.result-card {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  margin-bottom: 16px;
  border-left: 4px solid #0071e3;
}

.result-card h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}

.result-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-top: 16px;
  margin-bottom: 8px;
  color: #6e6e73;
}

.result-text {
  font-size: 16px;
  line-height: 1.7;
  white-space: pre-wrap;
}

#explanations-list {
  list-style: none;
  padding: 0;
}

#explanations-list li {
  padding: 8px 0;
  border-bottom: 1px solid #f2f2f7;
  font-size: 14px;
  color: #3a3a3c;
}

#explanations-list li:last-child {
  border-bottom: none;
}

.rewrite-card {
  border-left-color: #34c759;
}

.rewrite-card:nth-child(2) {
  border-left-color: #af52de;
}

.style-label {
  display: inline-block;
  background: #f2f2f7;
  color: #6e6e73;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Responsive */
@media (max-width: 600px) {
  .auth-card {
    padding: 32px 24px;
  }

  #app {
    padding: 0 16px;
  }

  header h1 {
    font-size: 20px;
  }

  .auth-buttons {
    flex-direction: column;
  }
}
