/* ══════════════════════════════════════════════
   PIYO Frontend Styles — CottonSakura Edition
   ══════════════════════════════════════════════ */

:root {
  --bg: #faf8f9;
  --panel: #ffffff;
  --panel-soft: #fdf7f9;
  --text: #1a1a1a;
  --text-soft: #71717a;
  --text-muted: #a1a1aa;
  --line: #f0e4e8;
  --line-soft: #f8f0f3;
  --brand: #f472b6;
  --brand-light: #fff0f3;
  --brand-dark: #ec4899;
  --brand-deeper: #db2777;
  --brand-glow: rgba(244, 114, 182, 0.12);
  --brand-text: #831843;
  --header-bg: #4a1942;
  --header-text: #fafaf9;
  --ok: #10b981;
  --ok-bg: #ecfdf5;
  --warn: #f59e0b;
  --warn-bg: #fffbeb;
  --fail: #ef4444;
  --fail-bg: #fef2f2;
  --yellow-alert: #fefce8;
  --countdown: #e11d48;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow-xs: 0 1px 2px rgba(0,0,0,.03);
  --shadow: 0 1px 3px rgba(0,0,0,.05), 0 1px 2px rgba(0,0,0,.03);
  --shadow-md: 0 4px 12px rgba(0,0,0,.06), 0 2px 4px rgba(0,0,0,.03);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.08), 0 4px 8px rgba(0,0,0,.04);
  --transition: 0.2s cubic-bezier(.4,0,.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Noto Sans KR', system-ui, -apple-system, sans-serif;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* -- BUTTONS -- */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 14px; border-radius: var(--radius-xs);
  font-weight: 500; transition: all var(--transition);
  border: 1px solid transparent;
}
.btn-primary {
  background: #ffc0cb; color: var(--brand-text);
  border-color: #ffb3c1;
}
.btn-primary:hover {
  background: #ff99b0; border-color: #ff99b0;
  transform: translateY(-1px); box-shadow: 0 2px 8px rgba(236,72,153,.2);
}
.btn-primary:active { transform: translateY(0); }
.btn-danger { background: var(--fail); color: #fff; border-color: var(--fail); }
.btn-danger:hover { background: #dc2626; }
.btn-ghost {
  background: var(--panel); color: var(--text-soft);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-xs);
}
.btn-ghost:hover { background: var(--brand-light); color: var(--brand-dark); border-color: #ffc0cb; }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: var(--radius-xs); }
.btn-lg { padding: 10px 24px; font-size: 14px; border-radius: var(--radius-sm); }
.btn-kakao { background: #FEE500; color: #191919; font-weight: 600; }
.btn-kakao:hover { background: #F5DC00; }
.btn-apple { background: #000; color: #fff; font-weight: 600; }
.btn-apple:hover { background: #333; }
.btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

/* -- LOGIN -- */
#login-screen {
  display: flex; align-items: center; justify-content: center;
  flex: 1; min-height: 100vh;
  background: linear-gradient(180deg, #fff0f3 0%, #ffffff 50%, #ffffff 100%);
  position: relative; overflow: hidden;
}

/* 벚꽃 꽃잎 애니메이션 */
.petals {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 0;
}
.petal {
  position: absolute; top: -20px;
  width: 10px; height: 12px;
  background: linear-gradient(135deg, #fbbad1, #f9a8d4);
  border-radius: 50% 0 50% 50%;
  opacity: 0.6;
  animation: petal-fall linear infinite, petal-sway ease-in-out infinite;
}
@keyframes petal-fall {
  0%   { top: -5%; }
  100% { top: 105%; }
}
@keyframes petal-sway {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  25%      { transform: translateX(30px) rotate(90deg); }
  50%      { transform: translateX(-20px) rotate(180deg); }
  75%      { transform: translateX(25px) rotate(270deg); }
}
.petal:nth-child(1)  { left: 5%;  width: 8px;  height: 10px; animation-duration: 10s, 4s; animation-delay: 0s; opacity: 0.5; }
.petal:nth-child(2)  { left: 15%; width: 12px; height: 14px; animation-duration: 12s, 5s; animation-delay: 1s; opacity: 0.7; }
.petal:nth-child(3)  { left: 28%; width: 9px;  height: 11px; animation-duration: 9s, 3.5s; animation-delay: 3s; opacity: 0.5; }
.petal:nth-child(4)  { left: 40%; width: 11px; height: 13px; animation-duration: 14s, 4.5s; animation-delay: 2s; opacity: 0.6; }
.petal:nth-child(5)  { left: 55%; width: 8px;  height: 10px; animation-duration: 11s, 3s; animation-delay: 5s; opacity: 0.4; }
.petal:nth-child(6)  { left: 65%; width: 13px; height: 15px; animation-duration: 13s, 5.5s; animation-delay: 1.5s; opacity: 0.7; }
.petal:nth-child(7)  { left: 78%; width: 10px; height: 12px; animation-duration: 10s, 4s; animation-delay: 4s; opacity: 0.5; background: linear-gradient(135deg, #f9a8d4, #f472b6); }
.petal:nth-child(8)  { left: 88%; width: 9px;  height: 11px; animation-duration: 15s, 6s; animation-delay: 0.5s; opacity: 0.6; }
.petal:nth-child(9)  { left: 35%; width: 7px;  height: 9px;  animation-duration: 16s, 5s; animation-delay: 7s; opacity: 0.4; background: linear-gradient(135deg, #fce7f3, #fbbad1); }
.petal:nth-child(10) { left: 72%; width: 11px; height: 13px; animation-duration: 11s, 4.5s; animation-delay: 3.5s; opacity: 0.55; }

.login-card {
  background: var(--panel); border-radius: 20px;
  box-shadow: var(--shadow-lg); padding: 48px 44px; width: 400px;
  text-align: center;
  border: 1px solid var(--line);
  position: relative; z-index: 1;
}
.login-card h1 {
  font-size: 26px; font-weight: 700; margin-bottom: 4px;
  letter-spacing: -0.5px; color: var(--brand-dark);
}
.piyo-chick {
  display: inline-block; font-size: 30px; vertical-align: middle;
  animation: chick-bounce 2s ease-in-out infinite;
}
@keyframes chick-bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}
.login-card p { color: var(--text-soft); margin-bottom: 32px; font-size: 13px; }
.login-card input {
  width: 100%; padding: 11px 14px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); margin-bottom: 12px; outline: none;
  transition: all var(--transition); background: #fff;
}
.login-card input:focus {
  border-color: #ffb3c1; background: #fff;
  box-shadow: 0 0 0 3px var(--brand-glow);
}
.login-card .btn {
  width: 100%; justify-content: center; padding: 11px;
  font-size: 14px; margin-top: 8px; border-radius: var(--radius-sm);
}
.login-error { color: var(--fail); font-size: 12px; margin-bottom: 8px; display: none; }

/* -- APP SHELL -- */
#app-shell { display: none; flex-direction: column; height: 100vh; }

/* -- TOP BAR -- */
.top-bar {
  display: flex; align-items: center; height: 48px;
  background: var(--header-bg); color: var(--header-text);
  padding: 0 16px; gap: 10px; flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
  position: relative; z-index: 10;
}
.top-bar .logo {
  font-weight: 800; font-size: 16px; margin-right: 12px;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #fbbad1, #f472b6);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.top-bar .logo-icon {
  -webkit-text-fill-color: initial; font-size: 18px;
}
.account-tabs { display: flex; gap: 3px; flex: 1; overflow-x: auto; }
.account-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: 8px 8px 0 0;
  font-size: 12px; font-weight: 500; cursor: pointer;
  background: rgba(255,255,255,.06); color: rgba(255,255,255,.6);
  transition: all var(--transition); white-space: nowrap; position: relative;
}
.account-tab.active {
  background: rgba(255,255,255,.15); color: #fff;
  box-shadow: inset 0 -2px 0 var(--brand);
}
.account-tab:hover { background: rgba(255,255,255,.1); color: rgba(255,255,255,.85); }
.account-tab .status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-soft); flex-shrink: 0;
}
.account-tab .status-dot.online { background: var(--ok); box-shadow: 0 0 6px rgba(16,185,129,.5); }
.account-tab .close-tab {
  margin-left: 4px; opacity: .4; font-size: 14px; line-height: 1;
}
.account-tab .close-tab:hover { opacity: 1; }
.add-tab-btn {
  padding: 6px 12px; font-size: 16px; color: rgba(255,255,255,.4);
  cursor: pointer; border-radius: 8px 8px 0 0;
  transition: all var(--transition);
}
.add-tab-btn:hover { color: #fff; background: rgba(255,255,255,.08); }
.top-actions { display: flex; gap: 6px; margin-left: auto; align-items: center; }
.top-actions button {
  padding: 5px 12px; font-size: 12px; border-radius: var(--radius-xs);
  color: rgba(255,255,255,.7); transition: all var(--transition);
}
.top-actions button:hover { background: rgba(255,255,255,.1); color: #fff; }
.user-badge { font-size: 11px; color: rgba(255,255,255,.5); }

/* -- EMPTY STATE (no accounts) -- */
#no-account-screen {
  display: none; flex: 1;
  flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; color: var(--text-soft);
}
#no-account-screen .big-icon { font-size: 64px; opacity: .3; }
#no-account-screen h2 { font-size: 18px; color: var(--text); font-weight: 600; }
#no-account-screen p { font-size: 13px; max-width: 360px; text-align: center; line-height: 1.6; }

/* -- 3-PANEL LAYOUT -- */
#main-panels { display: none; flex: 1; overflow: hidden; }
.panels {
  display: grid; height: 100%; width: 100%;
  grid-template-columns: 280px minmax(0, 1fr) 320px;
  transition: grid-template-columns .3s cubic-bezier(.4,0,.2,1);
}

.panel {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel);
  border-right: 1px solid var(--line);
}
.panel:last-child { border-right: none; }
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; min-height: 45px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.panel-body { flex: 1; overflow-y: auto; padding: 0; }

/* -- COLLAPSE/EXPAND TOGGLE -- */
.collapse-toggle {
  display: none; align-items: center; justify-content: center;
  width: 100%; padding: 12px 0; cursor: pointer;
  color: var(--text-muted); font-size: 11px;
  transition: all var(--transition);
  flex-direction: column; gap: 6px;
  user-select: none;
}
.collapse-toggle:hover { color: var(--brand-dark); background: var(--brand-light); }
.collapse-toggle svg {
  width: 16px; height: 16px; transition: transform .3s;
}
.collapse-toggle .collapse-label {
  writing-mode: vertical-lr; text-orientation: mixed;
  font-size: 11px; font-weight: 500; letter-spacing: 1px;
}

/* Left panel collapse */
.accept-toggle-btn { display: none; }
.panels.accept-collapsed { grid-template-columns: 40px minmax(0, 1fr) 320px; }
.panels.accept-collapsed.log-collapsed { grid-template-columns: 40px minmax(0, 1fr) 40px; }
.panels.accept-collapsed .accept-toggle-btn {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 8px;
  cursor: pointer; padding: 12px 4px;
  color: var(--text-muted); font-size: 11px;
  transition: all var(--transition);
  user-select: none; height: 100%;
}
.panels.accept-collapsed .accept-toggle-btn:hover { color: var(--brand-dark); background: var(--brand-light); }
.panels.accept-collapsed .accept-toggle-btn .toggle-icon {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--brand-light); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; transition: all var(--transition);
  color: var(--brand);
}
.panels.accept-collapsed .accept-toggle-btn:hover .toggle-icon {
  background: #ffc0cb; border-color: var(--brand);
  color: var(--brand-deeper);
}
.panels.accept-collapsed .accept-toggle-btn .toggle-label {
  writing-mode: vertical-lr; text-orientation: mixed;
  font-weight: 500; letter-spacing: 1px;
}
.panels.accept-collapsed .accept-content { display: none; }

.accept-content { display: flex; flex-direction: column; flex: 1; overflow: hidden; }

/* Right panel collapse */
.log-toggle-btn { display: none; }
.panels.log-collapsed { grid-template-columns: 280px minmax(0, 1fr) 40px; }
.panels.log-collapsed .log-toggle-btn {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 8px;
  cursor: pointer; padding: 12px 4px;
  color: var(--text-muted); font-size: 11px;
  transition: all var(--transition);
  user-select: none; height: 100%;
}
.panels.log-collapsed .log-toggle-btn:hover { color: var(--brand-dark); background: var(--brand-light); }
.panels.log-collapsed .log-toggle-btn .toggle-icon {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--brand-light); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; transition: all var(--transition);
  color: var(--brand);
}
.panels.log-collapsed .log-toggle-btn:hover .toggle-icon {
  background: #ffc0cb; border-color: var(--brand);
  color: var(--brand-deeper);
}
.panels.log-collapsed .log-toggle-btn .toggle-label {
  writing-mode: vertical-lr; text-orientation: mixed;
  font-weight: 500; letter-spacing: 1px;
}
.panels.log-collapsed .log-content { display: none; }
.log-content { display: flex; flex-direction: column; flex: 1; overflow: hidden; }

/* Collapse button inside panel header */
.panel-collapse-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 500;
  color: var(--text-muted); background: var(--panel-soft);
  border: 1px solid var(--line);
  cursor: pointer; transition: all var(--transition);
}
.panel-collapse-btn:hover {
  color: var(--brand-dark); background: var(--brand-light);
  border-color: #ffc0cb;
}
.panel-collapse-btn svg { width: 12px; height: 12px; }

/* -- LEFT PANEL: ACCEPT -- */
.accept-controls {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px; border-bottom: 1px solid var(--line);
}
.accept-controls label {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text);
}
.accept-controls input[type="checkbox"] {
  accent-color: var(--brand); width: 15px; height: 15px;
}
.accept-controls input[type="number"] {
  width: 60px; padding: 4px 8px; border: 1px solid var(--line);
  border-radius: var(--radius-xs); text-align: center;
  transition: border-color var(--transition);
}
.accept-controls input[type="number"]:focus { border-color: var(--brand); outline: none; }
.accept-log-item {
  padding: 8px 12px; border-bottom: 1px solid var(--line-soft); font-size: 11px;
  transition: background var(--transition);
}
.accept-log-item:hover { background: var(--panel-soft); }
.accept-log-item .time { color: var(--text-soft); }
.accept-log-item .status-ok { color: var(--ok); font-weight: 600; }
.accept-log-item .status-wait { color: var(--warn); }

/* -- CENTER PANEL: DASHBOARD -- */
.dash-toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  background: var(--panel); flex-shrink: 0;
}
.dash-toolbar select {
  padding: 5px 10px; border: 1px solid var(--line);
  border-radius: var(--radius-xs); min-width: 160px;
  transition: border-color var(--transition); background: #fff;
}
.dash-toolbar select:focus { border-color: var(--brand); outline: none; }
.dash-settings {
  display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  font-size: 12px; background: var(--panel-soft); flex-shrink: 0;
}
.dash-settings label { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.dash-settings input[type="number"] {
  width: 62px; padding: 3px 4px; border: 1px solid var(--line);
  border-radius: var(--radius-xs); text-align: center;
  -moz-appearance: textfield; -webkit-appearance: textfield; appearance: textfield;
}
.dash-settings input[type="number"]::-webkit-inner-spin-button,
.dash-settings input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none; appearance: none; display: none; margin: 0;
}
.dash-settings input[type="number"]:focus { border-color: var(--brand); outline: none; }
.dash-settings input[type="checkbox"] { accent-color: var(--brand); }

.farm-list { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; }
.farm-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; position: relative;
  box-shadow: var(--shadow-xs);
  transition: all var(--transition);
}
.farm-card:hover { box-shadow: var(--shadow); border-color: #e8d0d6; }
.farm-card.alert {
  background: var(--yellow-alert); border-color: #fcd34d;
  box-shadow: 0 0 0 1px rgba(252,211,77,.2);
}
.farm-card.expired { background: #fafafa; border-color: var(--line); opacity: 0.6; }
.farm-card.my-farm {
  border-left: 3px solid var(--brand); background: var(--brand-light);
}
.friend-list-row.my-farm {
  border-left: 3px solid var(--brand); background: var(--brand-light);
}
.farm-card-header { display: flex; justify-content: space-between; margin-bottom: 8px; align-items: center; }
.farm-card-header .farm-owner { font-weight: 700; font-size: 13px; }
.farm-card-header .badge {
  font-size: 10px; padding: 2px 8px; border-radius: 12px;
  font-weight: 600; letter-spacing: 0.3px;
}
.farm-card-header .badge.live { background: var(--brand-light); color: var(--brand-deeper); }
.farm-card-header .badge.cache { background: #fef3c7; color: var(--warn); }
.farm-card-header .badge.empty-slot { background: var(--ok-bg); color: #059669; }
.farm-card-header .badge.waiting { background: var(--warn-bg); color: #d97706; }
.farm-card-header .badge.done { background: #f3f4f6; color: #9ca3af; }
.farm-card-info { font-size: 12px; color: var(--text-soft); margin-bottom: 8px; }
.farm-card-countdown {
  font-size: 20px; font-weight: 800; color: var(--countdown);
  margin-bottom: 10px; font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}
.farm-card-controls { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.slot-btn {
  width: 30px; height: 30px; border: 1px solid var(--line);
  border-radius: var(--radius-xs); font-weight: 700; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  background: #fff; transition: all var(--transition);
}
.slot-btn:hover { border-color: var(--brand); color: var(--brand); }
.slot-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: 0 1px 3px rgba(244,114,182,.3); }
.slot-btn.skip { background: var(--panel-soft); color: var(--text-muted); }

/* -- RIGHT PANEL: LOGS & FRIENDS -- */
.log-tabs {
  display: flex; border-bottom: 1px solid var(--line); background: var(--panel);
  padding: 0 4px;
}
.log-tab {
  padding: 9px 14px; font-size: 12px; font-weight: 500;
  border-bottom: 2px solid transparent; cursor: pointer;
  color: var(--text-muted); transition: all var(--transition);
  position: relative;
}
.log-tab:hover { color: var(--text); }
.log-tab.active {
  color: var(--brand-dark); border-color: var(--brand); font-weight: 600;
}
/* -- Log entries -- */
.log-entry {
  padding: 8px 12px; border-bottom: 1px solid var(--line-soft); font-size: 11px;
  transition: background var(--transition);
}
.log-entry:hover { background: var(--panel-soft); }
.log-entry .log-time {
  color: var(--text-muted); font-size: 10px; font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* -- Flag-style log rows -- */
.log-flag-row { padding: 8px 12px; }
.log-flag-top {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.log-flag-bottom {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: 3px; padding-left: 2px;
}

/* Status flags (배지) */
.log-flag {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 2px 8px; border-radius: 10px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.3px;
  line-height: 1.4; white-space: nowrap;
}
.log-flag.flag-success { background: #ecfdf5; color: #059669; }
.log-flag.flag-fail    { background: #fef2f2; color: #dc2626; }
.log-flag.flag-skip    { background: #f3f4f6; color: #6b7280; }
.log-flag.flag-running { background: #fffbeb; color: #d97706; animation: flag-pulse 1.5s ease infinite; }
.log-flag.flag-info    { background: #eff6ff; color: #2563eb; }

@keyframes flag-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Event type label */
.log-type-label {
  font-size: 10px; font-weight: 600; color: var(--text-soft);
  padding: 1px 6px; background: var(--panel-soft); border-radius: 4px;
  white-space: nowrap;
}

/* Friend name */
.log-friend {
  font-size: 11px; font-weight: 500; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 120px;
}

/* Local log message */
.log-msg {
  font-size: 11px; color: var(--text-soft);
  overflow: hidden; text-overflow: ellipsis;
}
.log-local { border-left: 2px solid var(--brand-light); padding-left: 10px; }

/* Meta info (slot, attempts, mode) */
.log-meta {
  font-size: 10px; color: var(--text-muted);
  white-space: nowrap;
}

/* Detail text */
.log-detail-text {
  font-size: 10px; color: var(--text-muted); word-break: break-all;
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Source badge */
.log-source {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 4px;
  font-size: 9px; font-weight: 700; line-height: 1; color: #fff;
  flex-shrink: 0;
}
.log-source.worker { background: #a855f7; }
.log-source.frontend { background: var(--brand); }

/* Empty / Loading / End states */
.log-empty {
  padding: 20px; text-align: center; color: var(--text-soft); font-size: 12px;
}
.log-loading {
  padding: 12px; text-align: center; color: var(--brand);
  font-size: 11px; font-weight: 500;
}
.log-end {
  padding: 12px; text-align: center; color: var(--text-muted);
  font-size: 10px; border-top: 1px dashed var(--line-soft);
}

/* Legacy compat */
.log-entry .log-result {
  display: inline-block; padding: 1px 7px; border-radius: 4px;
  font-weight: 600; font-size: 10px;
}
.log-entry .log-result.success { background: var(--ok-bg); color: var(--ok); }
.log-entry .log-result.fail { background: var(--fail-bg); color: var(--fail); }

/* -- ADMIN PANEL -- */
#admin-panel {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.4); backdrop-filter: blur(4px); z-index: 100;
  justify-content: center; align-items: center;
}
#admin-panel.show { display: flex; }
.admin-card {
  background: var(--panel); border-radius: 16px;
  box-shadow: var(--shadow-lg); width: 680px; max-height: 80vh;
  display: flex; flex-direction: column;
  border: 1px solid var(--line);
}
.admin-card-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 24px; border-bottom: 1px solid var(--line);
  font-weight: 700; font-size: 16px;
}
.admin-card-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.admin-table th, .admin-table td {
  padding: 10px 12px; text-align: left;
  border-bottom: 1px solid var(--line-soft);
}
.admin-table th {
  background: var(--panel-soft); font-weight: 600; color: var(--text-soft);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
}
.admin-table .role-badge {
  display: inline-block; padding: 2px 10px; border-radius: 12px;
  font-size: 11px; font-weight: 600;
}
.admin-table .role-badge.admin { background: #fef3c7; color: #92400e; }
.admin-table .role-badge.user { background: var(--brand-light); color: var(--brand-deeper); }
.admin-form { display: flex; gap: 8px; margin-top: 16px; align-items: flex-end; flex-wrap: wrap; }
.admin-form .field { display: flex; flex-direction: column; gap: 4px; }
.admin-form .field label { font-size: 11px; color: var(--text-soft); font-weight: 500; }
.admin-form .field input, .admin-form .field select {
  padding: 6px 10px; border: 1px solid var(--line);
  border-radius: var(--radius-xs); min-width: 120px;
}

/* Admin Tabs */
.admin-tabs { display: flex; gap: 2px; }
.admin-tab {
  padding: 6px 16px; font-size: 13px; font-weight: 500;
  border-bottom: 2px solid transparent; cursor: pointer;
  color: var(--text-muted); transition: all var(--transition);
  border-radius: var(--radius-xs) var(--radius-xs) 0 0;
}
.admin-tab.active { color: var(--brand-dark); border-color: var(--brand); font-weight: 700; }
.admin-tab:hover { color: var(--text); background: var(--brand-light); }

/* DB Cleanup */
.admin-db-actions {
  margin-top: 16px; padding: 14px;
  background: var(--panel-soft); border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}
.admin-db-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.admin-db-row label { font-size: 12px; font-weight: 600; color: var(--text-soft); }
.admin-db-row select {
  padding: 5px 10px; border: 1px solid var(--line);
  border-radius: var(--radius-xs); font-size: 12px;
}
.admin-db-hint {
  font-size: 11px; color: var(--text-muted); margin-top: 10px; line-height: 1.5;
}

/* -- MODAL (generic) -- */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.4); backdrop-filter: blur(4px); z-index: 200;
  justify-content: center; align-items: center;
  animation: fadeIn .15s ease;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--panel); border-radius: 16px;
  box-shadow: var(--shadow-lg); min-width: 400px; max-width: 90vw;
  max-height: 85vh; display: flex; flex-direction: column;
  animation: modalSlideIn .2s ease;
  border: 1px solid var(--line);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalSlideIn { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 24px; border-bottom: 1px solid var(--line);
  font-weight: 700; font-size: 15px;
}
.modal-header button {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.modal-header button:hover { background: var(--brand-light); }
.modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 24px; border-top: 1px solid var(--line);
}
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 5px; color: var(--text-soft); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); outline: none;
  transition: all var(--transition); background: #fff;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: #ffb3c1; box-shadow: 0 0 0 3px var(--brand-glow);
}
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; line-height: 1.5; }

/* -- ADD ACCOUNT MODAL - method tabs -- */
.method-tabs {
  display: flex; border-bottom: 1px solid var(--line); margin-bottom: 20px;
  gap: 2px;
}
.method-tab {
  padding: 9px 18px; font-size: 12px; font-weight: 500;
  border-bottom: 2px solid transparent; cursor: pointer;
  color: var(--text-muted); transition: all var(--transition);
  border-radius: var(--radius-xs) var(--radius-xs) 0 0;
}
.method-tab.active { color: var(--brand-dark); border-color: var(--brand); font-weight: 600; }
.method-tab:hover { color: var(--text); background: var(--brand-light); }
.method-tab.disabled { opacity: .4; cursor: not-allowed; }
.method-panel { display: none; }
.method-panel.active { display: block; }
.method-coming-soon {
  text-align: center; padding: 36px 24px; color: var(--text-soft);
}
.method-coming-soon .icon { font-size: 36px; margin-bottom: 12px; opacity: .4; }

/* -- MSG RULE MODAL -- */
.rule-list { display: flex; flex-direction: column; gap: 8px; }
.rule-card {
  padding: 12px; background: var(--panel-soft);
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  font-size: 12px; transition: all var(--transition);
}
.rule-card:hover { border-color: #e8d0d6; }
.rule-card-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.rule-card-name { font-weight: 600; font-size: 13px; }
.rule-card-info {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  font-size: 11px; color: var(--text-soft); margin-bottom: 8px;
}
.rule-card-info .rule-sep { color: var(--line); }
.rule-card-actions { display: flex; gap: 6px; }
/* 드래그 드롭 */
.rule-drag-handle {
  cursor: grab; font-size: 14px; color: var(--text-muted);
  padding: 0 4px; user-select: none;
}
.rule-drag-handle:active { cursor: grabbing; }
.rule-order-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--brand-light); color: var(--brand-dark);
  font-size: 10px; font-weight: 600; flex-shrink: 0;
}
.rule-card-dragging { opacity: 0.4; }
.rule-card-dragover { border-color: var(--brand) !important; box-shadow: 0 0 0 2px var(--brand-glow); }
.rule-badge {
  font-size: 10px; padding: 1px 8px; border-radius: 10px; font-weight: 500;
}
.rule-badge-on { background: #e8f5e9; color: #2e7d32; }
.rule-badge-off { background: #fce4ec; color: #c62828; }
.rule-friend { font-weight: 500; font-size: 11px; color: var(--text-soft); }
.rule-mode {
  font-size: 10px; padding: 2px 8px; border-radius: 10px;
  background: var(--brand-light); color: var(--brand-deeper); font-weight: 500;
}
/* 메시지 설정 버튼 (#2) */
.btn-outline {
  border: 1px solid var(--brand); color: var(--brand-deeper);
  background: transparent; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 500; padding: 6px 16px;
  cursor: pointer; transition: all var(--transition);
}
.btn-outline:hover { background: var(--brand-light); }
.btn-msg-setting { width: 100%; }
/* 메시지 모드 바 (#11) */
.msg-mode-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; margin-bottom: 14px;
  background: var(--panel-soft); border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}
.msg-mode-select {
  flex: 1; font-size: 12px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); color: var(--text-main);
}
/* 메시지 섹션 */
.msg-section { margin-bottom: 4px; }
.msg-section-title { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
/* 메시지 textarea (#3,4) */
.msg-textarea {
  flex: 1; resize: none; font-size: 13px;
  padding: 10px 10px; line-height: 1.8;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text);
  font-family: 'Noto Sans KR', 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', system-ui, sans-serif;
  min-height: 56px; overflow-y: auto;
}
.msg-textarea:focus { border-color: var(--brand); outline: none; }
/* 토글 스위치 (#10) */
.toggle-switch {
  position: relative; display: inline-block;
  width: 36px; height: 20px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #ccc; border-radius: 20px;
  transition: 0.2s;
}
.toggle-slider::before {
  content: ""; position: absolute;
  width: 16px; height: 16px;
  left: 2px; bottom: 2px;
  background: #fff; border-radius: 50%;
  transition: 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--brand); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(16px); }
/* 요일 선택 */
.day-selector {
  display: flex; gap: 4px; flex-wrap: wrap;
}
.day-check {
  display: flex; align-items: center; gap: 3px;
  font-size: 12px; cursor: pointer;
  padding: 4px 8px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--panel-soft);
  transition: all var(--transition);
}
.day-check input[type="checkbox"] { display: none; }
.day-check:has(input:checked) {
  background: var(--brand-light); border-color: var(--brand);
  color: var(--brand-deeper); font-weight: 500;
}
.btn-xs { font-size: 10px; padding: 2px 8px; }
/* 기존 호환 */
.rule-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: var(--panel-soft);
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  font-size: 12px; transition: all var(--transition);
}
.rule-item:hover { border-color: #e8d0d6; }
.template-rows { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.template-row {
  display: flex; gap: 6px; align-items: center; font-size: 12px;
  padding: 4px 0; transition: opacity var(--transition);
}
.template-row input {
  flex: 1; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: var(--radius-xs);
  background: var(--bg); color: var(--text);
  font-family: 'Noto Sans KR', 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', system-ui, sans-serif;
  line-height: 1.8; outline: none; transition: border-color var(--transition);
}
.template-row input:focus { border-color: var(--brand); }
.tpl-drag-handle {
  cursor: grab; font-size: 13px; color: var(--text-muted);
  padding: 0 2px; user-select: none; flex-shrink: 0;
}
.tpl-drag-handle:active { cursor: grabbing; }
.tpl-num {
  font-size: 11px; color: var(--text-soft); font-weight: 600;
  min-width: 20px; text-align: center; flex-shrink: 0;
}
.tpl-row-dragging { opacity: 0.4; }
.tpl-row-dragover { border-left: 2px solid var(--brand); padding-left: 2px; }

/* -- FRIEND CHIPS -- */
.friend-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 12px; border-radius: 16px;
  font-size: 11px; font-weight: 500; cursor: pointer;
  background: var(--panel-soft); color: var(--text);
  border: 1px solid var(--line); transition: all var(--transition);
}
.friend-chip:hover { background: var(--brand-light); border-color: #ffc0cb; }
.friend-chip.selected { background: var(--brand-light); border-color: var(--brand); color: var(--brand-deeper); }
.friend-chip .chip-remove {
  font-size: 12px; line-height: 1; opacity: .4; margin-left: 2px;
}
.friend-chip .chip-remove:hover { opacity: 1; color: var(--fail); }
.friend-chip .chip-msg-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--ok); margin-left: 2px;
}
.farm-card.selected-card {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow);
}
.farm-card .msg-badge {
  display: inline-block; font-size: 10px; padding: 2px 8px;
  border-radius: 10px; font-weight: 600;
}
.farm-card .msg-badge.direct { background: var(--ok-bg); color: var(--ok); }
.farm-card .msg-badge.rule { background: var(--brand-light); color: var(--brand-deeper); }
.farm-card .msg-badge.none { background: #f3f4f6; color: var(--text-muted); }
.ntp-clock {
  font-variant-numeric: tabular-nums; font-weight: 700;
  color: var(--brand-deeper); font-size: 13px;
  background: var(--brand-light); padding: 2px 8px; border-radius: 6px;
}
.accept-pending-count {
  font-size: 22px; font-weight: 800; color: var(--brand-deeper);
  text-align: center; padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--brand-light);
}
.accept-pending-count .label {
  font-size: 11px; color: var(--text-soft); font-weight: 400;
  text-transform: uppercase; letter-spacing: 0.5px;
}

/* -- RESPONSIVE -- */
@media (max-width: 900px) {
  .panels { grid-template-columns: 1fr !important; }
  .panel { border-right: none; border-bottom: 1px solid var(--line); }
}

/* -- TOAST -- */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 20px; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 500;
  box-shadow: var(--shadow-md); animation: toastSlideIn .25s ease;
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--line);
}
.toast.success { color: var(--ok); border-color: #a7f3d0; }
.toast.error { color: var(--fail); border-color: #fca5a5; }
.toast.info { color: var(--brand-dark); border-color: #ffc0cb; }
@keyframes toastSlideIn { from { transform: translateY(12px) scale(.95); opacity: 0; } to { transform: none; opacity: 1; } }

/* -- FARM DETAIL VIEW -- */
.farm-detail {
  background: var(--panel); border: 1px solid var(--brand); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 12px;
  box-shadow: 0 0 0 3px var(--brand-glow);
}
.farm-detail-header { display: flex; align-items: center; }
.farm-detail-slots { margin: 10px 0; }
.farm-slot-row { font-size: 12px; padding: 5px 0; border-bottom: 1px solid var(--line-soft); }
.farm-slot-row:last-child { border-bottom: none; }
.farm-slot-row .slot-idx { color: var(--text-muted); font-size: 11px; }
.farm-detail-countdown {
  font-size: 18px; font-weight: 800; color: var(--brand-dark);
  padding: 8px 0; text-align: center;
}
.farm-detail-controls {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  padding-top: 8px; border-top: 1px solid var(--line);
}

/* -- FRIEND LIST (right panel) -- */
.friend-list-row {
  position: relative; padding: 10px 14px; border-bottom: 1px solid var(--line-soft);
  cursor: pointer; transition: all var(--transition);
}
.friend-list-row:hover { background: var(--brand-light); }
.friend-list-row.alert { background: var(--yellow-alert); }
.friend-list-name { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.friend-list-info { font-size: 11px; color: var(--text-soft); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.friend-list-countdown {
  font-size: 13px; font-weight: 700; font-family: 'SF Mono', 'Consolas', monospace;
  color: var(--brand-dark); margin-top: 3px;
}
.friend-list-countdown.alert { color: var(--fail); }
.friend-list-countdown.expired { color: var(--text-muted); font-size: 11px; }
.friend-list-row.expired { opacity: 0.5; }
.farm-card-countdown.expired { color: var(--text-muted); font-size: 14px; }

/* -- SLOT STATUS TAGS -- */
.slot-status-waiting {
  display: inline-block; padding: 1px 7px; border-radius: 4px;
  background: var(--warn-bg); color: #d97706; font-size: 9px; font-weight: 600;
}
.slot-status-empty {
  display: inline-block; padding: 1px 7px; border-radius: 4px;
  background: var(--ok-bg); color: #059669; font-size: 9px; font-weight: 600;
}
.waiting-expiry-line {
  font-size: 9px; color: #d97706; margin-left: 20px; padding: 2px 0;
  border-left: 2px solid #fcd34d; padding-left: 8px; margin-top: 2px;
}

/* -- INLINE BUTTON (manual apply etc.) -- */
.btn-inline {
  background: var(--ok); color: #fff;
  border: none; border-radius: var(--radius-xs);
  cursor: pointer; font-size: 10px;
  padding: 3px 10px; margin-left: 6px;
  font-weight: 600; letter-spacing: 0.3px;
  transition: all var(--transition);
}
.btn-inline:hover { background: #059669; transform: translateY(-1px); }
.btn-inline:active { transform: translateY(0); }

/* -- SCROLLBAR -- */
.panel-body::-webkit-scrollbar { width: 4px; }
.panel-body::-webkit-scrollbar-track { background: transparent; }
.panel-body::-webkit-scrollbar-thumb { background: #e8d0d6; border-radius: 10px; }
.panel-body::-webkit-scrollbar-thumb:hover { background: #d4a0ab; }

/* Session refresh button */
.refresh-session-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 4px 12px; font-size: 11px; font-weight: 600;
  border-radius: 12px; cursor: pointer;
  transition: all .2s; margin-right: 4px; letter-spacing: .3px;
}
.refresh-session-btn.online {
  color: rgba(255,255,255,.45); background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.1);
}
.refresh-session-btn.online:hover {
  color: rgba(255,255,255,.7); background: rgba(255,255,255,.14);
}
.refresh-session-btn.offline {
  color: #fff; background: var(--ok);
  border: 1px solid var(--ok);
  box-shadow: 0 0 8px rgba(16,185,129,.4);
}
.refresh-session-btn.offline:hover {
  background: #059669; border-color: #059669;
}
.refresh-session-btn.spinning { opacity: .6; pointer-events: none; }
