:root {
  color-scheme: light;
  --background: #f7f8fc;
  --surface: #ffffff;
  --surface-soft: rgba(255, 255, 255, 0.7);
  --primary: #3f66ff;
  --primary-dark: #2747b6;
  --primary-ghost: rgba(63, 102, 255, 0.12);
  --text: #1f2433;
  --text-muted: #5a6376;
  --border: #d9deeb;
  --shadow: 0 18px 40px rgba(33, 42, 63, 0.12);
  font-family: "Pretendard", "Noto Sans KR", -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

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

body {
  margin: 0;
  color: var(--text);
  background: var(--background);
}

.app-body {
  min-height: 100vh;
  position: relative;
}

.gradient {
  position: fixed;
  inset: -20vh -20vw auto;
  height: 55vh;
  background: radial-gradient(
    circle at 20% 20%,
    rgba(63, 102, 255, 0.45),
    transparent 60%
  );
  z-index: -1;
  filter: blur(20px);
}

.top-bar {
  padding: 24px 6vw 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
}

.brand__symbol {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand__text {
  font-size: 1.05rem;
}

.top-bar__links {
  display: inline-flex;
  gap: 8px;
}

.link-button {
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  color: var(--primary);
  background: var(--primary-ghost);
  text-decoration: none;
  font-weight: 600;
  transition: transform 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}

.link-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(63, 102, 255, 0.18);
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

.shell {
  padding: 64px 6vw 80px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  align-items: center;
}

.card {
  max-width: 640px;
  width: 100%;
  background: var(--surface);
  padding: 40px clamp(24px, 5vw, 52px);
  border-radius: 32px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.card__header h1 {
  margin: 0;
  font-size: clamp(2rem, 2.6vw, 2.6rem);
}

.card__header p {
  margin: 12px 0 0;
  color: var(--text-muted);
  line-height: 1.6;
}

.form {
  margin-top: 36px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.form__field--checkbox {
  gap: 8px;
}

.form__checkbox {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.form__checkbox-input {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}

.form__hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.type-switcher {
  display: grid;
  gap: 24px;
  border: 1px solid rgba(63, 102, 255, 0.16);
  border-radius: 24px;
  padding: 24px clamp(18px, 4vw, 32px);
  background: rgba(255, 255, 255, 0.7);
}

.type-switcher__control {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.type-switcher__row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.type-switcher__select,
.type-switcher__input {
  min-width: 220px;
}

.type-switcher__action {
  padding: 12px 20px;
  border-radius: 16px;
  border: 1px solid rgba(63, 102, 255, 0.4);
  background: #fff;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.type-switcher__action:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(63, 102, 255, 0.16);
}

.type-switcher__action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.type-switcher__hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.pin-locked {
  overflow: hidden;
}

.pin-gate {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: clamp(24px, 6vw, 64px);
  background: rgba(18, 21, 33, 0.48);
  backdrop-filter: blur(10px);
  z-index: 2000;
}

.pin-locked .pin-gate {
  display: grid;
}

.pin-gate__card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 28px;
  box-shadow: 0 24px 48px rgba(31, 36, 51, 0.28);
  padding: clamp(28px, 7vw, 40px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  text-align: left;
}

.pin-gate__title {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 2rem);
}

.pin-gate__body {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.6;
}

.pin-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pin-form__input {
  font-size: 1rem;
  letter-spacing: 0.4em;
  text-align: center;
}

.pin-form__actions {
  display: flex;
  justify-content: center;
}

.pin-form__button {
  width: 100%;
}

.pin-form__feedback {
  min-height: 1.2em;
  margin: 0;
  text-align: center;
  font-size: 0.9rem;
  color: #d64545;
}

.form__field {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form__label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form__input {
  border-radius: 18px;
  border: 1px solid var(--border);
  padding: 15px 18px;
  font-size: 1rem;
  transition: border 0.2s ease, box-shadow 0.2s ease;
  font-family: inherit;
  resize: vertical;
}

.form__input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(63, 102, 255, 0.15);
}

.form__input--textarea {
  min-height: 160px;
}

.form__actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.primary-button {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border: none;
  border-radius: 18px;
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 28px rgba(63, 102, 255, 0.25);
}

.primary-button:active {
  transform: translateY(1px);
}

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

.primary-button[data-loading="true"] {
  position: relative;
  padding-right: 44px;
}

.button-spinner {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-top-color: #fff;
  display: inline-block;
  margin-left: 12px;
  animation: button-spinner-spin 0.8s linear infinite;
}

@keyframes button-spinner-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.form[data-submitting="true"] {
  position: relative;
  pointer-events: none;
}

.form[data-submitting="true"]::after {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(2px);
}

.primary-button--ghost {
  width: 100%;
  background: #fff;
  color: var(--primary);
  border: 1px solid rgba(63, 102, 255, 0.4);
  box-shadow: none;
}

.footnote {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

#save-status {
  width: 100%;
  text-align: right;
  margin-top: -12px;
}

#save-status[data-state="dirty"] {
  color: var(--primary-dark);
}

#save-status[data-state="success"] {
  color: #22863a;
}

#save-status[data-state="error"] {
  color: #d64545;
}

.dialog {
  border: none;
  padding: 32px clamp(24px, 6vw, 40px);
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 24px 48px rgba(33, 42, 63, 0.18);
  max-width: 420px;
}

.dialog::backdrop {
  background: rgba(16, 19, 30, 0.45);
}

.dialog__title {
  margin: 0 0 12px;
}

.dialog__body {
  margin: 0 0 24px;
  color: var(--text-muted);
  line-height: 1.6;
}

@media (max-width: 720px) {
  .top-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .shell {
    padding: 36px 4vw 60px;
  }

  .card {
    padding: 32px clamp(18px, 4vw, 28px);
  }

  .form__actions {
    justify-content: center;
  }

  .primary-button {
    width: 100%;
  }
}
