/* ============================================
   GRAIN DESIGN SYSTEM
   ============================================ */

/* --- TOKENS --- */
:root {
  --bg:              #f7f5f0;
  --bg-subtle:       #f0ede8;
  --bg-hover:        #ebe8e2;
  --bg-white:        #ffffff;
  --border:          rgba(28,43,30,0.12);
  --border-strong:   rgba(28,43,30,0.22);
  --text-primary:    #1c2b1e;
  --text-secondary:  #4a5c4d;
  --text-tertiary:   #7a8c7d;
  --accent:          #3b6d11;
  --accent-mid:      #639922;
  --accent-hover:    #2d5509;
  --accent-subtle:   #eaf3de;
  --danger:          #d85a30;
  --danger-subtle:   #faece7;
  --warning:         #ba7517;
  --warning-subtle:  #faeeda;
  --success:         #3b6d11;
  --success-subtle:  #eaf3de;
  --radius:          4px;
  --radius-sm:       2px;
  --shadow:          0 1px 3px rgba(28,43,30,0.08);
  --font:            'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif:      'DM Serif Display', Georgia, serif;
  --font-mono:       'SF Mono', 'Fira Code', monospace;
}

/* --- GOOGLE FONTS --- */
@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=Inter:wght@400;500&display=swap');

/* --- RESET --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font); background: var(--bg); color: var(--text-primary); line-height: 1.6; min-height: 100vh; overflow-y: scroll; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: var(--font); cursor: pointer; }
input, textarea, select { font-family: var(--font); }

/* --- HEADER --- */
.g-header {
  background: var(--bg);
  border-bottom: 0.5px solid var(--border);
  padding: 0 2rem;
  height: 56px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
}
.g-header-inner {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 2rem;
}
.g-logo {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  text-decoration: none;
  flex-shrink: 0;
}
.g-logo:hover { text-decoration: none; color: var(--text-primary); }
.g-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
}
.g-nav a {
  font-size: 0.82rem;
  color: var(--text-secondary);
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
  font-weight: 400;
}
.g-nav a:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; }
.g-nav a.active { color: var(--text-primary); font-weight: 500; }
.g-nav-divider { width: 0.5px; height: 18px; background: var(--border); margin: 0 0.5rem; }

/* --- LAYOUT --- */
.g-main { max-width: 1100px; margin: 0 auto; padding: 2.5rem 2rem; }
.g-main-narrow { max-width: 760px; margin: 0 auto; padding: 2.5rem 2rem; }
.g-main-wide { max-width: 1100px; margin: 0 auto; padding: 2.5rem 2rem; }

/* --- PAGE HEADER --- */
.g-page-header { margin-bottom: 2rem; }
.g-page-label {
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-mid);
  margin-bottom: 0.4rem;
}
.g-page-title {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: 0;
  line-height: 1.2;
}
.g-page-subtitle {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-top: 0.4rem;
}

/* --- CARDS --- */
.g-card {
  background: var(--bg-white);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
}
.g-card-header {
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  border-bottom: 0.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.g-card-title { font-size: 0.88rem; font-weight: 500; color: var(--text-primary); }
.g-card-subtitle { font-size: 0.78rem; color: var(--text-secondary); margin-top: 0.2rem; }

/* --- SECTION HEADERS --- */
.g-section-label {
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-mid);
  margin-bottom: 0.75rem;
  margin-top: 1.5rem;
}
.g-section-label:first-child { margin-top: 0; }

/* --- BUTTONS --- */
.g-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0 0.9rem;
  height: 34px;
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 0.5px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  letter-spacing: 0.02em;
}
.g-btn:hover { text-decoration: none; }
.g-btn-primary { background: var(--text-primary); color: #fff; border-color: var(--text-primary); }
.g-btn-primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.g-btn-secondary { background: var(--bg-white); color: var(--text-primary); border-color: var(--border-strong); }
.g-btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); }
.g-btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.g-btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.g-btn-ghost { background: transparent; color: var(--text-secondary); border-color: transparent; }
.g-btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.g-btn-danger { background: transparent; color: var(--danger); border-color: rgba(216,90,48,0.3); }
.g-btn-danger:hover { background: var(--danger-subtle); }
.g-btn-lg { height: 42px; padding: 0 1.6rem; font-size: 0.88rem; letter-spacing: 0.06em; text-transform: uppercase; }
.g-btn-sm { height: 28px; padding: 0 0.7rem; font-size: 0.75rem; }
.g-btn-full { width: 100%; }

