:root {
  color-scheme: light;
  --bg: #fbfaf7;
  --ink: #1d1f24;
  --muted: #79746c;
  --line: #ddd8cf;
  --panel: #ffffff;
  --soft: #f1eee8;
  --accent: #111318;
  --shadow: 0 16px 40px rgba(41, 36, 29, .1);
  --tiktok: #ff3b76;
  --homework: #4178d4;
  --drawing: #d49323;
  --work: #68615b;
  --hobby: #3d9462;
  --life: #1c8a86;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button,
a {
  min-height: 2.55rem;
  border-radius: .5rem;
  font-weight: 850;
}

button {
  border: 0;
  cursor: pointer;
  background: var(--accent);
  color: white;
  padding: 0 .9rem;
}

button.secondary,
button.is-active {
  background: var(--life);
}

button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: white;
  background: var(--tiktok);
  padding: 0 .9rem;
}

input,
select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--panel);
  color: var(--ink);
  min-height: 2.75rem;
  padding: 0 .8rem;
}

.app {
  width: min(1440px, calc(100% - 1.2rem));
  margin: 0 auto;
  padding: .8rem 0 1.2rem;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 1rem;
  padding: .6rem 0 .8rem;
}

.topbar p,
.upload-dock p,
.status {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 850;
  margin: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.6rem, 8vw, 6.8rem);
  line-height: .88;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 1.25rem;
}

.toolbar,
.quick-card,
.dock-actions {
  display: flex;
  gap: .55rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.quick-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 10rem 10rem;
  justify-content: stretch;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: .75rem;
  box-shadow: var(--shadow);
  padding: .65rem;
}

.canvas-wrap {
  margin-top: .7rem;
  border: 1px solid var(--line);
  border-radius: .8rem;
  overflow: hidden;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.canvas-head {
  min-height: 2.7rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 .9rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: .86rem;
  font-weight: 750;
}

.canvas {
  position: relative;
  min-height: 62vh;
  overflow: auto;
  background:
    linear-gradient(90deg, rgba(29, 31, 36, .055) 1px, transparent 1px),
    linear-gradient(rgba(29, 31, 36, .055) 1px, transparent 1px),
    #fffefb;
  background-size: 32px 32px;
}

#lines {
  position: absolute;
  left: 0;
  top: 0;
  width: 1200px;
  height: 760px;
  pointer-events: none;
  z-index: 1;
}

#nodes {
  position: relative;
  width: 1200px;
  height: 760px;
  z-index: 2;
}

.node {
  position: absolute;
  width: min(17rem, calc(100vw - 2.4rem));
  min-height: 9rem;
  display: grid;
  gap: .55rem;
  background: var(--panel);
  border: 2px solid var(--line);
  border-top: .5rem solid var(--life);
  border-radius: .8rem;
  box-shadow: 0 14px 36px rgba(35, 31, 25, .16);
  padding: .75rem;
  touch-action: none;
  user-select: none;
}

.node.is-selected {
  outline: 3px solid rgba(28, 138, 134, .28);
}

.node[data-area="tiktok"] { border-top-color: var(--tiktok); }
.node[data-area="homework"] { border-top-color: var(--homework); }
.node[data-area="drawing"] { border-top-color: var(--drawing); }
.node[data-area="work"] { border-top-color: var(--work); }
.node[data-area="hobby"] { border-top-color: var(--hobby); }
.node[data-area="life"] { border-top-color: var(--life); }

.node-top {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
}

.node-title {
  border: 0;
  padding: 0;
  min-height: 0;
  border-radius: 0;
  font-weight: 900;
  font-size: 1rem;
  background: transparent;
}

.pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 1.5rem;
  padding: 0 .48rem;
  border-radius: 99rem;
  color: white;
  font-size: .72rem;
  font-weight: 850;
  text-transform: capitalize;
}

.pill.tiktok { background: var(--tiktok); }
.pill.homework { background: var(--homework); }
.pill.drawing { background: var(--drawing); }
.pill.work { background: var(--work); }
.pill.hobby { background: var(--hobby); }
.pill.life { background: var(--life); }

.node-date {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 750;
}

.node-note {
  width: 100%;
  min-height: 2.3rem;
  border: 1px dashed var(--line);
  border-radius: .5rem;
  padding: .55rem;
  color: var(--ink);
  resize: none;
  font: inherit;
}

.node-actions {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: .4rem;
}

.node-actions button {
  min-height: 2.1rem;
  padding: 0 .5rem;
  font-size: .78rem;
  background: var(--soft);
  color: var(--ink);
}

.node-actions button:first-child {
  background: var(--accent);
  color: white;
}

.file-chip {
  color: var(--muted);
  font-size: .78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-preview {
  max-height: 8rem;
  border-radius: .5rem;
  overflow: hidden;
  border: 1px solid var(--line);
}

.file-preview img,
.file-preview video {
  display: block;
  width: 100%;
  max-height: 8rem;
  object-fit: cover;
}

.upload-dock {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .8rem;
  align-items: center;
  margin-top: .75rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: .75rem;
  box-shadow: var(--shadow);
  padding: .8rem;
}

#cameraPreview {
  display: none;
  grid-column: 1 / -1;
  width: min(30rem, 100%);
  max-height: 18rem;
  border-radius: .7rem;
  background: #111;
}

#cameraPreview.is-on {
  display: block;
}

#clipDownload {
  grid-column: 1 / -1;
}

#clipDownload a {
  background: var(--life);
}

.status {
  margin-top: .8rem;
  text-transform: none;
  font-weight: 750;
}

@media (max-width: 820px) {
  .topbar,
  .quick-card,
  .upload-dock {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .dock-actions {
    justify-content: start;
  }

  .canvas {
    min-height: 68vh;
  }
}
