:root {
  --bg: #f4f7ff;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-strong: #ffffff;
  --primary: #4f46e5;
  --primary-dark: #312e81;
  --text: #1f2937;
  --muted: #6b7280;
  --border: rgba(79, 70, 229, 0.12);
  --success: #10b981;
  --danger: #ef4444;
  --shadow: 0 18px 45px rgba(79, 70, 229, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: linear-gradient(135deg, #eef2ff, #f9fafb);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 420px);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--border);
  border-radius: 26px;
  box-shadow: var(--shadow);
  padding: 28px 24px;
}

.login-header {
  margin-bottom: 24px;
}

.eyebrow,
.label {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 2.6rem);
}

.login-form {
  display: grid;
  gap: 18px;
}

.login-form label {
  display: grid;
  gap: 8px;
  font-weight: 600;
  color: var(--text);
}

.login-form input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  padding: 14px 16px;
  color: var(--text);
}

.login-form input:focus,
textarea:focus {
  outline: 2px solid rgba(79, 70, 229, 0.18);
  border-color: var(--primary);
}

.login-form button,
#saveNoteBtn,
.ghost-btn,
.calendar-header button {
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  font-weight: 700;
  transition: transform 0.15s ease;
}

.login-form button,
#saveNoteBtn {
  padding: 14px 18px;
}

.ghost-btn {
  padding: 10px 16px;
  background: rgba(79, 70, 229, 0.08);
  color: var(--primary-dark);
}

.login-form button:hover,
#saveNoteBtn:hover,
.ghost-btn:hover,
.calendar-header button:hover {
  transform: translateY(-1px);
}

.login-error {
  min-height: 20px;
  color: var(--danger);
  font-size: 0.92rem;
}

.text-btn {
  margin-top: 18px;
  border: 0;
  background: transparent;
  color: var(--primary-dark);
  padding: 8px 0;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.setup-form {
  display: grid;
  gap: 14px;
  margin-top: 14px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.setup-form h2,
.credential-results h3 {
  font-size: 1.1rem;
}

.setup-form label {
  display: grid;
  gap: 8px;
  font-weight: 600;
}

.setup-form input,
.setup-form textarea,
.login-form input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  padding: 12px 14px;
  color: var(--text);
}

.setup-form button[type="submit"] {
  border: 0;
  border-radius: 10px;
  background: var(--primary-dark);
  color: white;
  padding: 13px 16px;
  font-weight: 700;
}

.credential-results {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f5f8f7;
}

.credential-results p {
  color: var(--muted);
  line-height: 1.5;
}

.credential-results pre {
  overflow-x: auto;
  margin: 0;
  padding: 12px;
  border-radius: 6px;
  background: #ffffff;
  font: 0.82rem/1.6 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre;
}

.app-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 32px 18px 60px;
}

.hidden {
  display: none !important;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.content {
  display: grid;
  gap: 22px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.hero,
.calendar-header,
.entry-header,
.entry-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.save-status {
  min-height: 20px;
  margin-top: 12px;
  color: var(--success);
  font-weight: 600;
}

.saved-notes-box {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.saved-notes-box h4 {
  margin-bottom: 10px;
  font-size: 1rem;
}

.note-list {
  list-style: disc;
  margin: 0;
  padding-left: 20px;
  color: var(--text);
  display: grid;
  gap: 8px;
}

.note-list li {
  line-height: 1.5;
  word-break: break-word;
}

.note-list .empty-note {
  list-style: none;
  padding-left: 0;
  color: var(--muted);
}

.hero {
  padding: 22px 24px;
}

.mini-badge {
  background: rgba(79, 70, 229, 0.06);
  border-radius: 999px;
  padding: 10px 16px;
  color: var(--primary-dark);
  font-weight: 700;
}

.calendar-panel,
.form-panel {
  padding: 22px 20px;
}

.calendar-header {
  margin-bottom: 18px;
}

.calendar-header button {
  width: 42px;
  height: 42px;
  font-size: 1.6rem;
}

.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  margin-bottom: 12px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.8rem;
  text-align: center;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.calendar-day {
  min-height: 68px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.55);
  border-radius: 14px;
  color: var(--text);
  padding: 8px 6px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.calendar-day.empty {
  background: transparent;
  border: 1px dashed transparent;
}

.calendar-day.past {
  opacity: 0.45;
  filter: grayscale(0.2);
}

.calendar-day.selected {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border-color: transparent;
  box-shadow: 0 8px 18px rgba(79, 70, 229, 0.2);
}

.calendar-day.today {
  border-color: rgba(79, 70, 229, 0.35);
}

textarea:disabled,
#saveNoteBtn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.entry-header {
  margin-bottom: 14px;
}

.entry-header p {
  color: var(--muted);
  font-size: 0.9rem;
}

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

.entry-actions {
  justify-content: flex-end;
  margin-top: 12px;
}

@media (max-width: 640px) {
  .topbar,
  .hero,
  .entry-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .calendar-day {
    min-height: 56px;
  }
}
