@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,600;8..60,700&family=Figtree:wght@400;500;600;700&display=swap');

:root {
  --bg: #f7f5ee;
  --bg-panel: #ffffff;
  --bg-input: #ffffff;
  --border: rgba(26, 36, 56, 0.12);
  --border-soft: rgba(26, 36, 56, 0.08);
  --text: #1a2438;
  --text-body: #3d4654;
  --text-dim: #5c6470;
  --text-faint: #8a94a6;
  --primary: #1e3a6e;
  --primary-hover: #16305e;
  --accent: #b78233;
  --accent-hover: #9a6b25;
  --success: #1e6e46;
  --danger: #ce181e;
  --radius: 14px;
  --shadow: 0 2px 14px rgba(26, 36, 56, 0.06);
}

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

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

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

h1, h2, h3 { font-family: 'Source Serif 4', Georgia, serif; color: var(--text); }

/* ---------- Login ---------- */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.login-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}
.login-card h1 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 6px;
}
.login-card p { color: var(--text-dim); margin-bottom: 24px; font-size: 14px; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px;
  background: var(--bg);
  border-right: 1px solid var(--border-soft);
  padding: 28px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .brand {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.sidebar .brand span { color: var(--accent); }
.sidebar .subtitle { color: var(--text-faint); font-size: 12px; margin-bottom: 26px; letter-spacing: 0.04em; }

.nav-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 11px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
  transition: all .15s;
}
.nav-item:hover { background: rgba(26, 36, 56, 0.05); color: var(--text); }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }

.logout-btn {
  margin-top: 24px;
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 10px;
  border-radius: 22px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
}
.logout-btn:hover { border-color: var(--danger); color: var(--danger); }

.main {
  flex: 1;
  padding: 36px 44px;
  max-width: 920px;
}
.main h2 { font-size: 27px; font-weight: 700; margin-bottom: 4px; }
.main .section-desc { color: var(--text-dim); margin-bottom: 28px; font-size: 14px; }

/* ---------- Fields ---------- */
.field { margin-bottom: 24px; }
.field label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.field .help { color: var(--text-faint); font-size: 12.5px; margin-bottom: 8px; }

.field input[type="text"],
.field input[type="password"],
.field input[type="number"],
.field input[type="url"],
.field textarea,
.field select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 11px 14px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.field select { cursor: pointer; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 110, 0.12);
}

.field textarea { resize: vertical; min-height: 120px; line-height: 1.6; }
.field textarea.prompt { min-height: 220px; font-family: 'SF Mono', Menlo, Consolas, monospace; font-size: 13px; }

.field-row { display: flex; gap: 12px; align-items: center; }
.field-row input[type="color"] {
  width: 52px; height: 42px; padding: 2px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer;
}

.toggle-secret {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 18px;
  padding: 8px 14px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  transition: all .15s;
}
.toggle-secret:hover { border-color: var(--primary); color: var(--primary); }
.secret-hint { color: var(--text-faint); font-size: 12px; margin-top: 6px; }

.asset-preview {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.asset-preview img {
  max-height: 64px; max-width: 160px;
  background: var(--bg); border: 1px solid var(--border-soft);
  border-radius: 10px; padding: 6px;
}

/* ---------- Buttons ---------- */
.btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 24px;
  padding: 13px 24px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn:hover { background: var(--primary-hover); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  border: 1.5px solid rgba(30, 58, 110, 0.35);
  color: var(--primary);
}
.btn-secondary:hover { background: rgba(30, 58, 110, 0.06); color: var(--primary); }

.btn-small { padding: 7px 14px; font-size: 12px; }

.save-bar {
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  padding: 20px 0 12px;
  display: flex;
  gap: 14px;
  align-items: center;
}

.field-actions { display: flex; gap: 8px; margin-top: 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--success);
  color: #fff;
  padding: 14px 22px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 6px 24px rgba(26, 36, 56, 0.18);
  opacity: 0;
  transform: translateY(10px);
  transition: all .25s;
  pointer-events: none;
  z-index: 1000;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }

.error-msg { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 16px; }

.hidden { display: none !important; }

@media (max-width: 720px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--border-soft); }
  .main { padding: 24px 20px; }
}
