* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", sans-serif;
  background: #f4f5f7;
  color: #222;
}

.hidden { display: none !important; }

.screen { min-height: 100vh; }

/* ログイン画面 */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-box {
  background: #fff;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  width: 320px;
  text-align: center;
}

.login-box h1 {
  font-size: 20px;
  margin-bottom: 24px;
}

.login-box input {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}

.login-box button {
  width: 100%;
  padding: 10px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

.login-box button:hover { background: #1d4ed8; }

.error { color: #dc2626; font-size: 13px; min-height: 18px; margin-top: 8px; }

/* アプリ画面 */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
}

header h1 { font-size: 18px; margin: 0; }

.header-actions { display: flex; align-items: center; gap: 10px; font-size: 13px; }

.header-actions button {
  padding: 6px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
}

.header-actions button:hover { background: #f3f4f6; }

.user-menu { position: relative; }

.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-menu-btn .chevron { font-size: 10px; color: #6b7280; }

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 160px;
  z-index: 10;
}

.user-menu-dropdown button {
  width: 100%;
  text-align: left;
  border: none;
  border-radius: 6px;
}

#logout-btn { color: #b91c1c; }

main {
  max-width: 900px;
  margin: 24px auto;
  padding: 0 16px;
}

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 16px;
}

.calendar-nav button {
  border: none;
  background: #fff;
  border-radius: 6px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.calendar-nav h2 { margin: 0; font-size: 18px; min-width: 140px; text-align: center; }

.calendar-legend {
  text-align: right;
  font-size: 12px;
  color: #6d28d9;
  margin: -6px 2px 8px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.weekday {
  text-align: center;
  font-size: 12px;
  color: #6b7280;
  padding: 4px 0;
}

.day-cell {
  background: #fff;
  border-radius: 8px;
  min-height: 84px;
  min-width: 0;
  padding: 6px;
  cursor: pointer;
  border: 1px solid #e5e7eb;
  position: relative;
  overflow: hidden;
}

.day-cell:hover { background: #eff6ff; }

.day-cell.other-month { opacity: 0.35; }

.day-cell.today { border: 2px solid #2563eb; }

.day-number { font-size: 12px; color: #374151; }

.event-chip {
  font-size: 11px;
  background: #dbeafe;
  color: #1e3a8a;
  border-radius: 4px;
  padding: 1px 4px;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-chip.icloud {
  background: #ede9fe;
  color: #6d28d9;
}

.event-chip.salida {
  background: #fef9c3;
  color: #92400e;
}

/* 日別パネル */
.day-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 340px;
  height: 100vh;
  background: #fff;
  box-shadow: -4px 0 16px rgba(0,0,0,0.1);
  padding: 20px;
  overflow-y: auto;
}

.day-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.day-panel-header button {
  border: none;
  background: none;
  font-size: 16px;
  cursor: pointer;
}

#event-list { list-style: none; padding: 0; margin: 0 0 20px; }

#event-list li {
  padding: 10px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  margin-bottom: 8px;
  cursor: pointer;
  font-size: 13px;
}

#event-list li:hover { background: #f9fafb; }

#event-list .event-time { color: #6b7280; font-size: 12px; margin-right: 6px; }

.icloud-note {
  font-size: 12px;
  color: #6d28d9;
  background: #ede9fe;
  border-radius: 6px;
  padding: 8px 10px;
  margin: 0 0 12px;
}

#event-form {
  border-top: 1px solid #e5e7eb;
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#event-form input, #event-form textarea {
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}

#event-form textarea { min-height: 60px; resize: vertical; }

#event-title:read-only, #event-memo:read-only, #event-time:disabled {
  background: #f3f4f6;
  color: #6b7280;
}

.field-label { font-size: 12px; color: #6b7280; margin-bottom: -4px; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #374151;
}

.checkbox-label input { width: auto; padding: 0; }

.remind-offset-select {
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
}

.remind-offset-select:disabled { opacity: 0.5; background: #f3f4f6; }

.form-actions { display: flex; gap: 8px; }

.form-actions button {
  flex: 1;
  padding: 8px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 13px;
}

#save-event-btn { background: #2563eb; color: #fff; }
#save-event-btn:hover { background: #1d4ed8; }

#delete-event-btn { background: #fee2e2; color: #b91c1c; }
#delete-event-btn:hover { background: #fecaca; }

@media (max-width: 640px) {
  .day-panel { width: 100%; }
  .day-cell { min-height: 60px; }
}
