/* tokens */
:root {
  --bg: #111113;
  --surface: #1a1a1f;
  --border: #2a2a32;
  --accent: #7c6ef7;
  --accent-dim: rgba(124, 110, 247, 0.15);
  --text: #e8e8f0;
  --muted: #666680;
  --red: #e05c5c;
  --red-dim: rgba(224, 92, 92, 0.18);
  --green: #4ecb8d;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 14px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* buttons */
button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
  white-space: nowrap;
}
button:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
}
button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}
button.danger {
  color: var(--red);
}
button.danger:hover {
  background: var(--red-dim);
  border-color: var(--red);
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 500;
}
button.primary:hover {
  background: #6a5de0;
}

/* header */
header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  flex-wrap: wrap;
}
header h1 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.3px;
  margin-right: 4px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 4px;
}
.brand-logo {
  height: 22px;
  width: auto;
  display: block;
  border-radius: 50%;
}
.brand-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

/* separator */
.sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

/* open-pdf label */
#open-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition:
    background 0.15s,
    border-color 0.15s;
}
#open-btn:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
}
#open-btn input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* color swatches */
.color-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.color-row label {
  color: var(--muted);
  font-size: 12px;
}

.swatch {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.1s;
  flex-shrink: 0;
}
.swatch.active {
  border-color: var(--text);
}
.swatch.black {
  background: #000;
}
.swatch.white {
  background: #fff;
  border: 2px solid #333;
}
.swatch.custom {
  background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
}

#custom-color {
  display: none;
  width: 22px;
  height: 22px;
  border: none;
  padding: 0;
  cursor: pointer;
  background: none;
}

/* page nav */
.page-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.page-nav span {
  color: var(--muted);
  font-size: 13px;
}
#page-info {
  font-weight: 500;
  color: var(--text);
  min-width: 60px;
  text-align: center;
}

/* main */
main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* sidebar */
aside {
  width: 200px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}
aside h2 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
aside footer {
  border-top: 1px solid var(--border);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* redaction list */
#redaction-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#empty-hint {
  color: var(--muted);
  font-size: 12px;
  padding: 12px;
  text-align: center;
  line-height: 1.6;
}

.redaction-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.redaction-item .ri-label {
  flex: 1;
  color: var(--muted);
}
.redaction-item .ri-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.redaction-item .ri-del {
  cursor: pointer;
  color: var(--red);
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  border: none;
  background: none;
}
.redaction-item .ri-del:hover {
  color: #ff8080;
}

/* canvas area */
#canvas-area {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
  background: #0d0d0f;
}
#canvas-wrapper {
  position: relative;
  display: inline-block;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.7);
  flex-shrink: 0;
}
#pdf-canvas {
  display: block;
}
#draw-canvas {
  position: absolute;
  inset: 0;
  cursor: crosshair;
}

/* drop zone */
#drop-zone {
  position: fixed;
  inset: 0;
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='160'%3E%3Crect x='28' y='30' width='130' height='6' fill='rgba(255,255,255,0.05)'/%3E%3Crect x='28' y='48' width='90' height='6' fill='rgba(255,255,255,0.05)'/%3E%3Crect x='28' y='66' width='112' height='6' fill='rgba(124,110,247,0.16)'/%3E%3Crect x='28' y='84' width='70' height='6' fill='rgba(255,255,255,0.05)'/%3E%3Crect x='28' y='102' width='100' height='6' fill='rgba(255,255,255,0.05)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 240px 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 100;
}
#drop-zone.hidden {
  display: none;
}
#drop-zone.drag-over {
  background-color: rgba(124, 110, 247, 0.06);
}

.drop-logo {
  height: 30px;
  width: auto;
  opacity: 0.9;
}

.drop-icon {
  font-size: 52px;
  line-height: 1;
  color: var(--muted);
}
.drop-title {
  font-size: 22px;
  font-weight: 600;
}
.drop-sub {
  color: var(--muted);
  font-size: 14px;
}

.privacy-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  letter-spacing: 0.2px;
  color: var(--muted);
}
.privacy-line i {
  font-size: 11px;
  color: var(--muted);
}

.drop-or {
  color: var(--muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.drop-or::before,
.drop-or::after {
  content: "";
  display: block;
  width: 60px;
  height: 1px;
  background: var(--border);
}

#drop-file-btn {
  padding: 10px 22px;
  font-size: 14px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
#drop-file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* status bar */
#status-bar {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

/* toast */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--green);
  color: #0a1a10;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 8px;
  opacity: 0;
  transition:
    opacity 0.25s,
    transform 0.25s;
  z-index: 200;
  pointer-events: none;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── responsive ── */

/* large desktop */
@media (min-width: 1280px) {
  aside {
    width: 240px;
  }
  #canvas-area {
    padding: 32px;
  }
}

