:root {
  --bg: #f4f7ff;
  --card: #ffffff;
  --text: #1b2440;
  --muted: #65708a;
  --accent: #1f6fff;
  --accent-soft: #e8f0ff;
  --border: #dce5f5;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: radial-gradient(circle at 20% 10%, #edf3ff 0%, var(--bg) 55%);
  color: var(--text);
}

.app {
  max-width: 860px;
  margin: 2rem auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(23, 52, 122, 0.1);
  padding: 1rem;
}

.toolbar {
  display: grid;
  grid-template-columns: 90px 1fr 90px;
  gap: 0.75rem;
  align-items: center;
}

h1 {
  margin: 0;
  text-align: center;
  font-size: 1.3rem;
}

button {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

.auth-panel {
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: 0.65rem;
  margin: -0.2rem 0 1rem;
  padding-bottom: 1rem;
}

.auth-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 1fr) auto auto;
  gap: 0.5rem;
}

.auth-form input {
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  min-width: 0;
  padding: 0.55rem 0.7rem;
}

.auth-form input:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent-soft);
}

.auth-session {
  align-items: center;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
}

.auth-session span {
  color: var(--muted);
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-status {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
  min-height: 1.2em;
}

.auth-status.error {
  color: #b32727;
}

.upload-panel {
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: 0.65rem;
  margin: -0.2rem 0 1rem;
  padding-bottom: 1rem;
}

.upload-form {
  align-items: end;
  display: grid;
  gap: 0.5rem;
  grid-template-columns: auto minmax(180px, 1fr) auto;
}

.upload-form label {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
  padding-bottom: 0.55rem;
}

.upload-form input[type="file"] {
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  min-width: 0;
  padding: 0.45rem 0.55rem;
}

.upload-progress {
  accent-color: var(--accent);
  height: 0.8rem;
  width: 100%;
}

.upload-progress.active {
  opacity: 0.85;
}

.upload-status {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
  min-height: 1.2em;
  overflow-wrap: anywhere;
}

.upload-status.error {
  color: #b32727;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.sr-only {
  border: 0;
  clip: rect(0, 0, 0, 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.actions {
  margin: 0.9rem 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.calendar-wrap {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekdays div {
  padding: 0.7rem 0.35rem;
  text-align: center;
  background: #f8faff;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  color: var(--muted);
}

.day {
  min-height: 104px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 0.45rem;
  background: #fff;
  text-align: left;
}

.day:nth-child(7n) {
  border-right: none;
}

.day-number {
  font-size: 0.9rem;
  font-weight: 700;
}

.day.other-month .day-number {
  color: #9ba7bf;
}

.day.today {
  background: var(--accent-soft);
}

.day-note {
  margin-top: 0.4rem;
  font-size: 0.82rem;
  color: #33415f;
  white-space: pre-wrap;
  word-break: break-word;
}

#eventDialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(460px, 92vw);
  padding: 0;
}

#eventDialog::backdrop {
  background: rgba(17, 28, 57, 0.35);
}

.dialog-form {
  padding: 1rem;
  display: grid;
  gap: 0.65rem;
}

textarea {
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  padding: 0.6rem;
  resize: vertical;
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
  margin: 0.35rem 0 0;
  padding: 0;
}

@media (max-width: 720px) {
  .app {
    margin: 1rem;
  }

  .toolbar {
    grid-template-columns: 72px 1fr 72px;
  }

  .auth-form {
    grid-template-columns: 1fr;
  }

  .auth-session {
    align-items: stretch;
    flex-direction: column;
  }

  .upload-form {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .upload-form label {
    padding-bottom: 0;
  }

  .day {
    min-height: 84px;
  }

  .hint {
    font-size: 0.85rem;
    margin-left: 0.8rem;
  }
}
