/* AI Writing Tools — Core Styles */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #7c3aed;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #526174;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* Layout */
.container { max-width: 900px; margin: 0 auto; padding: 0 24px; }

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  height: 56px;
  position: sticky; top: 0; z-index: 100;
}
.header-inner {
  display: flex; align-items: center;
  max-width: 1280px; margin: 0 auto; padding: 0 24px;
  height: 100%;
  gap: 16px;
}
.header-inner-wide {
  max-width: 1280px;
}
.container-wide {
  max-width: 1200px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}
.logo-mark {
  width: 32px;
  height: 32px;
  background: #eff6ff;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}
.logo-text {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.nav-links {
  display: flex;
  margin-left: 8px;
  flex-wrap: nowrap;
}
.nav-links a {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 600;
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.nav-links a:hover { color: var(--primary); }
.nav-links a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.logo:focus-visible, .nav-links a:focus-visible, .btn:focus-visible, .btn-sm:focus-visible, textarea:focus-visible, input:focus-visible, select:focus-visible, .faq-item summary:focus-visible {
  outline: 3px solid rgba(37,99,235,.22);
  outline-offset: 3px;
}

/* Auth area */
.auth-area {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .875rem;
  margin-left: auto;
}
.btn-sm {
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background .15s, border-color .15s, color .15s;
  background: var(--surface);
  color: var(--text);
  white-space: nowrap;
}
.btn-sm:hover { background: var(--bg); border-color: #cbd5e1; }
.btn-primary-sm { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary-sm:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-ghost-sm { background: var(--surface); color: var(--text); border: 1px solid var(--border); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1rem;
}
.card-soft {
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

/* Hero / Index cards */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin: 2rem 0; }
.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  transition: transform .15s, box-shadow .15s;
  display: block;
}
.tool-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.1); }
.tool-card .icon { font-size: 2.5rem; margin-bottom: .5rem; }
.tool-card h3 { font-size: 1rem; font-weight: 600; }
.tool-card p { font-size: .8rem; color: var(--text-muted); margin-top: .3rem; }

/* Form elements */
label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .35rem; color: var(--text); }
textarea, input[type="text"], input[type="email"], select {
  width: 100%; padding: .6rem .85rem;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: .9rem; font-family: inherit;
  background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
textarea:focus, input:focus, select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
textarea { resize: vertical; min-height: 140px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-group { margin-bottom: 1rem; }
.field-help {
  font-size: .84rem;
  color: var(--text-muted);
  margin-top: .42rem;
}
.muted-note {
  font-weight: 400;
  color: #71839a;
}
.form-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .9rem 1rem;
}
.privacy-note {
  font-size: .86rem;
  color: var(--text-muted);
  margin: 0;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .6rem 1.25rem; border: none; border-radius: 8px;
  font-size: .9rem; font-weight: 500; cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.btn:hover { opacity: .88; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }

.btn-group { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; }

/* Result section */
.result-section { margin-top: 1.25rem; }
.result-box {
  background: #f0f7ff; border: 1px solid #bfdbfe;
  border-radius: 8px; padding: 1rem; white-space: pre-wrap;
  font-size: .9rem; line-height: 1.7; min-height: 80px;
}
.result-box.grammar { background: #f0fdf4; border-color: #bbf7d0; }
.key-points { list-style: disc; padding-left: 1.25rem; font-size: .9rem; line-height: 1.8; }
.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: .85rem;
}
.result-meta-chip {
  display: inline-flex;
  align-items: center;
  padding: .3rem .55rem;
  border-radius: 999px;
  border: 1px solid #dbe4f0;
  background: #f8fafc;
  color: #334155;
  font-size: .8rem;
  font-weight: 500;
}

/* Issues list */
.issue-item {
  border: 1px solid var(--border); border-radius: 8px;
  padding: .75rem 1rem; margin-bottom: .5rem; background: var(--surface);
}
.issue-row {
  margin-top: .45rem;
}
.issue-label {
  font-size: .74rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .2rem;
}
.issue-old {
  color: var(--danger);
  text-decoration: line-through;
  font-size: .92rem;
}
.issue-new {
  color: var(--text);
  font-weight: 700;
  font-size: .95rem;
}
.issue-explainer {
  font-size: .87rem;
  color: var(--text-muted);
  margin-top: .45rem;
  line-height: 1.7;
}
.grammar-success-note {
  color: var(--success);
  font-size: .92rem;
  font-weight: 600;
}
.issue-category {
  display: inline-block; font-size: .7rem; font-weight: 600;
  padding: .1rem .45rem; border-radius: 4px; text-transform: uppercase;
  letter-spacing: .04em; margin-bottom: .3rem;
}
.cat-grammar { background: #fee2e2; color: #991b1b; }
.cat-spelling { background: #fef3c7; color: #92400e; }
.cat-punctuation { background: #e0e7ff; color: #3730a3; }
.cat-clarity { background: #d1fae5; color: #065f46; }
.cat-tone { background: #fce7f3; color: #9d174d; }

/* Feedback */
.feedback-row { display: flex; gap: .5rem; align-items: center; margin-top: .75rem; font-size: .8rem; color: var(--text-muted); }
.feedback-row .btn-outline { padding: .25rem .7rem; font-size: .8rem; }
.feedback-row .btn-outline.active { border-color: var(--primary); color: var(--primary); background: #eff6ff; }

/* Quota bar */
.quota-bar { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: .6rem 1rem; font-size: .8rem; color: var(--text-muted); display: flex; gap: 1rem; flex-wrap: wrap; }
.quota-bar strong { color: var(--text); }

/* Alerts */
.alert { padding: .75rem 1rem; border-radius: 8px; font-size: .875rem; margin-bottom: .75rem; }
.alert-info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }

/* Modal (unified) */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--surface); border-radius: 12px;
  width: 90%; max-width: 450px;
  box-shadow: 0 20px 40px rgba(0,0,0,.2);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 20px; font-weight: 600; color: var(--text); margin: 0; }
.modal-close {
  background: none; border: none; font-size: 28px; color: #6b7280;
  cursor: pointer; padding: 0; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; transition: all .2s;
}
.modal-close:hover { color: var(--text); background: var(--bg); }
.modal-body { padding: 24px; }
.auth-step { display: flex; flex-direction: column; gap: 16px; }
.auth-step.hidden { display: none; }
.auth-step > p { color: var(--text-muted); font-size: 14px; margin: 0; }
.input-field {
  width: 100%; padding: 12px 16px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 16px; font-family: inherit;
  transition: border-color .2s;
}
.input-field:focus { outline: none; border-color: var(--primary); }
.checkbox-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; color: var(--text-muted); cursor: pointer;
}
.checkbox-label input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }
.btn-link {
  background: none; border: none; color: var(--primary);
  text-decoration: underline; cursor: pointer; padding: 8px; font-size: 14px;
}
.btn-link:hover { color: var(--primary-dark); }

/* Spinner */
.spinner {
  display: inline-block; width: 1rem; height: 1rem;
  border: 2px solid #fff; border-top-color: transparent;
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Section headings */
h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: .25rem; }
h2 { font-size: 1.2rem; font-weight: 600; margin-bottom: .5rem; }
.subtitle { color: var(--text-muted); font-size: .9rem; margin-bottom: 1.5rem; }

/* Summarizer page */
.page-intro {
  margin-bottom: 1rem;
}
.intro-grid {
  display: grid;
  grid-template-columns: 1.45fr .95fr;
  gap: 1.2rem;
  align-items: start;
}
.intro-copy {
  color: var(--text-muted);
  font-size: .95rem;
  line-height: 1.8;
  margin-top: .4rem;
}
.trust-list-wrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}
.trust-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.trust-list li {
  position: relative;
  padding-left: 1rem;
  color: var(--text-muted);
  font-size: .88rem;
}
.trust-list li::before {
  content: "";
  width: .38rem;
  height: .38rem;
  border-radius: 50%;
  background: var(--primary);
  position: absolute;
  left: 0;
  top: .48rem;
}
.examples-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .55rem;
  margin-bottom: 1rem;
}
.examples-label {
  font-size: .86rem;
  font-weight: 600;
  color: var(--text-muted);
}
.example-chip {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: .4rem .75rem;
  font: inherit;
  font-size: .83rem;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.example-chip:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: var(--primary);
}
.next-step-panel {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.next-step-copy {
  font-size: .9rem;
  color: var(--text-muted);
  margin: 0 0 .8rem;
}
.seo-section p {
  color: var(--text-muted);
  font-size: .92rem;
  line-height: 1.8;
}
.result-explanation {
  font-size: .92rem;
  color: #475569;
  margin-top: .75rem;
  line-height: 1.7;
}
.faq-list {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.faq-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 .95rem;
  background: var(--surface);
}
.faq-item summary {
  list-style: none;
  cursor: pointer;
  font-size: .92rem;
  font-weight: 600;
  padding: .95rem 0;
}
.faq-item summary::-webkit-details-marker {
  display: none;
}
.faq-item p {
  padding: 0 0 .95rem;
  margin: 0;
}

/* History items */
.history-item {
  border: 1px solid var(--border); border-radius: 8px;
  padding: .85rem 1rem; margin-bottom: .5rem; background: var(--surface);
}
.history-item .meta { font-size: .75rem; color: var(--text-muted); margin-bottom: .3rem; }
.history-item .preview { font-size: .85rem; color: var(--text); white-space: pre-wrap; max-height: 80px; overflow: hidden; }

/* Char counter */
.char-count { font-size: .75rem; color: var(--text-muted); text-align: right; margin-top: .2rem; }
.char-count.warn { color: var(--warning); }
.char-count.error { color: var(--danger); }

/* Responsive */
@media (max-width: 600px) {
  .form-row { grid-template-columns: 1fr; }
  .tool-grid { grid-template-columns: 1fr 1fr; }
  .container { padding: 0 12px; }
  .header-inner { padding: 0 12px; gap: 10px; }
  .nav-links { overflow-x: auto; }
  .intro-grid { grid-template-columns: 1fr; }
  .form-footer { align-items: flex-start; }
  .feedback-row { flex-wrap: wrap; }
}
