/* ═══════════════════════════════════════════════════
   ygo collab notes — "Ink & Paper" editorial theme
   ═══════════════════════════════════════════════════ */

:root {
  --paper:    #f5f0e8;
  --paper-hi: #ece6d9;
  --ink:      #1a1615;
  --ink-50:   #1a161580;
  --ink-20:   #1a161533;
  --ink-10:   #1a16151a;
  --red:      #c23b22;
  --red-soft: #c23b2218;
  --blue:     #2d5a8e;
  --green:    #3a7d44;
  --mono:     'IBM Plex Mono', monospace;
  --serif:    'Newsreader', Georgia, serif;
  --ease:     cubic-bezier(.4, 0, .2, 1);
  --radius:   3px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: var(--mono);
  background: var(--paper);
  color: var(--ink);
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--red); color: var(--paper); }

/* ─── scrollbar ─── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ink-20); border-radius: 99px; }

/* ═══ GATE (login) ═══ */

.gate {
  display: grid;
  place-items: center;
  height: 100dvh;
  padding: 2rem;
  background:
    repeating-linear-gradient(0deg, transparent, transparent 1.6rem, var(--ink-10) 1.6rem, var(--ink-10) calc(1.6rem + 1px)),
    var(--paper);
  animation: gateFadeIn .5s var(--ease) both;
}

@keyframes gateFadeIn { from { opacity: 0; } }

.gate-paper {
  width: 100%;
  max-width: 400px;
  padding: 2.5rem 2rem 2rem;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  position: relative;
}

.gate-rule {
  position: absolute;
  top: 0; left: 2.5rem; right: 2.5rem;
  height: 3px;
  background: var(--red);
}

.gate-masthead {
  text-align: center;
  border-bottom: 1px solid var(--ink-20);
  padding-bottom: 1rem;
  margin-bottom: 1rem;
}

.gate-masthead h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.7rem;
  letter-spacing: -.02em;
  line-height: 1.2;
  margin: .25rem 0;
}

.gate-vol, .gate-date {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .15em;
  color: var(--ink-50);
}

.gate-sub {
  text-align: center;
  font-size: .75rem;
  color: var(--ink-50);
  margin-bottom: 1.5rem;
}

.gate-fields label {
  display: block;
  margin-bottom: 1rem;
}

.gate-fields label span {
  display: block;
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ink-50);
  margin-bottom: .3rem;
}

.gate-fields input {
  width: 100%;
  font-family: var(--serif);
  font-size: 1rem;
  padding: .5rem 0;
  border: none;
  border-bottom: 1px solid var(--ink-20);
  background: transparent;
  color: var(--ink);
  outline: none;
  transition: border-color .2s;
}

.gate-fields input:focus {
  border-color: var(--red);
}

.gate-fields button {
  width: 100%;
  margin-top: .5rem;
  padding: .65rem;
  font-family: var(--mono);
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  border: 1.5px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  transition: all .15s var(--ease);
}

.gate-fields button:hover {
  background: var(--red);
  border-color: var(--red);
}

.gate-footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: .65rem;
  color: var(--ink-50);
}

.gate-footer a {
  color: var(--red);
  text-decoration: none;
  font-weight: 600;
}

/* ═══ WORKSPACE ═══ */

.workspace {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  animation: wsFadeIn .4s var(--ease) both;
}

@keyframes wsFadeIn { from { opacity: 0; transform: translateY(4px); } }

/* ─── topbar ─── */

.topbar {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: 0 .75rem;
  height: 42px;
  border-bottom: 1px solid var(--ink-20);
  flex-shrink: 0;
  font-size: .75rem;
}

.topbar-left, .topbar-center, .topbar-right {
  display: flex;
  align-items: center;
  gap: .35rem;
}

.topbar-left { flex: 1; }
.topbar-right { flex: 1; justify-content: flex-end; }

.tb-room {
  font-weight: 600;
  letter-spacing: -.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tb-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: all .12s;
}

.tb-btn:hover { background: var(--ink-10); }
.tb-btn:disabled { opacity: .25; pointer-events: none; }

.tb-btn--leave:hover { color: var(--red); }

.tb-sep {
  width: 1px;
  height: 16px;
  background: var(--ink-20);
  margin: 0 .15rem;
}

/* peers */
.peers { display: flex; gap: 4px; margin-right: .25rem; }

.peer-pip {
  width: 22px; height: 22px;
  border-radius: 99px;
  display: grid;
  place-items: center;
  font-size: .55rem;
  font-weight: 600;
  color: var(--paper);
  border: 1.5px solid var(--paper);
  cursor: default;
  position: relative;
}

.peer-pip[data-name]::after {
  content: attr(data-name);
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  font-family: var(--mono);
  font-size: .6rem;
  background: var(--ink);
  color: var(--paper);
  padding: 2px 6px;
  border-radius: 2px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s;
}

.peer-pip:hover::after { opacity: 1; }

/* status dot */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 99px;
  background: var(--ink-20);
  transition: background .3s;
  flex-shrink: 0;
}

.status-dot.connected { background: var(--green); }
.status-dot.disconnected { background: var(--red); }

/* ─── main layout ─── */

.main-wrap {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ─── sidebar ─── */

.sidebar {
  width: 260px;
  flex-shrink: 0;
  border-right: 1px solid var(--ink-20);
  overflow-y: auto;
  padding: 1rem;
  transition: margin-left .25s var(--ease);
}

.sidebar.collapsed {
  margin-left: -260px;
}

.sb-section {
  margin-bottom: 1.5rem;
}

.sb-title {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ink-50);
  margin-bottom: .75rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.sb-tag {
  font-size: .55rem;
  font-weight: 600;
  padding: 1px 5px;
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: 2px;
  letter-spacing: .06em;
}

.sb-field {
  display: block;
  margin-bottom: .75rem;
}

.sb-field span {
  display: block;
  font-size: .6rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--ink-50);
  margin-bottom: .2rem;
}

