:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-soft: #f1f5f9;
  --text: #151923;
  --muted: #7b8190;
  --line: #e7e9ef;
  --accent: #25b7d3;
  --shadow: 0 16px 36px rgba(15, 23, 42, 0.12);
}

* { box-sizing: border-box; }

html {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overscroll-behavior-x: none;
}

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

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#app {
  width: min(100%, 620px);
  max-width: 100vw;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--surface);
  overflow-x: hidden;
}

.hidden { display: none !important; }

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(68px, calc(env(safe-area-inset-top, 0px) + 24px)) 14px max(82px, env(safe-area-inset-bottom, 0px));
}

.login-screen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f0fbff 100%);
}

.login-screen form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-screen h1 {
  margin: 0;
  font-size: 2rem;
}

.login-screen p,
.summary,
#daySubtitle,
.item-meta,
.detail-muted {
  color: var(--muted);
}

input, select, textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
  padding: 10px 12px;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.primary {
  width: 100%;
  min-height: 50px;
  border-radius: 16px;
  background: var(--text);
  color: #fff;
  font-weight: 800;
}

.month-header {
  display: grid;
  grid-template-columns: 46px 1fr 46px;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.icon-btn {
  width: 46px;
  height: 42px;
  border-radius: 14px;
  background: #eef2f7;
  font-size: 1.6rem;
  font-weight: 900;
}

.month-title {
  min-height: 42px;
  background: transparent;
  text-align: left;
  font-size: clamp(1.35rem, 7vw, 1.55rem);
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.month-title::after {
  content: "▼";
  margin-left: 5px;
  color: #a2a7b0;
  font-size: 0.7rem;
}

.calendar-toolbar {
  display: grid;
  grid-template-columns: 1fr 72px;
  gap: 8px;
  margin-bottom: 10px;
}

.ghost-btn {
  border-radius: 14px;
  background: #eef7ff;
  color: #1169b1;
  font-weight: 800;
}

.summary {
  min-height: 20px;
  margin-bottom: 8px;
  font-size: 0.86rem;
}

.weekday-row,
.week-days,
.week-bars {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.month-grid {
  display: flex;
  flex-direction: column;
}

.weekday-row {
  border-bottom: 1px solid var(--line);
}

.weekday-row span {
  padding: 7px 0;
  text-align: center;
  color: #8b91a0;
  font-size: 0.76rem;
  font-weight: 800;
}

.weekday-row span.sunday {
  color: #dc2626;
}

.weekday-row span.saturday {
  color: #2563eb;
}

.month-week {
  display: flex;
  flex-direction: column;
}

/* 날짜 숫자 행 */
.week-days {
  border-bottom: none;
}

.day-cell {
  display: block;
  height: 28px;
  padding: 4px 2px 2px;
  appearance: none;
  -webkit-appearance: none;
  background: #fff;
  border-right: 1px solid #f0f1f4;
  text-align: center;
  overflow: hidden;
}

.day-cell:nth-child(7n) { border-right: 0; }
.day-cell.empty { background: #fbfcfd; }
.day-cell.outside { color: #b8bdc7; }
.day-cell.sunday {
  background: #fff1f2;
  color: #dc2626;
}
.day-cell.saturday {
  background: #eff6ff;
  color: #2563eb;
}
.day-cell.selected { background: #eef7ff; }
.day-cell.today .day-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #1f2937;
  color: #fff;
}

.day-num {
  display: block;
  font-size: 0.83rem;
  font-weight: 900;
  line-height: 20px;
  height: 20px;
}

/* 이벤트 바 행 — 날짜 숫자 아래 별도 행 */
.week-bars {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-auto-rows: 17px;
  row-gap: 2px;
  min-height: clamp(36px, calc((100dvh - 320px) / 6 - 28px), 60px);
  padding: 2px 0 4px;
  border-bottom: 1px solid #f0f1f4;
  background: #fff;
}

.month-week .week-bars {
  background:
      linear-gradient(90deg,
      rgba(220, 38, 38, 0.08) 0 calc(100% / 7),
      transparent calc(100% / 7) calc(600% / 7),
      rgba(37, 99, 235, 0.08) calc(600% / 7) 100%);
}

.week-event-bar {
  min-width: 0;
  min-height: 16px;
  margin: 0 2px;
  padding: 0 4px;
  border-radius: 4px;
  color: #fff;
  font-size: 0.64rem;
  font-weight: 800;
  line-height: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  pointer-events: auto;
}

.week-event-bar.start {
  margin-right: 0;
  border-radius: 4px 0 0 4px;
}

.week-event-bar.mid {
  margin-left: 0;
  margin-right: 0;
  border-radius: 0;
}

.week-event-bar.end {
  margin-left: 0;
  border-radius: 0 4px 4px 0;
}

.week-event-bar.single {
  border-radius: 4px;
}

.more-chip {
  color: #6b7280;
  background: transparent;
  font-size: 0.62rem;
  font-weight: 800;
}

.day-sheet {
  position: sticky;
  bottom: calc(58px + env(safe-area-inset-bottom));
  z-index: 4;
  margin: 12px -14px -12px;
  padding: 8px 14px 16px;
  border-radius: 24px 24px 0 0;
  background: #fff;
  box-shadow: var(--shadow);
}

.sheet-handle {
  width: 42px;
  height: 4px;
  margin: 0 auto 12px;
  border-radius: 99px;
  background: #d8dce3;
}

.day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.day-header h2 {
  margin: 0;
  font-size: 1.35rem;
}

#daySubtitle {
  margin: 2px 0 0;
  font-size: 0.85rem;
}

.quick-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  gap: 8px;
  margin-top: 12px;
}

.quick-add input {
  min-height: 42px;
  border-radius: 12px;
  font-size: 0.88rem;
}

.quick-add button {
  min-height: 42px;
  border-radius: 12px;
  background: #111827;
  color: #fff;
  font-size: 0.86rem;
  font-weight: 900;
}

.round {
  flex: 0 0 auto;
  width: 50px;
  height: 50px;
  border-radius: 999px;
  background: #232323;
  color: #fff;
  font-size: 1.8rem;
  font-weight: 800;
}

.day-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 12px;
  max-height: 42vh;
  overflow: auto;
}

.item {
  display: grid;
  grid-template-columns: 72px 4px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 8px 0;
  background: #fff;
  text-align: left;
}

.item-time {
  color: #2f3541;
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1.35;
}

.item-line {
  width: 4px;
  height: 44px;
  border-radius: 99px;
  background: var(--accent);
}

.item-title {
  font-weight: 900;
  line-height: 1.25;
}

.item-meta {
  margin-top: 3px;
  font-size: 0.8rem;
  line-height: 1.25;
}

.avatars {
  display: flex;
  justify-content: flex-end;
  min-width: 42px;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-left: -7px;
  border: 2px solid #fff;
  border-radius: 999px;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 900;
}

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

.icon-link,
.save-link {
  width: auto;
  min-height: 40px;
  padding: 0 8px;
  background: transparent;
  color: var(--accent);
  font-size: 1.2rem;
  font-weight: 900;
}

.save-link {
  min-width: 68px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #1f2937;
  font-size: 1rem;
}

.detail-title {
  margin: 24px 0;
  color: var(--accent);
  text-align: center;
  font-size: 1.35rem;
}

.detail-time {
  display: grid;
  grid-template-columns: 1fr 28px 1fr;
  align-items: center;
  gap: 14px;
  margin: 20px 0 24px;
  text-align: center;
}

.detail-time strong {
  display: block;
  margin-top: 3px;
  font-size: 2.1rem;
}

.detail-row,
.form-row,
.toggle-row,
.static-row {
  display: grid;
  grid-template-columns: 78px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  border-top: 1px solid var(--line);
}

.detail-row span:first-child,
.form-row span,
.toggle-row span {
  color: #2f3541;
  font-weight: 900;
}

.title-input {
  margin: 28px 0 18px;
  border: 0;
  background: transparent;
  font-size: 1.55rem;
  font-weight: 900;
}

.form-row {
  grid-template-columns: 52px 3fr 2fr;
}

.form-row input,
.form-row select {
  min-height: 42px;
  border: 0;
  border-radius: 10px;
  background: #f4f5f7;
  text-align: center;
  font-weight: 800;
}

.date-hint {
  min-height: 24px;
  margin: -8px 0 4px 62px;
  color: #64748b;
  font-size: 0.8rem;
  font-weight: 800;
}

.toggle-row input {
  justify-self: end;
  width: 58px;
  height: 34px;
  accent-color: #111827;
}

.static-row strong {
  font-size: 0.95rem;
}

.danger {
  width: 100%;
  min-height: 48px;
  margin-top: 12px;
  border-radius: 14px;
  background: #fee2e2;
  color: #b91c1c;
  font-weight: 900;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(100%, 620px);
  transform: translateX(-50%);
  padding: 7px 10px max(7px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
}

.bottom-nav button {
  min-height: 42px;
  background: transparent;
  color: #9aa0aa;
  font-size: 0.78rem;
  font-weight: 900;
}

.bottom-nav button.active { color: #059669; }

.bottom-nav button:not(.active) {
  cursor: pointer;
}

.list-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
  margin-bottom: 8px;
}

.list-date {
  padding-top: 12px;
  color: #6b7280;
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
}

.menu-row {
  width: 100%;
  min-height: 48px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  font-size: 1rem;
  font-weight: 900;
  text-align: left;
  padding: 0 16px;
}

.danger-text {
  color: #b91c1c;
}

.error {
  min-height: 20px;
  color: #dc2626;
  font-weight: 700;
}

@media (max-width: 390px) {
  .screen {
    padding-top: max(72px, calc(env(safe-area-inset-top, 0px) + 28px));
    padding-left: 10px;
    padding-right: 10px;
  }
  .day-cell { height: 26px; padding-top: 3px; }
  .week-bars { grid-auto-rows: 14px; min-height: 32px; }
  .week-event-bar { min-height: 14px; line-height: 14px; font-size: 0.60rem; padding: 0 3px; }
  .item { grid-template-columns: 62px 4px 1fr auto; }
  .form-row { grid-template-columns: 46px 3fr 2fr; }
}

/* ── 에디터 추가 UI ── */
.form-section-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 14px 0 6px;
}
.remind-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}
.remind-check-item {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--hover);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 0.8rem;
  cursor: pointer;
}
.remind-check-item input[type=checkbox] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
}
.weekday-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin: 4px 0;
}
.weekday-btn {
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.82rem;
  cursor: pointer;
}
.weekday-btn input[type=checkbox] {
  width: 13px;
  height: 13px;
  accent-color: var(--accent);
}

