:root {
  color-scheme: light;
  --bg: #efefef;
  --card: #f8f8f8;
  --text: #1f2937;
  --muted: #5b6472;
  --axis: #5b2cf2;
  --axis-light: #8b5cf6;
  --border: #d4d4d8;
}

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

a {
  color: inherit;
}

.page-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  padding: 1rem 1.5rem;
}

.header-actions {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  flex-wrap: wrap;
}

.header-actions form {
  margin: 0;
}

.page-header h1 {
  margin: 0;
  font-size: 1.5rem;
}

.page-header p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.page-header p a {
  overflow-wrap: anywhere;
}

button {
  border: 1px solid var(--axis-light);
  color: #fff;
  background: var(--axis);
  border-radius: 6px;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
}

main {
  padding: 0 1rem 1.25rem;
}

.timeline-wrap {
  position: relative;
  overflow-x: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ececec;
}

.timeline-visibility {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  gap: 6px;
  z-index: 12;
}

.timeline-visibility__toggle {
  width: 12px;
  height: 12px;
  min-width: 12px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  padding: 0;
  background: #9ca3af;
  cursor: pointer;
}

.timeline-visibility__toggle.is-off {
  opacity: 0.25;
  filter: grayscale(0.6);
}

.timeline-visibility__toggle:focus-visible {
  outline: 2px solid #111827;
  outline-offset: 1px;
}

.timeline-visibility__toggle:disabled {
  opacity: 0.45;
  cursor: wait;
}

.timeline {
  position: relative;
  min-height: 900px;
  min-width: 1200px;
  padding: 16px 20px 26px;
}

.year-ticks {
  position: absolute;
  left: 0;
  right: 0;
  top: 758px;
  height: 45px;
}

.tick {
  position: absolute;
  transform: translateX(-50%);
  text-align: center;
  color: #6b7280;
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: 0.05em;
}

.tick::before {
  content: "";
  position: absolute;
  top: -12px;
  left: 50%;
  width: 1px;
  height: 10px;
  background: #8a8a8a;
  transform: translateX(-50%);
}

.event-node {
  position: absolute;
  width: 0;
}

.event-line {
  position: absolute;
  left: -1px;
  top: calc(-1 * var(--line-height, 60px));
  width: 2px;
  height: var(--line-height, 60px);
  border-left: 2px dotted #9c84ff;
  opacity: 0.45;
  transition: opacity 0.14s ease, border-left-width 0.14s ease, border-left-style 0.14s ease;
  z-index: 0;
  pointer-events: none;
}

.event-dot {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--axis);
  border-radius: 50%;
  left: -6px;
  top: -6px;
  box-shadow: 0 0 0 2px rgba(80, 40, 220, 0.18);
  z-index: 4;
  cursor: pointer;
}

.event-card {
  position: absolute;
  width: 258px;
  height: 72px;
  left: -129px;
  background: var(--card);
  border: 1px solid #d1d5db;
  border-radius: 6px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  display: flex;
  cursor: pointer;
  z-index: 5;
}

.event-node.is-selected .event-card {
  box-shadow: 0 0 0 2px rgba(17, 24, 39, 0.35), 0 4px 12px rgba(0, 0, 0, 0.2);
}

.event-node.is-selected .event-dot {
  transform: scale(1.28);
  box-shadow: 0 0 0 4px rgba(17, 24, 39, 0.25);
}

.event-node.is-selected .event-line {
  opacity: 1;
  border-left-style: solid;
  border-left-width: 3px;
}

.event-card-media {
  width: 72px;
  min-width: 72px;
  height: 72px;
  background: #d7d7dc;
  overflow: hidden;
}

