:root {
  --ink: #111827;
  --muted: #6b7280;
  --line: #d1d5db;
  --panel: #ffffff;
  --soft: #f6f7f9;
  --accent: #0f766e;
  --danger: #dc2626;
  font-family: "Yu Gothic", "YuGothic", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: #eef1f4;
}

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

button {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: var(--ink);
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
}

button:hover {
  border-color: #94a3b8;
}

button[type="submit"],
#saveButton {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.hidden,
body[data-role="user"] .admin-only {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-box {
  width: min(420px, 100%);
  background: #fff;
  padding: 32px;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.16);
}

.login-box h1 {
  margin: 0 0 24px;
  font-size: 30px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
  color: #374151;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand {
  font-size: 18px;
  font-weight: 900;
  white-space: nowrap;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.toolbar input {
  width: auto;
}

.title-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-size: 14px;
}

.title-toggle input {
  width: auto;
}

.title-input {
  min-width: 280px;
}

.workspace {
  display: grid;
  grid-template-columns: 340px 1fr;
  min-height: calc(100vh - 64px);
}

.side-panel {
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 16px;
  overflow: auto;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head h2,
.modal h2 {
  margin: 0;
  font-size: 18px;
}

.stack {
  display: grid;
  gap: 12px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.danger {
  color: #b91c1c;
  border-color: #fecaca;
}

.copy-status {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #99f6e4;
  border-radius: 6px;
  background: #f0fdfa;
  color: #0f766e;
  font-weight: 800;
  line-height: 1.45;
}

.copy-active .day-cell:not(.outside) {
  cursor: copy;
}

.copy-active .day-cell:not(.outside):hover {
  background: #ecfeff;
}

.copy-active .day-cell.closed:hover {
  background: #ffe4e6;
}

.event-list {
  display: grid;
  gap: 8px;
  margin-top: 20px;
}

.event-list button {
  display: grid;
  gap: 2px;
  text-align: left;
}

.event-list button.selected {
  border-color: #0f766e;
  background: #ccfbf1;
  box-shadow: inset 4px 0 0 #0f766e;
}

.event-list span {
  color: var(--muted);
}

.preview-wrap {
  overflow: auto;
  padding: 18px;
}

.calendar-a3 {
  width: min(100%, 1400px);
  margin: 0 auto;
  background: #fff;
  padding: 3.2% 3.5% 3.4%;
  box-shadow: 0 12px 34px rgba(15, 23, 42, 0.18);
  display: block;
  gap: 0;
  color: #030712;
}

.calendar-a3.poster-mode {
  width: 1900px;
  max-width: none;
  aspect-ratio: 4961 / 3508;
  padding: 0;
  background: transparent;
}

.calendar-export-area {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto;
  gap: 0;
}

.poster-export-area {
  min-width: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 6px 3.4% 1.6%;
  background: linear-gradient(180deg, var(--poster-bg-top), var(--poster-bg-bottom));
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 0;
}

.poster-export-area.without-background {
  background: #ffffff;
}

.poster-header {
  min-height: 122px;
  margin-bottom: -20px;
  position: relative;
  display: grid;
  place-items: center;
  z-index: 1;
}

.poster-title-slot {
  min-width: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  transform: translateY(-8px);
}

.poster-title-image {
  display: block;
  width: min(var(--poster-title-width), 96%);
  max-height: 164px;
  object-fit: contain;
}

.poster-title-fallback {
  font-size: clamp(36px, 5.6vw, 76px);
  font-weight: 950;
  line-height: 1;
  color: #ffffff;
  -webkit-text-stroke: 4px #000000;
  paint-order: stroke fill;
}

.poster-month {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: flex-end;
  gap: 0.04em;
  color: var(--poster-month-color);
  font-size: var(--poster-month-size);
  font-weight: 950;
  line-height: 1;
  white-space: nowrap;
  -webkit-text-stroke: var(--poster-month-stroke) var(--poster-month-outline);
  paint-order: stroke fill;
  filter: drop-shadow(1px 2px 0 rgba(0, 0, 0, 0.35));
}

.poster-month-year,
.poster-month-number,
.poster-month-unit {
  display: inline-block;
}

.poster-month-year {
  font-size: 1.12em;
}

.poster-month-number {
  font-size: 1.12em;
}

.poster-month-unit {
  font-size: 0.72em;
  padding-bottom: 0.04em;
}

.calendar-title {
  text-align: center;
  font-weight: 900;
  line-height: 1;
  font-size: clamp(30px, 4.8vw, 68px);
  letter-spacing: 0;
  margin-bottom: 1.1%;
}

.calendar-frame {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
}

.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-left: 3px solid #111;
  border-top: 3px solid #111;
  background: #ffffff;
}

.weekday-row div {
  display: grid;
  place-items: center;
  min-height: 38px;
  font-size: clamp(18px, 2.2vw, 30px);
  font-weight: 900;
  border-right: 3px solid #111;
  border-bottom: 3px solid #111;
}

.poster-mode .weekday-row div {
  min-height: 34px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(136px, auto);
  border-left: 3px solid #111;
  background: #ffffff;
}

.poster-mode .calendar-grid {
  min-height: 0;
  grid-auto-rows: 1fr;
}

.day-cell {
  min-width: 0;
  min-height: 0;
  border-right: 3px solid #111;
  border-bottom: 3px solid #111;
  padding: 6px;
  background: #fff;
  overflow: hidden;
}

.poster-mode .day-cell {
  padding: 5px;
}

.day-cell.closed {
  background: #fff1f2;
}

.day-cell.outside {
  background: #fafafa;
}

.date-head {
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  column-gap: 6px;
  text-align: left;
}

.date-number {
  display: block;
  font-size: clamp(20px, 2.7vw, 42px);
  line-height: 1;
  font-weight: 900;
  text-align: left;
}

.sun {
  color: #dc2626;
}

.sat {
  color: #0284c7;
}

.hours {
  min-width: 0;
  justify-self: end;
  align-self: start;
  margin-top: 4px;
  padding: 3px 7px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #334155;
  font-weight: 600;
  font-size: clamp(8px, 0.92vw, 14px);
  line-height: 1;
  white-space: nowrap;
}

.poster-mode .hours {
  font-size: clamp(10px, 0.98vw, 17px);
}

.hours.red {
  color: #dc2626;
}

.hours.bold {
  font-weight: 900;
  -webkit-text-stroke: 0.35px currentColor;
  paint-order: stroke fill;
}

.events {
  display: grid;
  gap: 4px;
  margin-top: 4px;
  align-content: start;
}

.event-count-1,
.event-count-2,
.event-count-3 {
  min-height: 92px;
}

.poster-mode .event-count-1,
.poster-mode .event-count-2,
.poster-mode .event-count-3 {
  min-height: 92px;
}

.event-chip {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 5px;
  align-items: center;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  text-align: left;
  line-height: 1.05;
}

.event-chip.selected {
  outline: 3px solid #0f766e;
  outline-offset: 2px;
  background: #ecfdf5;
}

.category-tag {
  width: 50px;
  min-height: 27px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 2px 3px;
  border: 2px solid var(--tag-border);
  border-radius: 6px;
  color: var(--tag-text);
  background: var(--tag-bg);
  font-weight: 900;
  font-size: clamp(8px, 0.8vw, 13px);
  line-height: 1;
  text-align: center;
}

.category-tag span {
  display: block;
}

.poster-mode .category-tag {
  width: 56px;
  min-height: 30px;
  font-size: clamp(9px, 0.88vw, 15px);
}

.event-main {
  min-width: 0;
  font-size: clamp(9px, 0.94vw, 16px);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.poster-mode .event-main {
  font-size: clamp(12.5px, 1.2vw, 21px);
}

.event-note {
  font-size: 0.86em;
  font-weight: 700;
  color: #111827;
}

.poster-mode .event-note {
  font-size: 0.762em;
}

.modal {
  border: 0;
  padding: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.modal-box {
  width: min(860px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
}

.settings-box {
  width: min(1080px, calc(100vw - 32px));
}

.modal header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.tabs button.active {
  color: #fff;
  background: #334155;
  border-color: #334155;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: grid;
  gap: 14px;
}

.rows {
  display: grid;
  gap: 8px;
}

.setting-row {
  display: grid;
  gap: 8px;
  align-items: center;
}

.category-row {
  grid-template-columns: 1.4fr 1fr 70px 70px 70px 90px auto;
}

.holiday-row {
  grid-template-columns: 180px 1fr auto;
}

.override-row {
  grid-template-columns: 170px 1fr auto auto auto auto;
}

.override-row label {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.override-row input[type="checkbox"] {
  width: auto;
}

.weekday-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.poster-settings {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.message {
  color: var(--danger);
  min-height: 1.4em;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  transform: translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: 0.18s ease;
  background: #111827;
  color: #fff;
  padding: 10px 14px;
  border-radius: 6px;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .side-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .category-row,
  .holiday-row,
  .override-row,
  .weekday-grid,
  .poster-settings {
    grid-template-columns: 1fr;
  }
}
