* { box-sizing: border-box; }

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #1a1a1a;
  --text-dim: #6b7280;
  --text-faint: #9ca3af;
  --brand: #f97316;
  --brand-dim: #ffedd5;
  --brand-ink: #9a3412;
  --start: #059669;
  --start-bg: #ecfdf5;
  --end: #dc2626;
  --end-bg: #fef2f2;
  --radius: 12px;
}

body {
  font-family: -apple-system, "Segoe UI", "Pretendard", "Malgun Gothic", sans-serif;
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

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

.header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo {
  color: var(--brand);
  flex-shrink: 0;
}

.header-name {
  font-size: 1.05rem;
  font-weight: 700;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--text-faint);
  white-space: nowrap;
  padding-top: 4px;
}

#refresh-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.2s;
}

#refresh-btn:hover {
  color: var(--brand);
  border-color: var(--brand);
}

#refresh-btn.spinning {
  animation: spin 0.6s linear;
}

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

#notifications {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.notif-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.notif-col h2 {
  font-size: 0.88rem;
  margin: 0;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot-start { background: var(--start); }
.dot-end { background: var(--end); }

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
}

.badge-start { color: var(--start); background: var(--start-bg); }
.badge-end { color: var(--end); background: var(--end-bg); }

.notif-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
}

.notif-col li {
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}

.notif-col li:last-child {
  border-bottom: none;
}

.notif-col li.empty {
  color: var(--text-faint);
  font-size: 0.85rem;
  text-align: center;
  padding: 16px 0;
}

.notif-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.notif-item .site-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.notif-item .meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.sheet-tag {
  font-size: 0.68rem;
  color: var(--text-dim);
  background: #f3f4f6;
  border-radius: 4px;
  padding: 1px 6px;
}

#chat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

#login-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

#login-bar #name-input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
}

#login-bar #name-input:focus {
  outline: none;
  border-color: var(--brand);
}

#user-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: var(--brand-dim);
  border-radius: 8px;
  font-size: 0.82rem;
  color: var(--brand-ink);
}

#switch-user-btn {
  padding: 4px 10px;
  font-size: 0.75rem;
  background: #fff;
  color: var(--brand);
  border: 1px solid var(--brand);
}

#switch-user-btn:hover {
  background: var(--brand);
  color: #fff;
}

#chat-log {
  min-height: 240px;
  max-height: 420px;
  overflow-y: auto;
  margin-bottom: 12px;
  padding-right: 2px;
}

.msg {
  padding: 9px 12px;
  border-radius: 10px;
  margin-bottom: 8px;
  white-space: pre-wrap;
  font-size: 0.88rem;
  max-width: 82%;
}

.msg.user {
  background: var(--brand);
  color: #fff;
  margin-left: auto;
  border-bottom-right-radius: 3px;
}

.msg.bot {
  background: #f0f1f3;
  color: var(--text);
  margin-right: auto;
  border-bottom-left-radius: 3px;
}

.msg.welcome {
  background: var(--brand-dim);
  color: var(--brand-ink);
  font-size: 0.82rem;
}

.msg.loading {
  color: var(--text-faint);
  font-style: italic;
}

#chat-form {
  display: flex;
  gap: 8px;
}

#chat-input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
}

#chat-input:focus {
  outline: none;
  border-color: var(--brand);
}

button {
  padding: 9px 18px;
  border: none;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
}

button:hover {
  background: #ea580c;
}

@media (max-width: 560px) {
  #notifications {
    grid-template-columns: 1fr;
  }
}