.event-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.event-card-body {
  padding: 0.42rem 0.55rem;
  font-size: 0.83rem;
  line-height: 1.2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.event-card-date {
  font-size: 0.78rem;
  color: #374151;
  margin-bottom: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-card-title {
  font-weight: 700;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.event-card-desc {
  display: none;
}

.timespan {
  position: absolute;
  height: 20px;
  top: 404px;
  background: #4b13f3;
  color: #fff;
  border-radius: 4px;
  font-size: 0.87rem;
  display: flex;
  align-items: center;
  padding: 0 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 3;
}

.range-strip {
  position: absolute;
  left: 20px;
  right: 20px;
  top: 800px;
  height: 42px;
  border: 1px solid #e0e0e0;
  border-radius: 7px;
  background: #ece8ff;
  touch-action: none;
}

.range-strip__fill {
  position: absolute;
  left: 0;
  width: 100%;
  top: 7px;
  bottom: 7px;
  border-radius: 5px;
  background: linear-gradient(90deg, #e6e5e5, #b9b9b9);
  cursor: grab;
}

.range-strip__handle {
  position: absolute;
  top: 5px;
  bottom: 5px;
  width: 12px;
  border: 1px solid #c9b5ff;
  border-radius: 3px;
  background: #f2edff;
  cursor: ew-resize;
}

.range-strip__handle::before,
.range-strip__handle::after {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: #9f88e9;
}

.range-strip__handle::before {
  left: 4px;
}

.range-strip__handle::after {
  right: 4px;
}

.range-strip.is-dragging .range-strip__fill {
  cursor: grabbing;
}

.detail-modal {
  width: min(820px, 94vw);
  border: 0;
  border-radius: 10px;
  padding: 0;
  background: #fff;
  color: var(--text);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
}

.detail-modal::backdrop {
  background: rgba(10, 12, 20, 0.6);
}

.detail-modal__content {
  position: relative;
}

.detail-modal__toolbar {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  z-index: 2;
}

.detail-modal__edit {
  border: 1px solid #d4d4d8;
  color: #111827;
  background: #fff;
  padding: 0.38rem 0.62rem;
  line-height: 1;
}

.detail-modal__close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 1.4rem;
  line-height: 1;
  padding: 0;
  border: 1px solid #d4d4d8;
  color: #111827;
  background: #fff;
}

.detail-modal__media {
  width: 100%;
  max-height: 430px;
  overflow-y: auto;
  overflow-x: hidden;
  background: #ddd;
}

.detail-modal__media img {
  width: 100%;
  height: auto;
  display: block;
}

.detail-modal__body {
  padding: 1rem 1.2rem 1.3rem;
}

.detail-modal__date {
  font-size: 1.08rem;
  font-style: italic;
  color: #374151;
  margin-bottom: 0.5rem;
}

.detail-modal__title {
  margin: 0 0 0.65rem;
  font-size: 2rem;
  line-height: 1.15;
}

.detail-modal__description {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.35;
  color: #1f2937;
}

.detail-modal__description a {
  color: #1d4ed8;
  text-decoration: underline;
  word-break: break-word;
}

.form-modal {
  width: min(560px, 92vw);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0;
  background: #fff;
  color: var(--text);
}

.form-modal::backdrop {
  background: rgba(17, 24, 39, 0.35);
}

.form-modal form {
  margin: 0;
  padding: 0.9rem;
}

.form-modal h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

label {
  display: block;
  margin-bottom: 0.55rem;
  font-size: 0.85rem;
  color: #374151;
}

input,
select,
textarea {
  width: 100%;
  margin-top: 0.2rem;
  border: 1px solid #c4c4c8;
  border-radius: 4px;
  padding: 0.45rem;
  font: inherit;
}

.modal-actions {
  margin-top: 0.3rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
}

button.secondary {
  background: #fff;
  color: var(--axis);
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.checkbox-line input {
  width: auto;
  margin-top: 0;
}

.period-manager-modal {
  width: min(760px, 95vw);
}

.period-manager-list {
  max-height: min(58vh, 480px);
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.period-manager-empty {
  padding: 0.9rem;
  color: #6b7280;
}

.period-manager-row {
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  justify-content: space-between;
}

.period-manager-row:last-child {
  border-bottom: 0;
}

.period-manager-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: #111827;
}

.period-manager-controls {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.period-manager-controls input[type="color"] {
  width: 44px;
  height: 34px;
  padding: 0.1rem;
  margin-top: 0;
}