/* tablet landscape */
@media (max-width: 1024px) {
  aside {
    width: 180px;
  }
  header {
    gap: 8px;
    padding: 8px 12px;
  }
  #canvas-area {
    padding: 16px;
  }
}

/* tablet portrait — sidebar moves to bottom */
@media (max-width: 768px) {
  header {
    gap: 8px;
    padding: 8px 12px;
    row-gap: 8px;
  }
  header h1 {
    font-size: 14px;
  }
  header .sep {
    display: none;
  }
  .page-nav {
    margin-left: 0;
  }

  main {
    flex-direction: column;
  }

  aside {
    width: 100%;
    height: auto;
    max-height: 180px;
    border-right: none;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
  }
  aside h2 {
    padding: 8px 14px 6px;
  }
  aside footer {
    flex-direction: row;
    gap: 8px;
    padding: 8px 10px;
  }
  aside footer button {
    flex: 1;
    justify-content: center;
  }

  #redaction-list {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 6px 8px;
    gap: 6px;
  }
  .redaction-item {
    flex-shrink: 0;
    min-width: 140px;
  }

  #canvas-area {
    flex: 1;
    padding: 12px;
    align-items: flex-start;
  }

  .drop-logo {
    height: 26px;
  }
  .drop-title {
    font-size: 18px;
  }
  .drop-icon {
    font-size: 40px;
  }
}

/* mobile landscape */
@media (max-width: 640px) {
  header {
    padding: 6px 10px;
    gap: 6px;
  }
  header h1 {
    font-size: 13px;
  }
  header h1 img {
    height: 19px;
  }
  #open-btn,
  button {
    padding: 5px 9px;
    font-size: 12px;
  }
  .swatch {
    width: 18px;
    height: 18px;
  }
  #page-info {
    min-width: 44px;
    font-size: 12px;
  }
  .color-row label {
    display: none;
  }
  aside {
    max-height: 150px;
  }
  #canvas-area {
    padding: 8px;
  }
  #status-bar {
    font-size: 11px;
    padding: 4px 10px;
  }
}

/* mobile portrait */
@media (max-width: 480px) {
  header {
    padding: 6px 8px;
    gap: 5px;
  }
  header h1 {
    font-size: 12px;
    margin-right: 0;
  }
  header h1 img {
    height: 17px;
  }
  #open-btn {
    padding: 5px 8px;
    font-size: 12px;
  }

  #prev-btn .btn-label,
  #next-btn .btn-label {
    display: none;
  }
  #prev-btn,
  #next-btn {
    padding: 5px 8px;
    min-width: 32px;
    justify-content: center;
  }
  .page-nav {
    gap: 4px;
  }
  .color-row {
    gap: 6px;
  }

  aside {
    max-height: 130px;
  }
  aside footer button {
    font-size: 12px;
    padding: 5px 8px;
  }

  #canvas-area {
    padding: 6px;
  }

  .drop-logo {
    height: 24px;
  }
  .drop-icon {
    font-size: 32px;
  }
  .drop-title {
    font-size: 16px;
    text-align: center;
  }
  .drop-sub {
    font-size: 12px;
    text-align: center;
    max-width: 260px;
  }
  .privacy-line {
    font-size: 11px;
    text-align: center;
    max-width: 280px;
  }
  .drop-or::before,
  .drop-or::after {
    width: 40px;
  }
  #drop-file-btn {
    padding: 9px 18px;
    font-size: 13px;
  }

  #toast {
    font-size: 12px;
    padding: 8px 14px;
    bottom: 16px;
    width: calc(100% - 32px);
    text-align: center;
  }
}

/* very small */
@media (max-width: 360px) {
  header h1 {
    display: none;
  }
  aside {
    max-height: 120px;
  }
  aside h2 {
    display: none;
  }
  #status-bar {
    display: none;
  }
}

/* touch devices */
@media (pointer: coarse) {
  button,
  #open-btn,
  #drop-file-btn,
  .swatch,
  .ri-del {
    min-height: 40px;
    min-width: 40px;
  }
  .swatch {
    width: 28px;
    height: 28px;
    border-radius: 6px;
  }
  #draw-canvas {
    cursor: default;
  }
}
