:root {
  --bg: #f4f1ec;
  --surface: #ffffff;
  --surface-muted: #faf8f5;
  --border: #e2ddd4;
  --border-focus: #c4a882;
  --text: #1c1917;
  --text-muted: #6b6560;
  --accent: #b45309;
  --accent-soft: #fef3c7;
  --accent-hover: #92400e;
  --tab-active: #292524;
  --shadow: 0 1px 3px rgba(28, 25, 23, 0.06), 0 8px 24px rgba(28, 25, 23, 0.04);
  --radius: 12px;
  --radius-sm: 8px;
  --font-sans: "DM Sans", system-ui, sans-serif;
  --font-display: "Fraunces", Georgia, serif;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(180, 83, 9, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(180, 83, 9, 0.05), transparent);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 20px 48px;
}

/* Header */
.header {
  padding: 40px 0 28px;
  text-align: center;
  position: relative;
}

.sync-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.sync-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sync-detail {
  margin: 0;
  max-width: 640px;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--text-muted);
  text-align: center;
}

.sync-detail.warn {
  color: #b45309;
}

.sync-detail.ok {
  color: #16a34a;
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #a8a29e;
  flex-shrink: 0;
}

.sync-dot.synced { background: #16a34a; }
.sync-dot.syncing { background: #b45309; animation: pulse 1s infinite; }
.sync-dot.error { background: #dc2626; }
.sync-dot.offline { background: #a8a29e; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.sync-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.logo {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.tagline {
  margin: 8px 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 28px;
}

.tab {
  flex: 1;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab:hover {
  color: var(--text);
  background: var(--surface-muted);
}

.tab.active {
  background: var(--tab-active);
  color: #fff;
}

/* Panels */
.panel {
  display: none;
}

.panel.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.panel-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
}

.period-picker {
  display: flex;
  align-items: center;
  gap: 6px;
}

.period-label input,
.period-label select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
}

.period-label input:focus,
.period-label select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(196, 168, 130, 0.25);
}

.btn-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 1rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.btn-icon:hover {
  border-color: var(--border-focus);
  color: var(--text);
}

/* Cards & forms */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.form-card + .form-card {
  margin-top: 20px;
}

.field-group {
  border: none;
  margin: 0 0 24px;
  padding: 0;
}

.field-group legend {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 10px;
  padding: 0;
}

.field-hint {
  margin: 0 0 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

input[type="text"],
textarea,
select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface-muted);
  transition: border-color 0.15s, box-shadow 0.15s;
  resize: vertical;
}

input[type="text"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(196, 168, 130, 0.25);
  background: var(--surface);
}

input[type="text"]::placeholder,
textarea::placeholder {
  color: #a8a29e;
}

/* Subtasks */
.subtask-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.subtask {
  display: flex;
  align-items: center;
  gap: 12px;
}

.subtask-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
}

/* Reflection grid */
.reflection-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

/* Plan */
.plan-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.plan-item {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
}

.plan-item-header {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.plan-item-header input {
  flex: 1;
  font-weight: 600;
  background: var(--surface);
}

.weekly-plans {
  margin-top: 20px;
}

.plan-progress-card .plan-progress-block {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.plan-progress-card .plan-progress-block:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.plan-progress-card .plan-progress-block:first-of-type {
  padding-top: 0;
}

.plan-progress-title {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent-hover);
}

.plan-progress-desc {
  margin: 0 0 12px;
  font-size: 0.9rem;
  color: var(--text-muted);
  white-space: pre-wrap;
}

/* Monthly */
.monthly-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.section-header-row h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
}

.btn-secondary {
  padding: 8px 14px;
  border: 1px dashed var(--border-focus);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-secondary:hover {
  background: #fde68a;
  border-color: var(--accent);
}

.monthly-sections {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.monthly-section {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
}

.monthly-section-header {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.monthly-section-header input {
  flex: 1;
  font-weight: 600;
  background: var(--surface);
}

.btn-remove {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.btn-remove:hover {
  color: #b91c1c;
  background: #fef2f2;
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.task-row input {
  flex: 1;
  background: var(--surface);
}

.btn-add-task {
  margin-top: 8px;
  padding: 6px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s;
}

.btn-add-task:hover {
  color: var(--accent);
}

.accomplished-card h3 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
}

/* Yearly */
.notes-card textarea {
  min-height: 400px;
  line-height: 1.65;
}

/* Footer */
.footer {
  margin-top: 32px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.save-status {
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: color 0.2s;
}

.save-status.saving {
  color: var(--accent);
}

.save-status.saved {
  color: #16a34a;
}
