:root {
  --bg: #0a0a0a;
  --surface: #121212;
  --surface-2: #1b1b1b;
  --surface-hover: #242424;
  --border: #2a2a2a;
  --text: #f5f5f5;
  --text-muted: #9a9a9a;
  --accent: #7f9450;
  --accent-hover: #6d8142;
  --accent-soft: rgba(127, 148, 80, 0.16);
  --danger: #e5534b;
  --today-bg: rgba(127, 148, 80, 0.16);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
  margin-right: 8px;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(127, 148, 80, 0.75);
}

.current-title {
  font-size: 17px;
  font-weight: 600;
  min-width: 130px;
}

.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
}

.btn.small {
  padding: 5px 10px;
  font-size: 13px;
}

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

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

.btn-danger {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.35);
  color: #f87171;
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.25); }

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background 0.15s;
}
.icon-btn:hover { background: var(--surface-hover); }
.icon-btn.small { width: 26px; height: 26px; font-size: 14px; }

.view-switcher {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.view-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s;
}
.view-btn.active {
  background: var(--surface-2);
  color: var(--text);
}

/* Workspace */
.workspace {
  display: flex;
  flex: 1;
  min-height: 0;
  position: relative;
}

/* Sidebar */
.sidebar {
  width: 290px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.todo-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-bottom: none;
}

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

.section-header h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}

.badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
}

.category-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
}
.cat-item:hover { background: var(--surface-hover); }
.cat-item.off { opacity: 0.45; }

