:root {
  color-scheme: light;
  --panel: #ffffff;
  --panel-border: #d8e0ea;
  --ink: #162033;
  --muted: #667085;
  --accent: #315efb;
  --accent-dark: #2448d8;
  --accent-soft: #eef2ff;
  --danger: #dc2626;
  --surface: #f4f7fb;
  --success: #16a34a;
  --warning: #d97706;
  --shadow: 0 18px 48px rgba(25, 38, 64, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  font-family: Inter, "Pretendard", "Noto Sans KR", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--surface);
  overflow: hidden;
  word-break: keep-all;
  overflow-wrap: break-word;
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

button:focus-visible,
.chart-node:focus-visible {
  outline: 3px solid rgba(49, 94, 251, 0.35);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.centered-view {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 20%, #ffffff 0, #f3f6fb 55%, #e9eff8 100%);
}

.loading-card {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 18px 22px;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid #dbe3f0;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.auth-view {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, 0.8fr);
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 15%, rgba(82, 114, 255, 0.28), transparent 36%),
    linear-gradient(135deg, #14213d 0%, #1e3270 58%, #315efb 100%);
}

.auth-intro {
  align-self: center;
  max-width: 720px;
  padding: clamp(40px, 7vw, 100px);
  color: #ffffff;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 30px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 30px;
  font-weight: 900;
}

.eyebrow {
  margin: 0 0 7px;
  color: #7182a0;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.auth-intro .eyebrow {
  color: #b9c6ff;
}

.auth-intro h1 {
  margin: 0;
  font-size: clamp(38px, 5vw, 68px);
  line-height: 1.12;
  letter-spacing: -0.04em;
}

.auth-intro > p:not(.eyebrow) {
  max-width: 600px;
  margin: 28px 0;
  color: #d8e0ff;
  font-size: 17px;
  line-height: 1.7;
}

.feature-list {
  display: grid;
  gap: 12px;
  margin: 32px 0 0;
  padding: 0;
  list-style: none;
}

.feature-list li::before {
  content: "✓";
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-right: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
}

.auth-card {
  align-self: center;
  width: min(440px, calc(100% - 48px));
  margin: 48px auto;
  padding: 34px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 28px 90px rgba(5, 15, 42, 0.32);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-bottom: 30px;
  padding: 5px;
  border-radius: 11px;
  background: #edf1f7;
}

.auth-tab {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #667085;
  font-weight: 800;
  cursor: pointer;
}

.auth-tab.is-active {
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 3px 10px rgba(30, 43, 72, 0.1);
}

.auth-card h2 {
  margin: 0;
  font-size: 25px;
  letter-spacing: -0.03em;
}

.auth-description {
  margin: 9px 0 25px;
  color: var(--muted);
  font-size: 14px;
}

.form-message {
  margin: 16px 0 0;
  padding: 11px 12px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff1f2;
  color: #9f1239;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 356px) 1fr;
  width: 100vw;
  height: 100vh;
}

.control-panel {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
  padding: 22px;
  border-right: 1px solid var(--panel-border);
  background: var(--panel);
  box-shadow: 8px 0 24px rgba(28, 36, 48, 0.05);
  overflow-y: auto;
}

.panel-header,
.section-title-row,
.sync-row,
.account-card {
  display: flex;
  align-items: center;
}

.panel-header,
.section-title-row {
  justify-content: space-between;
  gap: 12px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: -0.02em;
}

.panel-header h1 {
  font-size: 28px;
  line-height: 1.1;
}

.panel-section h2 {
  font-size: 15px;
}

.account-card {
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: #f8faff;
}

.avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 900;
}

.account-copy {
  display: grid;
  min-width: 0;
  flex: 1;
}

.account-copy strong,
.account-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-copy strong {
  font-size: 13px;
}

.account-copy span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.text-button {
  padding: 3px;
  border: 0;
  background: transparent;
  color: #516078;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.text-button:hover {
  color: var(--accent);
}

.sync-row {
  gap: 7px;
  min-height: 24px;
  padding: 0 3px;
  color: var(--muted);
  font-size: 12px;
}

.sync-row .text-button {
  margin-left: auto;
}

.sync-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
}

