:root {
  --bg: #f3f5f7;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #dbe2ea;
  --active: #0f172a;
  --sticky-offset: 4.9rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 0.8rem 1rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  overflow-x: hidden;
}

.brand {
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.nav {
  display: flex;
  gap: 0.35rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.2rem;
  width: 100%;
}

.nav-link {
  text-decoration: none;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.38rem 0.7rem;
  font-size: 0.86rem;
  white-space: nowrap;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-link:hover {
  border-color: #c4d0dc;
  color: var(--text);
}

.nav-link.is-active {
  color: #ffffff;
  background: var(--active);
  border-color: var(--active);
}

.nav-empty {
  color: var(--muted);
  font-size: 0.9rem;
}

.content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1rem;
  align-items: start;
}

.main-pane {
  min-width: 0;
}

.viewer-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem;
}

.media-stage {
  position: relative;
  width: min(100%, 900px);
  margin: 0 auto;
  cursor: crosshair;
  touch-action: manipulation;
}

.media-viewer {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
}

.pin-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.pin-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 2px solid #ffffff;
  background: #f59e0b;
  color: #111827;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  cursor: pointer;
  box-shadow:
    0 0 0 2px rgba(15, 23, 42, 0.35),
    0 4px 12px rgba(15, 23, 42, 0.35);
  z-index: 3;
}

.pin-marker.is-active {
  background: #0ea5e9;
  color: #ffffff;
  box-shadow:
    0 0 0 2px rgba(15, 23, 42, 0.5),
    0 6px 14px rgba(15, 23, 42, 0.4);
}

.pin-marker.is-draft {
  background: rgba(15, 23, 42, 0.35);
  border: 2px dashed #ffffff;
  pointer-events: none;
}

.pin-note-editor {
  position: absolute;
  z-index: 5;
  display: none;
  background:
    linear-gradient(
      145deg,
      rgba(255, 255, 255, 0.72),
      rgba(255, 255, 255, 0.36)
    );
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 16px;
  padding: 0.72rem;
  box-shadow:
    0 16px 34px rgba(15, 23, 42, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.88),
    inset 0 -1px 0 rgba(255, 255, 255, 0.34);
  backdrop-filter: blur(20px) saturate(165%);
  -webkit-backdrop-filter: blur(20px) saturate(165%);
  overflow: hidden;
}

.pin-note-editor.is-open {
  display: block;
}

.pin-note-editor::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 44%;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.52),
    rgba(255, 255, 255, 0.06)
  );
  pointer-events: none;
}

.pin-note-meta {
  position: relative;
  z-index: 1;
  margin: 0 0 0.38rem;
  font-size: 0.72rem;
  color: #334155;
}

.pin-note-author-label {
  position: relative;
  z-index: 1;
  display: block;
  margin: 0 0 0.2rem;
  font-size: 0.72rem;
  color: #334155;
}

.pin-note-author {
  position: relative;
  z-index: 1;
  width: 100%;
  margin: 0 0 0.4rem;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 8px;
  padding: 0.35rem 0.45rem;
  font: inherit;
  color: #0f172a;
  background: rgba(255, 255, 255, 0.58);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.pin-note-input {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 84px;
  resize: vertical;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 8px;
  padding: 0.45rem 0.5rem;
  font: inherit;
  color: #0f172a;
  background: rgba(255, 255, 255, 0.58);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.pin-note-author:focus,
.pin-note-input:focus {
  outline: none;
  border-color: rgba(56, 189, 248, 0.72);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.24);
}

.pin-note-actions {
  position: relative;
  z-index: 1;
  margin-top: 0.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.4rem;
}

.pin-note-save,
.pin-note-cancel,
.pin-note-delete {
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.46);
  color: #0f172a;
  border-radius: 999px;
  padding: 0.35rem 0.45rem;
  font: inherit;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.pin-note-save {
  background: linear-gradient(
    180deg,
    rgba(219, 234, 254, 0.9),
    rgba(147, 197, 253, 0.72)
  );
}

.pin-note-delete {
  background: linear-gradient(
    180deg,
    rgba(254, 226, 226, 0.9),
    rgba(252, 165, 165, 0.7)
  );
}

.pin-note-save:hover,
.pin-note-cancel:hover,
.pin-note-delete:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 12px rgba(15, 23, 42, 0.16);
}

.empty-state {
  margin: 4rem auto;
  max-width: 640px;
  text-align: center;
  color: var(--muted);
}

.empty-state h1 {
  color: var(--text);
  margin-bottom: 0.5rem;
}

.comments {
  background:
    linear-gradient(
      145deg,
      rgba(255, 255, 255, 0.78),
      rgba(255, 255, 255, 0.46)
    );
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 10px;
  padding: 1rem;
  position: sticky;
  top: var(--sticky-offset);
  max-height: calc(100vh - var(--sticky-offset) - 1rem);
  overflow: auto;
  box-shadow:
    0 10px 24px rgba(15, 23, 42, 0.13),
    inset 0 1px 0 rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px) saturate(155%);
  -webkit-backdrop-filter: blur(14px) saturate(155%);
}

.comments h2 {
  margin: 0 0 0.7rem;
  font-size: 1rem;
}

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

.comment-count {
  margin: 0 0 0.7rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.comment-author-label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 0.3rem;
}

.comment-author {
  width: 100%;
  margin: 0 0 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  font: inherit;
  background: rgba(255, 255, 255, 0.62);
}

.comment-hint.is-warning {
  color: #b45309;
}

.comment-hint.is-info {
  color: #334155;
}

.comment-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.comment-input {
  width: 100%;
  resize: vertical;
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  font: inherit;
  color: var(--text);
}

.comment-actions {
  display: flex;
  gap: 0.5rem;
}

.comment-submit,
.comment-clear {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 0.4rem 0.7rem;
  font: inherit;
  cursor: pointer;
}

.comment-submit:hover,
.comment-clear:hover {
  border-color: #c4d0dc;
}

.comment-clear {
  width: 100%;
}

.comment-list {
  list-style: none;
  margin: 0.85rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}

.comment-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  background: #fff;
  cursor: pointer;
}

.comment-item.is-active {
  border-color: #0f172a;
  box-shadow: inset 0 0 0 1px #0f172a;
}

.comment-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.comment-text {
  margin: 0;
}

.comment-time {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.comment-empty {
  margin: 0.85rem 0 0;
  color: var(--muted);
}

code {
  background: #e8edf3;
  border-radius: 4px;
  padding: 0.1rem 0.3rem;
}

@media (max-width: 700px) {
  .topbar {
    padding: 0.65rem 0.7rem;
    gap: 0.55rem;
    flex-direction: column;
    align-items: stretch;
  }

  .brand {
    font-size: 0.78rem;
  }

  .nav-link {
    font-size: 0.8rem;
    padding: 0.35rem 0.62rem;
    max-width: 75vw;
  }

  .content {
    padding: 0.5rem;
  }

  .viewer-wrap {
    border-radius: 8px;
    padding: 0.4rem;
  }

  .comments {
    padding: 0.8rem;
  }

  .comment-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .comment-submit,
  .comment-clear {
    min-height: 42px;
  }

  .pin-marker {
    width: 34px;
    height: 34px;
    font-size: 0.82rem;
  }

  .pin-note-editor {
    padding: 0.5rem;
  }

  .pin-note-input {
    min-height: 74px;
  }

  .pin-note-actions {
    grid-template-columns: 1fr 1fr;
  }

  .pin-note-delete {
    grid-column: 1 / -1;
  }
}

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

  .comments {
    position: static;
    max-height: none;
    overflow: visible;
  }
}
