:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-hover: #f8fafc;
  --surface-selected: #eff6ff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --routine-bg: #ede9fe;
  --routine-text: #6d28d9;
  --radius: 10px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* 2초 자동 소멸 토스트 알림 */
.toast-container {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #1e293b;
  color: #ffffff;
  padding: 11px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: #dc2626;
}

.toast.success {
  background: #0f172a;
}

/* 버튼 공통 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 0.82rem;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-outline {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}

.btn-outline:hover {
  background: var(--surface-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--border);
  color: var(--text);
}

.btn-danger {
  background: #fef2f2;
  color: var(--danger);
  border-color: #fecaca;
}

.btn-danger:hover {
  background: #fee2e2;
}

.btn-icon {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  font-weight: 700;
}

/* 인증 화면 */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 410px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 30px 28px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}

.brand-header {
  text-align: center;
  margin-bottom: 22px;
}

.brand-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary);
  background: #dbeafe;
  padding: 3px 9px;
  border-radius: 99px;
  margin-bottom: 8px;
}

.brand-header h1 {
  font-size: 1.4rem;
  margin-bottom: 5px;
}

.subtitle {
  font-size: 0.86rem;
  color: var(--text-muted);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 8px;
  margin-bottom: 18px;
}

.auth-tab {
  border: none;
  background: transparent;
  padding: 8px;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
}

.auth-tab.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

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

.field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
}

.field input,
.field textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.92rem;
  font-family: inherit;
}

.field input:focus,
.field textarea:focus {
  outline: 2px solid #bfdbfe;
  border-color: var(--primary);
}

.divider {
  margin: 18px 0;
  text-align: center;
  position: relative;
}

.divider::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  border-top: 1px solid var(--border);
}

.divider span {
  position: relative;
  background: #fff;
  padding: 0 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-google {
  background: #fff;
  border: 1px solid var(--border);
  color: #1e293b;
}

.btn-google:hover {
  background: #f8fafc;
}

/* 메인 앱 레이아웃 */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.top-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 11px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.nav-left,
.nav-right,
.month-selector {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
}

.app-title {
  font-size: 1.05rem;
  margin-right: 8px;
}

#current-month-input {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.92rem;
}

.user-badge {
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
  background: #f1f5f9;
  padding: 5px 10px;
  border-radius: 6px;
}

/* 빠른 자연어 입력 바 */
.quick-add-bar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 12px 22px;
}

.quick-add-form {
  display: flex;
  gap: 10px;
  max-width: 1400px;
}

.natural-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.95rem;
}

.natural-input:focus {
  outline: 2px solid #bfdbfe;
  border-color: var(--primary);
}

.date-override-input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* 매월 고정 일정 드로어 */
.routine-drawer {
  background: #f8fafc;
  border-bottom: 2px solid #cbd5e1;
  padding: 16px 22px;
}

.routine-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  gap: 12px;
}

.routine-drawer-header h2 {
  font-size: 1rem;
  margin-bottom: 3px;
}

.routine-drawer-header p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.routine-add-form {
  display: grid;
  grid-template-columns: 220px 1fr 1fr auto;
  gap: 8px;
  margin-bottom: 12px;
}

.routine-add-form input {
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 0.88rem;
}

.routine-table-wrap {
  max-height: 210px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* 좌우 분할 워크스페이스 */
.workspace-split {
  flex: 1;
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  padding: 16px 22px;
  overflow: hidden;
}

.grid-panel,
.detail-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-toolbar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.86rem;
}

.status-counts strong {
  color: var(--primary);
}

.dot-sep {
  margin: 0 6px;
  color: var(--text-muted);
}

.toggle-completed-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--text-muted);
  user-select: none;
}

.grid-container {
  flex: 1;
  overflow-y: auto;
}

.grid-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.grid-table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  text-align: left;
  padding: 10px 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.grid-table td {
  padding: 11px 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.grid-table tbody tr {
  cursor: pointer;
  transition: background 0.1s;
}

.grid-table tbody tr:hover {
  background: var(--surface-hover);
}

.grid-table tbody tr.selected {
  background: var(--surface-selected);
}

.grid-table tbody tr.completed-row {
  color: #94a3b8;
  text-decoration: line-through;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #f1f5f9;
  color: #475569;
}

.badge.routine {
  background: var(--routine-bg);
  color: var(--routine-text);
}

/* 우측 상세 패널 */
.detail-panel {
  padding: 20px;
  overflow-y: auto;
}

.detail-empty {
  margin: auto;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.6;
}

.detail-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.meta-date {
  font-size: 0.78rem;
  color: var(--text-muted);
}

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

@media (max-width: 900px) {
  .workspace-split {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  .routine-add-form {
    grid-template-columns: 1fr;
  }
}