.cat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.todo-form {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.todo-form input[type="text"] {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 9px;
  font-size: 13px;
}

.todo-form select {
  width: 72px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  font-size: 12px;
}

.todo-list {
  list-style: none;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.todo-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
}

.todo-item.done {
  opacity: 0.72;
}
.todo-item.done .todo-text {
  text-decoration: line-through;
  text-decoration-color: #ffffff;
  text-decoration-thickness: 1.5px;
}

.todo-text {
  flex: 1;
  font-size: 13px;
  word-break: break-word;
}

.todo-del {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}
.todo-del:hover { color: #f87171; background: rgba(239, 68, 68, 0.12); }

.sidebar-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.sync-status.connected { color: #a3b870; }

/* Right Galaxy S25+ Preview Panel */
.phone-preview-panel {
  width: 330px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.phone-preview-panel.collapsed { display: none; }

.preview-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.preview-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.preview-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.ptab-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.ptab-btn.active {
  background: var(--accent);
  color: #fff;
}

.phone-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 12px;
  overflow-y: auto;
}

/* Galaxy S25+ Mockup */
.galaxy-frame {
  width: 264px;
  height: 548px;
  border-radius: 34px;
  background: #050505;
  border: 3px solid #303030;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.7), inset 0 0 0 2px #141414;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.galaxy-punchhole {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #000;
  z-index: 5;
  box-shadow: 0 0 0 1px #1f1f1f;
}

.galaxy-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 26px 12px 16px;
  background: radial-gradient(circle at 50% 18%, #1d2218 0%, #0d0f0b 55%, #070707 100%);
  overflow-y: auto;
  gap: 10px;
}

.galaxy-homebar {
  position: absolute;
  bottom: 7px;
  left: 50%;
  transform: translateX(-50%);
  width: 84px;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.35);
}

.g-statusbar {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.78);
  padding: 0 4px 4px;
}

.g-widget {
  background: rgba(18, 18, 18, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  padding: 12px;
  backdrop-filter: blur(10px);
}

.g-widget-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}
.g-widget-title {
  font-size: 11px;
  font-weight: 700;
  color: #a3b870;
  letter-spacing: 0.03em;
}
.g-widget-date {
  font-size: 11px;
  color: var(--text-muted);
}

.g-ev-list, .g-todo-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.g-ev-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
}
.g-ev-bar {
  width: 3px;
  height: 16px;
  border-radius: 2px;
  flex-shrink: 0;
}
.g-ev-time {
  font-size: 10px;
  color: var(--text-muted);
  width: 34px;
  flex-shrink: 0;
}
.g-ev-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.g-todo-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  cursor: pointer;
  user-select: none;
}
.g-todo-box {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1.5px solid #7f9450;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #fff;
  flex-shrink: 0;
}
.g-todo-item.done .g-todo-box {
  background: #7f9450;
  border-color: #7f9450;
}
.g-todo-item.done .g-ev-name {
  color: rgba(255, 255, 255, 0.72);
  text-decoration: line-through;
  text-decoration-color: #ffffff;
  text-decoration-thickness: 1.5px;
}
.g-prio-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.g-prio-dot.p3 { background: #ef4444; box-shadow: 0 0 6px rgba(239, 68, 68, 0.65); }
.g-prio-dot.p2 { background: #f97316; }
.g-prio-dot.p1 { background: #eab308; }

.g-empty {
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 0;
}

.g-app-dock {
  margin-top: auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 8px 6px 4px;
}
.g-app-icon {
  width: 36px;
  height: 36px;
  margin: 0 auto;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}
.g-app-icon.olive {
  background: var(--accent);
  color: #fff;
}

/* Lock screen clock */
.g-lock-clock {
  text-align: center;
  padding: 20px 0 12px;
}
.g-lock-time {
  font-size: 46px;
  font-weight: 300;
  letter-spacing: -0.03em;
  line-height: 1;
  color: #fff;
}
.g-lock-date {
  margin-top: 6px;
  font-size: 12px;
  color: #c7d3a8;
  font-weight: 500;
}
.g-lock-hint {
  margin-top: auto;
  text-align: center;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
  padding-bottom: 10px;
}

/* Calendar Main */
.calendar-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* Month View */
.month-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.month-weekdays div {
  text-align: center;
  padding: 8px 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.month-weekdays div:first-child { color: #f87171; }
.month-weekdays div:last-child { color: #60a5fa; }

.month-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(90px, 1fr);
  overflow-y: auto;
}

.day-cell {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  min-width: 0;
  transition: background 0.12s;
}
.day-cell:hover { background: rgba(255, 255, 255, 0.02); }
.day-cell.other-month { opacity: 0.38; }
.day-cell.today { background: var(--today-bg); }
.day-cell.drag-over, .time-cell.drag-over {
  background: rgba(127, 148, 80, 0.28) !important;
  outline: 1.5px dashed var(--accent);
  outline-offset: -2px;
}

.day-num {
  font-size: 12px;
  font-weight: 600;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.day-cell.today .day-num {
  background: var(--accent);
  color: #fff;
}

.ev-chip {
  font-size: 11.5px;
  padding: 2px 6px;
  border-radius: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: grab;
  color: #fff;
  font-weight: 500;
}
.ev-chip:active { cursor: grabbing; }
.ev-chip.dragging { opacity: 0.4; }
.ev-chip:hover { filter: brightness(1.12); }

/* Week & Day Time Grid */
.time-grid-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.time-grid-header {
  display: grid;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.time-grid-header .col-head {
  padding: 10px 6px;
  text-align: center;
  border-left: 1px solid var(--border);
  font-size: 13px;
}
.time-grid-header .col-head.today {
  color: #60a5fa;
  font-weight: 700;
}

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

.time-row {
  display: grid;
  min-height: 48px;
  border-bottom: 1px solid var(--border);
}

.time-label {
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 8px;
  text-align: right;
}

.time-cell {
  border-left: 1px solid var(--border);
  padding: 2px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.time-cell:hover { background: rgba(255, 255, 255, 0.03); }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal.hidden { display: none; }

.modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal-card.small { max-width: 340px; }

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

.modal-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}
.field span {
  font-size: 12px;
  color: var(--text-muted);
}
.field input, .field select, .field textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.field input[type="color"] {
  height: 40px;
  padding: 4px;
  cursor: pointer;
}

.field-row {
  display: flex;
  gap: 10px;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.spacer { flex: 1; }
.hidden { display: none !important; }
.hint { font-size: 12.5px; color: var(--text-muted); }
.file-btn { display: inline-flex; align-items: center; }

/* Mobile (Galaxy S25+ 등) */
.mobile-only { display: none; }
.mobile-bottom-nav { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 1120px) {
  .phone-preview-panel { display: none; }
  .desktop-only { display: none; }
}

@media (max-width: 820px) {
  .mobile-only { display: inline-flex; }
  .brand { display: none; }
  .topbar { padding: 8px 12px; }
  .current-title { font-size: 15px; min-width: auto; }
  #btn-add-event { display: none; }

  .sidebar {
    position: fixed;
    top: 53px;
    bottom: 56px;
    left: 0;
    width: 85vw;
    max-width: 320px;
    z-index: 60;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.open {
    display: block;
    position: fixed;
    inset: 53px 0 56px 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 50;
  }

  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    height: 56px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mnav-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
  }
  .mnav-btn.active { color: var(--accent); font-weight: 600; }

  .month-grid { grid-auto-rows: minmax(76px, 1fr); }
  .day-cell { padding: 4px; }
  .ev-chip { font-size: 10.5px; padding: 1px 4px; }
}