.sb-field input {
  width: 100%;
  font-family: var(--serif);
  font-size: .9rem;
  padding: .35rem 0;
  border: none;
  border-bottom: 1px solid var(--ink-10);
  background: transparent;
  color: var(--ink);
  outline: none;
  transition: border-color .15s;
}

.sb-field input:focus { border-color: var(--red); }

/* tasks */
.task-list { margin-bottom: .5rem; }

.task-empty {
  font-size: .7rem;
  color: var(--ink-20);
  font-style: italic;
  padding: .25rem 0;
}

.task-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .3rem 0;
  border-bottom: 1px solid var(--ink-10);
  font-size: .8rem;
}

.task-item.done .task-text { text-decoration: line-through; color: var(--ink-50); }

.task-check {
  width: 14px; height: 14px;
  border: 1.5px solid var(--ink-20);
  border-radius: 2px;
  flex-shrink: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all .12s;
}

.task-check.checked {
  background: var(--red);
  border-color: var(--red);
}

.task-check.checked::after {
  content: '';
  width: 6px; height: 6px;
  background: var(--paper);
  border-radius: 1px;
}

.task-text { flex: 1; }

.task-del {
  border: none;
  background: none;
  color: var(--ink-20);
  cursor: pointer;
  font-size: .75rem;
  padding: 0 2px;
  transition: color .12s;
}

.task-del:hover { color: var(--red); }

.task-form {
  display: flex;
  gap: .25rem;
}

.task-form input {
  flex: 1;
  font-family: var(--mono);
  font-size: .75rem;
  padding: .35rem .5rem;
  border: 1px solid var(--ink-10);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  outline: none;
}

.task-form input:focus { border-color: var(--red); }

.task-form button {
  width: 28px; height: 28px;
  border: 1px solid var(--ink-20);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font-size: 1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all .12s;
}

.task-form button:hover { background: var(--ink); color: var(--paper); }

/* snapshots */
.snap-list { max-height: 200px; overflow-y: auto; }

.snap-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .35rem 0;
  border-bottom: 1px solid var(--ink-10);
  font-size: .7rem;
}

.snap-label { font-weight: 500; }
.snap-time { color: var(--ink-50); font-size: .6rem; }

.snap-view {
  font-family: var(--mono);
  font-size: .6rem;
  border: 1px solid var(--ink-20);
  border-radius: 2px;
  background: transparent;
  padding: 1px 6px;
  cursor: pointer;
  transition: all .12s;
}

.snap-view:hover { background: var(--ink); color: var(--paper); }

/* ─── editor + preview ─── */

.editor-wrap {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pane--edit { border-right: 1px solid var(--ink-20); }

.pane-label {
  font-size: .6rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ink-50);
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--ink-10);
  display: flex;
  align-items: center;
  gap: .5rem;
}

#editor {
  flex: 1;
  width: 100%;
  padding: 1rem;
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--ink);
  background: transparent;
  border: none;
  resize: none;
  outline: none;
  overflow-y: auto;
}

#editor::placeholder { color: var(--ink-20); }

.preview-body {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.7;
}

.preview-body h1, .preview-body h2, .preview-body h3 {
  font-family: var(--serif);
  font-weight: 500;
  margin: 1.2em 0 .4em;
  letter-spacing: -.02em;
}

.preview-body h1 { font-size: 1.6rem; border-bottom: 1px solid var(--ink-20); padding-bottom: .3rem; }
.preview-body h2 { font-size: 1.3rem; }
.preview-body h3 { font-size: 1.1rem; }
.preview-body p { margin: .6em 0; }
.preview-body ul, .preview-body ol { padding-left: 1.5rem; margin: .6em 0; }
.preview-body code {
  font-family: var(--mono);
  font-size: .85em;
  background: var(--ink-10);
  padding: .1em .35em;
  border-radius: 2px;
}
.preview-body pre {
  background: var(--ink);
  color: var(--paper);
  padding: .75rem 1rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: .75em 0;
}
.preview-body pre code { background: transparent; padding: 0; }
.preview-body blockquote {
  border-left: 3px solid var(--red);
  padding-left: 1rem;
  color: var(--ink-50);
  margin: .75em 0;
}
.preview-body a { color: var(--blue); }
.preview-body img { max-width: 100%; border-radius: var(--radius); }

/* ─── snapshot preview overlay ─── */
.snap-overlay {
  position: fixed;
  inset: 0;
  background: #1a161590;
  display: grid;
  place-items: center;
  z-index: 100;
  animation: overlayIn .2s var(--ease) both;
}

@keyframes overlayIn { from { opacity: 0; } }

.snap-overlay-inner {
  background: var(--paper);
  border: 1.5px solid var(--ink);
  width: 90%;
  max-width: 640px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.snap-overlay-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--ink-20);
  font-size: .75rem;
  font-weight: 600;
}

.snap-overlay-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.snap-overlay-close {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--ink-50);
}

.snap-overlay-close:hover { color: var(--red); }

/* ─── responsive ─── */
@media (max-width: 768px) {
  .sidebar { position: fixed; left: 0; top: 42px; bottom: 0; z-index: 50; background: var(--paper); }
  .sidebar.collapsed { margin-left: -260px; }
  .pane--preview { display: none; }
}
