:root {
  --paper: #e4eaf1;
  --surface: #f4f7fa;
  --ink: #18212b;
  --muted: #5e6e82;
  --line: #c5d0de;
  --cobalt: #2b5cff;
  --cobalt-soft: rgba(43, 92, 255, 0.12);
  --done: #3d7a5a;
  --danger: #b42318;
  --shadow: 0 18px 40px rgba(24, 33, 43, 0.08);
  --radius: 18px;
  --font-display: 'Bricolage Grotesque', Georgia, serif;
  --font-body: 'Source Sans 3', 'Segoe UI', sans-serif;
  color: var(--ink);
  font-family: var(--font-body);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(43, 92, 255, 0.12), transparent 55%),
    radial-gradient(900px 420px at 100% 0%, rgba(61, 122, 90, 0.1), transparent 50%),
    linear-gradient(180deg, #dce4ee 0%, var(--paper) 42%, #d7e0ea 100%);
}

button,
input {
  font: inherit;
}

.shell {
  min-height: 100%;
  display: grid;
  grid-template-columns: 18px 1fr;
}

.spine {
  background: linear-gradient(180deg, #1f2a38, #2b5cff 48%, #1f2a38);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.18);
}

.page {
  max-width: 680px;
  width: min(100%, 680px);
  margin: 0 auto;
  padding: 36px 28px 48px;
}

.hero {
  margin-bottom: 28px;
  animation: rise 480ms ease both;
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.hero-top .brand {
  margin: 0;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.hero-btn {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.sync-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: rgba(24, 33, 43, 0.06);
  border: 1px solid var(--line);
}

.sync-badge.is-remote {
  color: var(--cobalt);
  background: var(--cobalt-soft);
  border-color: rgba(43, 92, 255, 0.28);
}

.sync-panel {
  gap: 14px;
  max-width: 440px;
}

.sync-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}

.sync-field-stack {
  display: grid;
  gap: 6px;
  justify-content: stretch;
}

.sync-field-stack input[type='url'],
.sync-field-stack input[type='password'],
.sync-field-stack input[type='text'] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.sync-field-stack input:focus {
  border-color: var(--cobalt);
  box-shadow: 0 0 0 3px var(--cobalt-soft);
}

.sync-msg {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(43, 92, 255, 0.08);
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.45;
}

.sync-actions {
  flex-wrap: wrap;
}

.brand {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cobalt);
}

.hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.lede {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.composer {
  display: grid;
  gap: 10px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: rise 560ms ease both;
}

.composer-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.composer-draft {
  display: grid;
  gap: 8px;
  padding: 8px;
  border-radius: 12px;
  background: rgba(43, 92, 255, 0.06);
  border: 1px dashed rgba(43, 92, 255, 0.28);
}

.composer-draft-tip {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.composer input {
  border: 0;
  outline: none;
  background: transparent;
  padding: 12px 14px;
  font-size: 1.05rem;
  color: var(--ink);
}

.composer input::placeholder {
  color: #8a97a8;
}

.composer button,
.filters button,
.footer button,
.remove {
  border: 0;
  cursor: pointer;
  border-radius: 12px;
  transition:
    transform 140ms ease,
    background 140ms ease,
    color 140ms ease,
    opacity 140ms ease;
}

.composer-row > button {
  padding: 0 18px;
  background: var(--cobalt);
  color: #fff;
  font-weight: 600;
}

.composer-row > button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.composer-row > button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.thumb-wrap.static {
  cursor: default;
}

.thumb-wrap.static:hover {
  outline: none;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(8, 12, 20, 0.92);
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: stretch;
  justify-items: stretch;
  padding: 12px 16px 10px;
  animation: rise 160ms ease both;
}

.lightbox-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  z-index: 2;
}

.lightbox-zoom,
.lightbox-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.lightbox-close,
.lightbox-copy,
.lightbox-tool {
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}

.lightbox-tool {
  min-width: 40px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.lightbox-zoom-label {
  color: rgba(255, 255, 255, 0.85);
  font-variant-numeric: tabular-nums;
  min-width: 3.5em;
  text-align: center;
  font-size: 0.9rem;
}

.lightbox-close {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.lightbox-copy {
  background: #2b5cff;
  color: #fff;
}

.lightbox-close:hover,
.lightbox-copy:hover,
.lightbox-tool:hover {
  filter: brightness(1.08);
}

.lightbox-stage {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 14px;
  touch-action: none;
  user-select: none;
}

.lightbox-stage.is-zoomed {
  cursor: grab;
}

.lightbox-stage.is-zoomed:active {
  cursor: grabbing;
}

.lightbox-img {
  max-width: min(98vw, 1600px);
  max-height: min(82vh, 1200px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  background: #0f1520;
  transform-origin: center center;
  transition: transform 60ms linear;
  will-change: transform;
}

.lightbox-hint {
  margin: 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.82rem;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 22px 0 14px;
  flex-wrap: wrap;
  animation: rise 640ms ease both;
}

.filters {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: rgba(244, 247, 250, 0.8);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.filters button {
  padding: 8px 14px;
  background: transparent;
  color: var(--muted);
}

.filters button.is-active {
  background: var(--ink);
  color: #fff;
}

.stats {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.stats strong {
  color: var(--ink);
  font-weight: 600;
}

.list ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.row {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: start;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(244, 247, 250, 0.92);
  border: 1px solid var(--line);
  border-radius: 14px;
  animation: rise 420ms ease both;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    opacity 140ms ease,
    transform 140ms ease;
}

.row .check {
  margin-top: 2px;
}

.drag-handle {
  margin-top: 4px;
  width: 22px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #9aa8b8;
  font-size: 0.78rem;
  letter-spacing: -0.12em;
  line-height: 1;
  cursor: grab;
  user-select: none;
  opacity: 0.55;
  transition:
    opacity 140ms ease,
    color 140ms ease,
    background 140ms ease;
}

.drag-handle:hover,
.row:hover .drag-handle,
.row:focus-within .drag-handle {
  opacity: 1;
  color: var(--muted);
  background: rgba(24, 33, 43, 0.05);
}

.drag-handle:active {
  cursor: grabbing;
}

.row.is-dragging {
  opacity: 0.45;
  transform: scale(0.985);
}

.row.is-drop-target {
  border-color: rgba(43, 92, 255, 0.45);
  box-shadow: 0 0 0 3px var(--cobalt-soft);
}

.body {
  min-width: 0;
  display: grid;
  gap: 10px;
}

.gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.thumb-card {
  position: relative;
  max-width: min(100%, 220px);
}

.thumb-wrap {
  display: block;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 12px;
  overflow: hidden;
  width: 100%;
}

.thumb-wrap:hover {
  outline: 2px solid var(--cobalt-soft);
}

.thumb {
  display: block;
  width: 100%;
  max-height: 160px;
  height: auto;
  object-fit: cover;
  border-radius: 12px;
  background: rgba(24, 33, 43, 0.04);
  border: 1px solid var(--line);
}

.thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 999px;
  background: rgba(24, 33, 43, 0.72);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 140ms ease;
}

.thumb-card:hover .thumb-remove,
.row:focus-within .thumb-remove {
  opacity: 1;
}

.image-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ghost-link {
  border: 0;
  background: transparent;
  color: var(--cobalt);
  padding: 0;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.ghost-link:hover {
  text-decoration: underline;
}

.image-count {
  color: var(--muted);
  font-size: 0.85rem;
}

.row.is-editing {
  border-color: rgba(43, 92, 255, 0.35);
  box-shadow: 0 0 0 3px var(--cobalt-soft);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #18212b;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: 0 10px 28px rgba(24, 33, 43, 0.28);
  z-index: 90;
  font-size: 0.92rem;
  animation: rise 200ms ease both;
}

.check {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: #fff;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
}

.check span {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: transparent;
  transform: scale(0.4);
  transition:
    transform 160ms ease,
    background 160ms ease;
}

.row.is-done .check {
  border-color: var(--done);
  background: rgba(61, 122, 90, 0.12);
}

.row.is-done .check span {
  background: var(--done);
  transform: scale(1);
}

.text {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 4px 0;
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1.4;
  cursor: text;
  white-space: pre-wrap;
  word-break: break-word;
}

.text.is-placeholder {
  color: #8a97a8;
  font-size: 0.95rem;
}

.row.has-image .text {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px dashed transparent;
}

.row.has-image .text:hover,
.row.has-image .text.is-placeholder {
  border-color: var(--line);
}

.row.is-done .text {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}

.row.is-done .text.is-placeholder {
  text-decoration: none;
  opacity: 0.8;
}

.edit {
  width: 100%;
  border: 1px solid var(--cobalt);
  border-radius: 10px;
  padding: 8px 10px;
  outline: none;
  background: #fff;
  box-shadow: 0 0 0 3px var(--cobalt-soft);
}

.remove {
  opacity: 0;
  background: transparent;
  color: var(--danger);
  padding: 6px 8px;
  font-size: 0.9rem;
}

.row:hover .remove,
.row:focus-within .remove {
  opacity: 1;
}

.empty {
  margin: 28px 0;
  padding: 28px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(244, 247, 250, 0.55);
}

.footer {
  margin-top: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.92rem;
  min-height: 36px;
}

.footer button {
  padding: 8px 12px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.footer button:hover {
  color: var(--danger);
  border-color: rgba(180, 35, 24, 0.35);
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.import-btn {
  border: 1px solid var(--line);
  background: rgba(244, 247, 250, 0.8);
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 600;
  transition:
    background 140ms ease,
    color 140ms ease,
    border-color 140ms ease;
}

.import-btn:hover {
  background: var(--cobalt-soft);
  color: var(--cobalt);
  border-color: rgba(43, 92, 255, 0.35);
}

.import-modal {
  position: fixed;
  inset: 0;
  z-index: 85;
  background: rgba(8, 12, 20, 0.55);
  display: grid;
  place-items: center;
  padding: 20px;
  animation: rise 160ms ease both;
}

.import-panel {
  width: min(100%, 520px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(24, 33, 43, 0.25);
  padding: 24px;
  display: grid;
  gap: 12px;
}

.import-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ink);
}

.import-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.import-textarea {
  width: 100%;
  min-height: 200px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease;
}

.import-textarea:focus {
  border-color: var(--cobalt);
  box-shadow: 0 0 0 3px var(--cobalt-soft);
}

.import-textarea::placeholder {
  color: #a0adbd;
}

.import-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.import-cancel,
.import-confirm {
  border: 0;
  border-radius: 12px;
  padding: 10px 20px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  transition:
    transform 140ms ease,
    background 140ms ease,
    opacity 140ms ease;
}

.import-cancel {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.import-cancel:hover {
  color: var(--ink);
  border-color: var(--muted);
}

.import-confirm {
  background: var(--cobalt);
  color: #fff;
}

.import-confirm:hover:not(:disabled) {
  transform: translateY(-1px);
}

.import-confirm:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.import-shortcut {
  margin: 0;
  text-align: right;
  color: var(--muted);
  font-size: 0.82rem;
}

.toolbar-ghost {
  border: 1px solid var(--line);
  background: rgba(244, 247, 250, 0.8);
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 600;
  transition:
    background 140ms ease,
    color 140ms ease,
    border-color 140ms ease;
}

.toolbar-ghost:hover:not(:disabled) {
  background: var(--cobalt-soft);
  color: var(--cobalt);
  border-color: rgba(43, 92, 255, 0.35);
}

.toolbar-ghost:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.backup-panel {
  gap: 14px;
}

.backup-path {
  margin: 0;
  padding: 8px 10px;
  font-size: 0.82rem;
  color: var(--muted);
  background: rgba(24, 33, 43, 0.04);
  border-radius: 8px;
  word-break: break-all;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

.backup-error {
  color: var(--danger);
  font-weight: 600;
}

.backup-modes {
  display: grid;
  gap: 8px;
}

.backup-mode {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.6);
  transition:
    border-color 140ms ease,
    background 140ms ease;
}

.backup-mode:hover {
  border-color: rgba(43, 92, 255, 0.35);
}

.backup-mode.is-active {
  border-color: var(--cobalt);
  background: var(--cobalt-soft);
}

.backup-mode input[type='radio'] {
  grid-row: 1 / span 2;
  margin: 0;
  accent-color: var(--cobalt);
  width: 16px;
  height: 16px;
}

.backup-mode-title {
  font-weight: 600;
  color: var(--ink);
  font-size: 0.95rem;
}

.backup-mode-desc {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 560px) {
  .page {
    padding: 24px 16px 36px;
  }

  .composer-row {
    grid-template-columns: 1fr;
  }

  .composer-row > button {
    height: 44px;
  }

  .remove {
    opacity: 1;
  }
}