/* Android APK embedded mode: this calendar lives inside the Sales Intelligence WebView. */
.embedded-android body {
  background: transparent;
  font-size: 15px;
}

.embedded-android #app {
  width: 100%;
  max-width: 100%;
  min-height: 100dvh;
  border-radius: 14px;
}

.embedded-android .screen {
  min-height: 100dvh;
  padding: 12px 10px 68px;
}

.embedded-android .month-header {
  grid-template-columns: 40px 1fr 40px;
  gap: 6px;
  margin-bottom: 8px;
}

.embedded-android .month-title {
  font-size: 1.24rem;
}

.embedded-android .calendar-toolbar {
  grid-template-columns: minmax(0, 1fr) 64px;
  gap: 6px;
  margin-bottom: 8px;
}

.embedded-android input,
.embedded-android select,
.embedded-android textarea {
  min-height: 42px;
  border-radius: 12px;
  padding: 8px 10px;
}

.embedded-android .summary {
  margin-bottom: 6px;
  font-size: 0.84rem;
}

.embedded-android .weekday-row span {
  padding: 5px 0;
  font-size: 0.72rem;
}

.embedded-android .day-cell {
  height: 30px;
}

.embedded-android .day-num {
  font-size: 0.84rem;
}

.embedded-android .week-bars {
  grid-auto-rows: 18px;
  min-height: clamp(42px, calc((100dvh - 292px) / 6), 66px);
  row-gap: 2px;
}

.embedded-android .week-event-bar {
  min-height: 17px;
  line-height: 17px;
  font-size: 0.66rem;
}

.embedded-android .bottom-nav {
  width: 100%;
  padding: 6px 8px max(6px, env(safe-area-inset-bottom));
}

.embedded-android .bottom-nav button {
  min-height: 40px;
  font-size: 0.76rem;
}