.sync-indicator.is-saved {
  background: var(--success);
}

.sync-indicator.is-error {
  background: var(--danger);
}

.panel-section {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: #fbfcfe;
}

.panel-section.compact {
  min-height: 130px;
}

.stacked-form {
  display: grid;
  gap: 13px;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 750;
}

.optional {
  color: #98a2b3;
  font-size: 11px;
  font-weight: 600;
}

input {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #c9d2df;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  outline: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(49, 94, 251, 0.14);
}

input[type="file"] {
  padding: 7px;
  font-size: 12px;
}

input[type="color"] {
  padding: 5px;
}

.primary-button,
.ghost-button,
.icon-button,
.delete-button {
  border-radius: 8px;
  cursor: pointer;
}

.primary-button {
  min-height: 43px;
  padding: 10px 14px;
  border: 0;
  background: var(--accent);
  color: #ffffff;
  font-weight: 850;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.primary-button:disabled,
.ghost-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.ghost-button {
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid #c9d2df;
  background: #ffffff;
  color: #344054;
  font-weight: 800;
}

.ghost-button:hover {
  background: #f2f5fa;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  background: #eef2f7;
  color: #263241;
  font-size: 21px;
}

.icon-button:hover {
  background: #e1e7ef;
}

.muted-text {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.file-actions,
.relation-list {
  display: grid;
  gap: 8px;
}

.count-badge {
  min-width: 27px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e9eef8;
  color: #36445c;
  font-size: 12px;
  font-weight: 850;
  text-align: center;
}

.relation-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid #dde3ec;
  border-radius: 8px;
  background: #ffffff;
}

.relation-summary {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.relation-swatch {
  width: 12px;
  height: 12px;
  border: 1px solid rgba(15, 23, 42, 0.22);
  border-radius: 50%;
}

.relation-item strong,
.relation-item span {
  display: block;
  min-width: 0;
}

.relation-item strong {
  font-size: 13px;
}

.relation-item span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.delete-button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  background: #fff1f2;
  color: var(--danger);
  font-size: 17px;
}

.workspace {
  position: relative;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  user-select: none;
  background-color: #edf2f8;
  background-image:
    linear-gradient(rgba(93, 110, 137, 0.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(93, 110, 137, 0.16) 1px, transparent 1px);
  background-size: 32px 32px;
}

.workspace-help {
  position: absolute;
  z-index: 4;
  right: 18px;
  top: 16px;
  padding: 7px 10px;
  border: 1px solid rgba(131, 145, 166, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  color: #667085;
  font-size: 11px;
  pointer-events: none;
}

.board,
.link-layer {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
}

.link-layer {
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.link-layer path {
  fill: none;
  stroke: #384252;
  stroke-width: 2.4;
  stroke-linecap: round;
}

.link-layer .draft-link {
  stroke-dasharray: 8 7;
  stroke-width: 2.8;
}

.link-layer text {
  font-size: 13px;
  font-weight: 850;
  pointer-events: none;
}

.link-label-bg {
  fill: rgba(255, 255, 255, 0.9);
  stroke-opacity: 0.45;
  stroke-width: 1;
}

.link-layer marker path {
  fill: context-stroke;
}

.board {
  z-index: 2;
}

.workspace.is-space-panning {
  cursor: grab;
}

.workspace.is-panning {
  cursor: grabbing;
}

.chart-node {
  position: absolute;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 11px 10px 10px;
  border: 1px solid rgba(51, 65, 85, 0.16);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.chart-node:active {
  cursor: grabbing;
}

.chart-node.is-source {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(49, 94, 251, 0.2), var(--shadow);
}

.chart-node.is-targetable {
  cursor: crosshair;
}

.chart-node.is-targetable:hover {
  border-color: var(--success);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.18), var(--shadow);
}

.person-card {
  width: max-content;
  min-width: 118px;
  min-height: 144px;
}

.person-card img,
.person-photo-placeholder {
  width: 82px;
  height: 82px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  object-fit: cover;
  background: #dfe5ee;
  box-shadow: 0 0 0 1px rgba(51, 65, 85, 0.22);
}

.person-photo-placeholder {
  display: grid;
  place-items: center;
  color: #3b485d;
  font-size: 30px;
  font-weight: 900;
}

.person-name,
.group-name {
  width: max-content;
  color: #172033;
  font-weight: 850;
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;
}

.person-name {
  font-size: 14px;
}

.group-card {
  align-content: center;
  width: max-content;
  min-width: 150px;
  min-height: 112px;
  padding: 16px 14px 14px;
  border-top: 6px solid var(--group-color, #16a34a);
}

.group-name {
  font-size: 16px;
}

.group-count,
.person-group {
  padding: 4px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--group-color, #16a34a) 16%, #ffffff);
  color: #233047;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.person-group {
  border: 1px solid color-mix(in srgb, var(--group-color, #16a34a) 35%, #ffffff);
}

.node-delete {
  position: absolute;
  top: 5px;
  right: 5px;
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.08);
  color: #39465a;
  cursor: pointer;
}

.node-delete:hover {
  background: #fee2e2;
  color: var(--danger);
}

.connect-button {
  position: absolute;
  right: -12px;
  top: 50%;
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  font-size: 22px;
  font-weight: 850;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(49, 94, 251, 0.28);
  cursor: crosshair;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) scale(0.88);
  transition: opacity 140ms ease, transform 140ms ease;
}

.chart-node:hover .connect-button,
.chart-node:focus-within .connect-button {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) scale(1);
}

.board.is-connecting .connect-button {
  display: none;
}

.relation-composer {
  position: absolute;
  z-index: 8;
  display: grid;
  gap: 11px;
  width: 288px;
  padding: 15px;
  border: 1px solid var(--panel-border);
  border-radius: 11px;
  background: #ffffff;
  box-shadow: var(--shadow);
  user-select: text;
}

.relation-composer strong {
  font-size: 14px;
}

.composer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.empty-state {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  justify-items: center;
  gap: 8px;
  width: min(430px, calc(100% - 40px));
  padding: 22px;
  border: 1px dashed #9aa8ba;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.76);
  color: #4b586d;
  text-align: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-bottom: 3px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 25px;
}

.empty-state strong {
  color: #1f2937;
  font-size: 18px;
}

.empty-state span {
  font-size: 13px;
  line-height: 1.45;
}

.toast {
  position: fixed;
  z-index: 30;
  right: 22px;
  bottom: 22px;
  max-width: 360px;
  padding: 13px 16px;
  border-radius: 10px;
  background: #172033;
  color: #ffffff;
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 700;
}

@media (max-width: 880px) {
  html,
  body {
    height: auto;
    overflow: auto;
  }

  .auth-view {
    grid-template-columns: 1fr;
  }

  .auth-intro {
    padding-bottom: 20px;
  }

  .auth-intro h1 {
    font-size: 39px;
  }

  .auth-card {
    margin-top: 20px;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(600px, 1fr);
    height: auto;
    min-height: 100vh;
  }

  .control-panel {
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--panel-border);
  }

  .workspace {
    min-height: 600px;
  }
}

@media (max-width: 520px) {
  .auth-intro {
    padding: 36px 24px 10px;
  }

  .auth-intro > p:not(.eyebrow),
  .feature-list {
    display: none;
  }

  .auth-card {
    width: calc(100% - 28px);
    padding: 24px;
  }

  .control-panel {
    padding: 16px;
  }

  .workspace-help {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
