/* อักษร — design tokens */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=Noto+Sans+Thai:wght@300;400;500;600;700;800&family=Noto+Serif+Thai:wght@400;600&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Brand */
  --ink:    #0F172A;
  --ink-2:  #1E293B;
  --ink-3:  #334155;
  --muted:  #64748B;
  --muted-2:#94A3B8;
  --line:   #E2E8F0;
  --line-2: #EEF2F6;
  --line-3: #F1F5F9;
  --bg:     #F8FAFC;
  --paper:  #FFFFFF;
  --paper-2:#FBFCFD;

  --primary:    #2563EB;
  --primary-700:#1D4ED8;
  --primary-50: #EEF2FF;
  --primary-100:#DBEAFE;

  --emerald:    #059669;
  --emerald-50: #ECFDF5;
  --emerald-100:#D1FAE5;

  --amber:    #D97706;
  --amber-50: #FFFBEB;
  --amber-100:#FEF3C7;

  --rose:    #BE123C;
  --rose-50: #FFF1F2;
  --rose-100:#FFE4E6;

  --violet:   #6D28D9;
  --violet-50:#F5F3FF;

  --sand:  #F5F1EA;
  --sand-2:#EDE7DA;

  /* Radius */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;

  /* Shadows */
  --sh-1: 0 1px 2px rgba(15,23,42,.04), 0 1px 1px rgba(15,23,42,.03);
  --sh-2: 0 1px 2px rgba(15,23,42,.04), 0 4px 12px rgba(15,23,42,.05);
  --sh-3: 0 2px 4px rgba(15,23,42,.04), 0 12px 32px rgba(15,23,42,.08);

  /* Typography — Thai + Latin (ตรงกับหน้า Home) */
  --serif: "Noto Serif Thai", "Instrument Serif", Georgia, serif;
  --sans:  "Inter", "Noto Sans Thai", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono:  "JetBrains Mono", "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

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

html {
  font-family: var(--sans);
  font-size: 16px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body { line-height: 1.5; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
img { display: block; max-width: 100%; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }

/* Status pills */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
  letter-spacing: 0.01em;
}
.pill-dot { width: 6px; height: 6px; border-radius: 50%; flex: 0 0 auto; }
.pill.urgent  { background: var(--rose-50);    color: var(--rose); }
.pill.event   { background: var(--violet-50);  color: var(--violet); }
.pill.general { background: var(--primary-50); color: var(--primary); }
.pill.success { background: var(--emerald-50); color: var(--emerald); }
.pill.warn    { background: var(--amber-50);   color: var(--amber); }
.pill.muted   { background: var(--line-3);     color: var(--muted); }
.pill.locked  { background: var(--line-3);     color: var(--muted); }

/* Cards */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-1);
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--paper);
  color: var(--ink); font-size: 14px; font-weight: 500;
  transition: background .12s, border-color .12s, box-shadow .12s, transform .04s;
  white-space: nowrap;
}
.btn:hover  { background: var(--paper-2); border-color: var(--muted-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-700); border-color: var(--primary-700); }
.btn.emerald { background: var(--emerald); border-color: var(--emerald); color: #fff; }
.btn.emerald:hover { background: #047857; border-color: #047857; }
.btn.ghost  { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--line-3); border-color: transparent; }
.btn.sm     { height: 30px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn.lg     { height: 46px; padding: 0 22px; font-size: 15px; }
.btn.danger { background: var(--rose-50); border-color: var(--rose-100); color: var(--rose); }
.btn.danger:hover { background: var(--rose-100); }
.btn.full   { width: 100%; }

/* Divider */
.divider { height: 1px; background: var(--line); }

/* Notification dot */
.dot-noti {
  position: absolute; top: 6px; right: 6px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--rose); box-shadow: 0 0 0 2px var(--paper);
  pointer-events: none;
}

/* Serif headings */
.serif { font-family: var(--serif); font-weight: 400; letter-spacing: -0.01em; }
.mono  { font-family: var(--mono); }

/* Placeholder image */
.placeholder {
  position: relative; overflow: hidden;
  background:
    repeating-linear-gradient(135deg, rgba(15,23,42,.04) 0 1px, transparent 1px 9px),
    var(--sand);
  color: var(--muted); font-family: var(--mono); font-size: 10px;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: 0.06em;
}

/* Animations */
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }
.pulse { animation: pulse 1s ease-in-out infinite; }

@keyframes fadeIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }
.fade-in { animation: fadeIn .2s ease; }

@keyframes spin { to{transform:rotate(360deg)} }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--primary);
  animation: spin .6s linear infinite;
}

/* Form inputs */
.input {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--paper); color: var(--ink); font-size: 14px;
  outline: none; transition: border-color .12s, box-shadow .12s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
.input::placeholder { color: var(--muted-2); }

.textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--paper); color: var(--ink); font-size: 14px;
  outline: none; resize: vertical; min-height: 80px;
  transition: border-color .12s, box-shadow .12s;
}
.textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }

/* Avatar */
.avatar {
  border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center;
  font-weight: 600; flex: 0 0 auto; font-size: 13px;
  background-size: cover; background-position: center;
  user-select: none;
}

/* Toast notification */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9999; display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast {
  padding: 12px 16px; border-radius: var(--r-md);
  background: var(--ink); color: #fff;
  font-size: 14px; box-shadow: var(--sh-3);
  pointer-events: auto; animation: fadeIn .2s ease;
  display: flex; align-items: center; gap: 10px;
  max-width: 320px;
}
.toast.success { background: var(--emerald); }
.toast.error   { background: var(--rose); }
.toast.warn    { background: var(--amber); }

/* Loading overlay */
#loading {
  position: fixed; inset: 0; background: rgba(255,255,255,.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 9998; backdrop-filter: blur(4px);
}
#loading.hidden { display: none; }

/* File chip */
.file-chip {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; font-family: var(--mono); font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase; flex: 0 0 auto;
}
