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

:root {
  --blue: #185FA5;
  --blue-light: #E6F1FB;
  --blue-mid: #378ADD;
  --green: #1D9E75;
  --green-light: #E1F5EE;
  --red: #A32D2D;
  --red-light: #FCEBEB;
  --gray-bg: #F5F5F3;
  --gray-border: rgba(0,0,0,0.12);
  --gray-text: #5F5E5A;
  --text: #1a1a18;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --blue: #85B7EB;
    --blue-light: #042C53;
    --blue-mid: #378ADD;
    --green: #5DCAA5;
    --green-light: #04342C;
    --red: #F09595;
    --red-light: #501313;
    --gray-bg: #1e1e1c;
    --gray-border: rgba(255,255,255,0.1);
    --gray-text: #B4B2A9;
    --text: #E8E6DF;
  }
}

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

/* ── Login ──────────────────────────────────────────── */

#login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem 1rem;
}

.login-card {
  background: white;
  border: 0.5px solid var(--gray-border);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

@media (prefers-color-scheme: dark) {
  .login-card { background: #2a2a28; }
}

.login-card h1 {
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 0.4rem;
}

.login-card p {
  font-size: 13px;
  color: var(--gray-text);
  margin-bottom: 1.5rem;
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 0.75rem 1rem;
  border: 0.5px solid var(--gray-border);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-google:hover { background: var(--gray-bg); }

@media (prefers-color-scheme: dark) {
  .btn-google { background: #3a3a38; color: var(--text); }
  .btn-google:hover { background: #444442; }
}

/* ── App layout ─────────────────────────────────────── */

#app-screen { display: none; }

header {
  background: white;
  border-bottom: 0.5px solid var(--gray-border);
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 10;
}

@media (prefers-color-scheme: dark) {
  header { background: #2a2a28; }
}

.header-title {
  font-size: 15px;
  font-weight: 500;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--gray-text);
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
}

.btn-logout {
  background: none;
  border: 0.5px solid var(--gray-border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--gray-text);
  cursor: pointer;
  transition: background 0.15s;
}

.btn-logout:hover { background: var(--gray-bg); }

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ── Cards ───────────────────────────────────────────── */

.card {
  background: white;
  border: 0.5px solid var(--gray-border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

@media (prefers-color-scheme: dark) {
  .card { background: #2a2a28; }
}

.card-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 1rem;
}

/* ── Form elements ───────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 0.9rem; }

label {
  font-size: 13px;
  color: var(--gray-text);
  font-weight: 500;
}

input[type="text"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 0.5px solid var(--gray-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  background: var(--gray-bg);
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}

@media (prefers-color-scheme: dark) {
  input[type="text"],
  input[type="date"],
  input[type="time"],
  select,
  textarea { background: #1e1e1c; }
}

input:focus, select:focus, textarea:focus {
  border-color: var(--blue-mid);
  box-shadow: 0 0 0 2px rgba(55,138,221,0.15);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

.char-count {
  font-size: 12px;
  color: var(--gray-text);
  text-align: right;
  margin-top: -2px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.field-readonly input {
  background: var(--blue-light);
  color: var(--blue);
  font-weight: 500;
  cursor: default;
}

/* ── Preview box ─────────────────────────────────────── */

.preview-box {
  background: var(--gray-bg);
  border: 0.5px solid var(--gray-border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--gray-text);
  margin-bottom: 0.75rem;
}

.preview-label {
  font-size: 12px;
  color: var(--gray-text);
  margin-bottom: 0.35rem;
  font-weight: 500;
}

/* ── Buttons ─────────────────────────────────────────── */

.btn-save {
  width: 100%;
  padding: 0.7rem;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.btn-save:hover { opacity: 0.88; }
.btn-save:active { transform: scale(0.98); }
.btn-save:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-copy {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 0.5px solid var(--gray-border);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-size: 12px;
  color: var(--gray-text);
  cursor: pointer;
  margin-bottom: 0.75rem;
  transition: background 0.15s;
}

.btn-copy:hover { background: var(--gray-bg); }

/* ── Toast ───────────────────────────────────────────── */

#toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text);
  color: var(--gray-bg);
  padding: 0.6rem 1.25rem;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
  white-space: nowrap;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#toast.success { background: var(--green); color: white; }
#toast.error   { background: var(--red); color: white; }

/* ── Loading ─────────────────────────────────────────── */

#loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.25);
  z-index: 50;
  align-items: center;
  justify-content: center;
}

#loading-overlay.show { display: flex; }

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ── Divider ─────────────────────────────────────────── */

.divider {
  height: 0.5px;
  background: var(--gray-border);
  margin: 1rem 0;
}

/* ── Responsive ──────────────────────────────────────── */

@media (min-width: 600px) {
  main { padding: 1.5rem 1.5rem 3rem; }
  .card { padding: 1.5rem; }
}

.toggle-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-bottom: 0.9rem;
}

.toggle-label {
  font-size: 13px;
  color: var(--gray-text);
  font-weight: 500;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--gray-border);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
  border: 0.5px solid var(--gray-border);
}

.toggle-switch input:checked + .toggle-track {
  background: var(--blue);
}

.toggle-track::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(20px);
}