/* ── Reset & Base ─────────────────────────────────────────────────────────── */

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

:root {
  --bg: #fafaf8;
  --surface: #ffffff;
  --border: #e8e4dc;
  --text: #2c2a26;
  --muted: #7a7670;
  --accent: #5c4a32;
  --accent-light: #f0ebe0;
  --danger: #c0392b;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-hover: 0 4px 16px rgba(0,0,0,0.12);
  --radius: 10px;
  --font-serif: Georgia, 'Times New Roman', serif;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html { font-size: 16px; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Landing ──────────────────────────────────────────────────────────────── */

body.landing {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #fdfcf8 0%, #f0ebe0 100%);
}

.landing-hero {
  text-align: center;
  padding: 2.5rem 2rem;
  max-width: 480px;
}

.landing-hero .brand {
  font-family: var(--font-serif);
  font-size: 3rem;
  color: var(--accent);
  margin-bottom: 0.75rem;
  letter-spacing: -0.5px;
}

.landing-hero .tagline {
  font-size: 1.1rem;
  color: var(--muted);
  margin-bottom: 2rem;
  line-height: 1.6;
}

.btn-google {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s, transform 0.1s;
  text-decoration: none;
}

.btn-google:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
  text-decoration: none;
}

.error-msg {
  margin-top: 1rem;
  color: var(--danger);
  font-size: 0.9rem;
}

/* ── Header ───────────────────────────────────────────────────────────────── */

.site-header {
  background: var(--surface);
  border-bottom: 1.5px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-inner .brand {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  color: var(--accent);
  letter-spacing: -0.3px;
}

.header-inner .brand a {
  color: inherit;
  text-decoration: none;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  object-fit: cover;
}

.user-name {
  font-size: 0.9rem;
  color: var(--text);
}

.logout-link {
  font-size: 0.85rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.75rem;
  transition: background 0.15s;
}

.logout-link:hover {
  background: var(--accent-light);
  text-decoration: none;
}

/* ── Dashboard ────────────────────────────────────────────────────────────── */

.dashboard-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ── Widget Grid ──────────────────────────────────────────────────────────── */

.widget-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

@media (max-width: 600px) {
  .widget-grid { grid-template-columns: 1fr; }
}

.grid-cell {
  min-height: 200px;
  position: relative;
}

/* ── Add Widget Button (empty cell) ──────────────────────────────────────── */

.add-widget-btn {
  width: 100%;
  height: 100%;
  min-height: 200px;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.15s, border-color 0.15s;
  font-family: var(--font-sans);
}

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

.plus-icon {
  font-size: 2rem;
  font-weight: 300;
  line-height: 1;
}

.add-label {
  font-size: 0.85rem;
  font-weight: 500;
}

/* ── Base Widget Card ─────────────────────────────────────────────────────── */

.widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.25rem 1rem;
  box-shadow: var(--shadow);
  position: relative;
  min-height: 200px;
  display: flex;
  flex-direction: column;
}

.widget-delete {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, color 0.1s;
}

.widget-delete:hover {
  background: #fde8e6;
  color: var(--danger);
}

.widget-error {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 1rem 0;
}

/* ── Weather Widget ───────────────────────────────────────────────────────── */

.weather-widget {
  text-align: center;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.weather-icon {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.weather-location {
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.weather-temp {
  font-family: var(--font-serif);
  font-size: 2.8rem;
  font-weight: bold;
  color: var(--text);
  line-height: 1;
  margin-bottom: 0.25rem;
}

.weather-desc {
  font-size: 0.95rem;
  color: var(--text);
  text-transform: capitalize;
  margin-bottom: 0.5rem;
}

.weather-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

/* ── RSS Widget ───────────────────────────────────────────────────────────── */

.rss-widget {
  gap: 0;
}

.rss-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  color: var(--accent);
  margin-bottom: 0.85rem;
  padding-right: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.6rem;
}

.rss-items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex: 1;
}

.rss-items li {
  padding-left: 0.85rem;
  position: relative;
  font-size: 0.9rem;
  line-height: 1.4;
}

.rss-items li::before {
  content: '›';
  position: absolute;
  left: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.4;
}

.rss-items a {
  color: var(--text);
  text-decoration: none;
}

.rss-items a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* ── Modal ────────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44, 42, 38, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  padding: 2rem;
  width: 100%;
  max-width: 440px;
  position: relative;
  transform: translateY(8px);
  transition: transform 0.2s;
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

.modal h2 {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.modal-hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  color: var(--muted);
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s;
}

.modal-close:hover {
  background: var(--accent-light);
}

.hidden { display: none !important; }

/* Type choices */
.type-choices {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.type-choice {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  display: grid;
  grid-template-columns: 2rem 1fr;
  grid-template-rows: auto auto;
  align-items: start;
  gap: 0 0.75rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}

.type-choice:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}

.choice-icon {
  font-size: 1.5rem;
  grid-row: 1 / 3;
  display: flex;
  align-items: center;
}

.choice-label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  grid-column: 2;
  grid-row: 1;
}

.choice-sub {
  font-size: 0.8rem;
  color: var(--muted);
  grid-column: 2;
  grid-row: 2;
}

/* Form inside modal */
.modal form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.3rem;
  margin-top: 1rem;
}

.modal form label:first-of-type { margin-top: 1.25rem; }

.modal form .optional {
  font-weight: 400;
  color: var(--muted);
}

.modal form input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  padding: 0.6rem 0.8rem;
  font-size: 0.95rem;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.15s;
}

.modal form input:focus {
  outline: none;
  border-color: var(--accent);
}

.form-actions {
  margin-top: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.btn-back {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.15s;
}

.btn-back:hover { background: var(--accent-light); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 0.6rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-primary:hover { opacity: 0.88; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