/* --- FORMS --- */
.g-field { margin-bottom: 1.2rem; }
.g-label { display: block; font-size: 0.8rem; font-weight: 500; color: var(--text-primary); margin-bottom: 0.4rem; }
.g-hint { font-size: 0.75rem; color: var(--text-tertiary); margin-top: 0.3rem; }
.g-input {
  width: 100%;
  padding: 0 0.75rem;
  height: 36px;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: var(--text-primary);
  background: var(--bg-white);
  transition: border-color 0.15s;
}
.g-input:focus { outline: none; border-color: var(--text-primary); }
.g-input::placeholder { color: var(--text-tertiary); }
.g-textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: var(--text-primary);
  background: var(--bg-white);
  resize: vertical;
  transition: border-color 0.15s;
  min-height: 80px;
}
.g-textarea:focus { outline: none; border-color: var(--text-primary); }
.g-textarea::placeholder { color: var(--text-tertiary); }
.g-select {
  width: 100%;
  padding: 0 0.75rem;
  height: 36px;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: var(--text-primary);
  background: var(--bg-white);
  transition: border-color 0.15s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234a5c4d' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}
.g-select:focus { outline: none; border-color: var(--text-primary); }

/* --- TOGGLE --- */
.g-toggle { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.g-toggle input { opacity: 0; width: 0; height: 0; }
.g-toggle-slider { position: absolute; cursor: pointer; inset: 0; background: var(--border-strong); border-radius: 22px; transition: 0.2s; }
.g-toggle-slider:before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: white; border-radius: 50%; transition: 0.2s; }
.g-toggle input:checked + .g-toggle-slider { background: var(--accent); }
.g-toggle input:checked + .g-toggle-slider:before { transform: translateX(18px); }

/* --- STARS --- */
.g-stars { display: flex; flex-direction: row-reverse; justify-content: flex-end; }
.g-stars input { display: none; }
.g-stars label { font-size: 1.2rem; cursor: pointer; color: var(--border-strong); padding: 0 1px; transition: color 0.1s; }
.g-stars label:hover,
.g-stars label:hover ~ label,
.g-stars input:checked ~ label { color: var(--accent); }

/* --- BADGES --- */
.g-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 2px;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.g-badge-green { background: var(--accent-subtle); color: var(--accent); }
.g-badge-red { background: var(--danger-subtle); color: var(--danger); }
.g-badge-yellow { background: var(--warning-subtle); color: var(--warning); }
.g-badge-grey { background: var(--bg-hover); color: var(--text-secondary); }
.g-badge-blue { background: #e6f1fb; color: #185fa5; }

/* --- ALERTS --- */
.g-alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  border: 0.5px solid transparent;
  margin-bottom: 1rem;
}
.g-alert-success { background: var(--accent-subtle); border-color: #c0dd97; color: var(--accent); }
.g-alert-error { background: var(--danger-subtle); border-color: #f0997b; color: #993c1d; }
.g-alert-warning { background: var(--warning-subtle); border-color: #fac775; color: var(--warning); }
.g-alert-info { background: #e6f1fb; border-color: #85b7eb; color: #185fa5; }

/* --- TABLES --- */
.g-table { width: 100%; border-collapse: collapse; }
.g-table th {
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
  padding: 0.6rem 1rem;
  text-align: left;
  border-bottom: 0.5px solid var(--border);
  background: var(--bg-subtle);
}
.g-table td { font-size: 0.85rem; padding: 0.8rem 1rem; border-bottom: 0.5px solid var(--border); color: var(--text-primary); }
.g-table tr:last-child td { border-bottom: none; }
.g-table tr:hover td { background: var(--bg-subtle); }

/* --- DIVIDER --- */
.g-divider { border: none; border-top: 0.5px solid var(--border); margin: 1.5rem 0; }

/* --- LOADING --- */
.g-spinner { width: 18px; height: 18px; border: 1.5px solid var(--border); border-top-color: var(--text-primary); border-radius: 50%; animation: g-spin 0.7s linear infinite; display: inline-block; }
.g-loading { display: flex; flex-direction: column; align-items: center; gap: 0.8rem; padding: 3rem; color: var(--text-tertiary); font-size: 0.85rem; }
@keyframes g-spin { to { transform: rotate(360deg); } }

/* --- EMPTY STATE --- */
.g-empty { text-align: center; padding: 4rem 2rem; color: var(--text-tertiary); }
.g-empty-title { font-size: 0.95rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 0.5rem; }
.g-empty-text { font-size: 0.85rem; margin-bottom: 1.5rem; }

/* --- SETTINGS ROW --- */
.g-setting-row { display: flex; justify-content: space-between; align-items: center; padding: 1rem 0; border-bottom: 0.5px solid var(--border); gap: 2rem; }
.g-setting-row:last-child { border-bottom: none; }
.g-setting-label { font-size: 0.88rem; font-weight: 500; color: var(--text-primary); }
.g-setting-hint { font-size: 0.78rem; color: var(--text-tertiary); margin-top: 0.2rem; }
.g-setting-control { flex-shrink: 0; }
.g-conditional { display: none; }
.g-conditional.visible { display: flex; }

/* --- RESULT SECTIONS --- */
.g-result {
  background: var(--bg-white);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 0.75rem;
}
.g-result-label {
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 0.8rem;
}
.g-result p { font-size: 0.88rem; line-height: 1.75; color: var(--text-secondary); margin-bottom: 0.4rem; }
.g-result ul { list-style: none; padding: 0; }
.g-result ul li { font-size: 0.88rem; line-height: 1.75; color: var(--text-secondary); padding-left: 1.1rem; position: relative; margin-bottom: 0.3rem; }
.g-result ul li::before { content: '—'; position: absolute; left: 0; color: var(--text-tertiary); }
.g-result-overall { border-left: 2px solid #378add; }
.g-result-overall .g-result-label { color: #185fa5; }
.g-result-love { border-left: 2px solid var(--accent); }
.g-result-love .g-result-label { color: var(--accent); }
.g-result-fix { border-left: 2px solid var(--warning); }
.g-result-fix .g-result-label { color: var(--warning); }
.g-result-urgent { border-left: 2px solid var(--danger); }
.g-result-urgent .g-result-label { color: var(--danger); }
.g-result-actions { border-left: 2px solid #7f77dd; }
.g-result-actions .g-result-label { color: #534ab7; }
.g-result-standout { border-left: 2px solid var(--text-primary); }
.g-result-standout .g-result-label { color: var(--text-primary); }

/* --- AUTH PAGE --- */
.g-auth-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--bg);
}
.g-auth-card {
  background: var(--bg-white);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 380px;
}
.g-auth-logo {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 1.8rem;
  display: block;
  text-decoration: none;
}
.g-auth-logo:hover { text-decoration: none; color: var(--text-primary); }
.g-auth-title { font-size: 1rem; font-weight: 500; margin-bottom: 0.3rem; }
.g-auth-subtitle { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 1.5rem; }
.g-auth-switch { text-align: center; font-size: 0.8rem; color: var(--text-tertiary); margin-top: 1.2rem; }
.g-auth-switch a { color: var(--text-secondary); }
.g-auth-switch a:hover { color: var(--text-primary); }

/* --- ONBOARDING --- */
.g-onboard-wrap { min-height: 100vh; background: var(--bg); display: flex; flex-direction: column; }
.g-onboard-header { background: var(--bg); border-bottom: 0.5px solid var(--border); padding: 0 2rem; height: 56px; display: flex; align-items: center; justify-content: space-between; }
.g-progress-bar { height: 2px; background: var(--border); position: relative; overflow: hidden; }
.g-progress-fill { height: 100%; background: var(--accent); transition: width 0.4s ease; }
.g-onboard-body { flex: 1; display: flex; align-items: center; justify-content: center; padding: 3rem 2rem; }
.g-onboard-card { background: var(--bg-white); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 2.5rem; width: 100%; max-width: 520px; }
.g-onboard-step { font-size: 0.72rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent-mid); margin-bottom: 0.5rem; }
.g-onboard-title { font-family: var(--font-serif); font-size: 1.4rem; font-weight: 400; margin-bottom: 0.5rem; line-height: 1.2; }
.g-onboard-subtitle { font-size: 0.88rem; color: var(--text-secondary); margin-bottom: 2rem; line-height: 1.6; }
.g-onboard-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 2rem; padding-top: 1.5rem; border-top: 0.5px solid var(--border); }

/* --- REVIEW BLOCK --- */
.g-review-block { border: 0.5px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; margin-bottom: 0.75rem; background: var(--bg-subtle); }
.g-review-block-header { display: flex; gap: 0.75rem; margin-bottom: 0.75rem; align-items: center; flex-wrap: wrap; }
.g-review-input-name { width: 160px; }
.g-review-input-date { width: 150px; }

/* --- DRAFT CARD --- */
.g-draft-card { border: 0.5px solid var(--border); border-radius: var(--radius-sm); padding: 1.2rem; margin-bottom: 0.75rem; background: var(--bg-white); }
.g-draft-card:last-child { margin-bottom: 0; }
.g-draft-meta { font-size: 0.72rem; color: var(--text-tertiary); font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.3rem; }
.g-draft-stars { color: var(--accent); font-size: 0.85rem; margin-bottom: 0.5rem; }
.g-draft-text { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.65; margin-bottom: 1rem; font-style: italic; border-left: 2px solid var(--border); padding-left: 0.75rem; }
.g-draft-controls { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.g-draft-output { margin-top: 0.75rem; background: var(--bg-subtle); border: 0.5px solid var(--border); border-radius: var(--radius-sm); padding: 0.75rem; display: none; }
.g-draft-output textarea { width: 100%; height: 100px; border: none; background: transparent; font-size: 0.88rem; color: var(--text-primary); resize: vertical; font-family: var(--font); }
.g-draft-output textarea:focus { outline: none; }
.g-generating { font-size: 0.78rem; color: var(--text-tertiary); font-style: italic; display: none; }

/* --- RESPONSIVE --- */
@media (max-width: 640px) {
  .g-main, .g-main-narrow, .g-main-wide { padding: 1.5rem 1rem; }
  .g-header { padding: 0 1rem; }
  .g-nav a span { display: none; }
}

body { overflow-x: hidden; }

.g-full-bleed {
  margin-left: calc(-50vw + 50%);
  margin-right: calc(-50vw + 50%);
  border-radius: 0;
  border-left: none;
  border-right: none;
  padding-left: calc(50vw - 50% + 1.5rem);
  padding-right: calc(50vw - 50% + 1.5rem);
}

.g-full-width {
  width: 100vw;
  position: relative;
  left: 50%;
  transform: translateX(-50%);
}
