/* ─── RESET ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f7f7f7;
  color: #111;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; }
input, select { font-family: inherit; }

/* ─── HEADER ─── */
header {
  background: #fff;
  border-bottom: 1px solid #e5e5e5;
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 24px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #111;
}
.logo-icon {
  width: 32px;
  height: 32px;
  background: #e53e3e;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
}
.logo em { font-style: normal; color: #e53e3e; }
.back-link {
  font-size: 0.82rem;
  font-weight: 500;
  color: #888;
  transition: color 0.15s;
  display: flex;
  align-items: center;
  gap: 4px;
}
.back-link:hover { color: #111; }

/* ─── MAIN ─── */
.tool-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 36px 24px 80px;
}

/* ─── TOOL HERO ─── */
.tool-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
  padding: 20px 24px;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 14px;
}
.tool-hero-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: var(--accent-bg, #fff5f5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
}
.tool-title { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 2px; }
.tool-subtitle { font-size: 0.85rem; color: #777; }

/* ─── DROP ZONE ─── */
.drop-zone {
  background: #fff;
  border: 2px dashed #d4d4d4;
  border-radius: 16px;
  padding: 56px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 0;
}
.drop-zone:hover, .drop-zone.dz-hover {
  border-color: var(--accent, #e53e3e);
  background: var(--accent-bg, #fff5f5);
}
.dz-icon { font-size: 2.5rem; margin-bottom: 14px; }
.dz-title { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 6px; }
.dz-sub { font-size: 0.85rem; color: #999; margin-bottom: 20px; }
.dz-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 12px 26px;
  background: var(--accent, #e53e3e);
  color: #fff;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 16px;
  transition: opacity 0.15s;
}
.dz-btn:hover { opacity: 0.88; }
.dz-privacy {
  font-size: 0.75rem;
  color: #aaa;
}

/* ─── CARD ─── */
.card {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 16px;
  padding: 24px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.card-title { font-size: 1rem; font-weight: 700; letter-spacing: -0.02em; }

/* ─── BADGE ─── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid #e5e5e5;
  background: #f5f5f5;
  color: #555;
}

/* ─── BUTTONS ─── */
.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--accent, #e53e3e);
  color: #fff;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.15s, transform 0.15s;
  margin-top: 18px;
}
.btn-primary:hover:not(:disabled) { opacity: 0.88; transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; }

.btn-ghost {
  padding: 7px 14px;
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
  color: #555;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.12s;
  cursor: pointer;
}
.btn-ghost:hover { background: #eee; color: #111; }

/* ─── FILE LIST ─── */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 4px;
}
.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #fafafa;
  border: 1px solid #efefef;
  border-radius: 10px;
  font-size: 0.84rem;
}
.fi-num {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: #fee2e2;
  color: #e53e3e;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.fi-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.fi-size { font-size: 0.72rem; color: #aaa; flex-shrink: 0; }
.fi-actions { display: flex; gap: 4px; }

.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: #f0f0f0;
  border: 1px solid #e0e0e0;
  color: #666;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.12s;
  flex-shrink: 0;
}
.icon-btn:hover { background: #e5e5e5; color: #111; }
.icon-btn.danger:hover { background: #fee2e2; color: #e53e3e; border-color: #fca5a5; }
.icon-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ─── FORM FIELDS ─── */
.field-group { margin-bottom: 16px; }
.field-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #999;
  margin-bottom: 7px;
}
.field-input {
  width: 100%;
  padding: 11px 14px;
  background: #fafafa;
  border: 1.5px solid #e0e0e0;
  border-radius: 10px;
  color: #111;
  font-size: 0.9rem;
  transition: border-color 0.15s;
  font-family: inherit;
}
.field-input:focus { outline: none; border-color: var(--accent, #e53e3e); background: #fff; }
.field-input::placeholder { color: #bbb; }
.field-input[type='password'] { letter-spacing: 0.08em; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 0;
  cursor: pointer;
  font-size: 0.87rem;
  color: #444;
  user-select: none;
  border-bottom: 1px solid #f5f5f5;
}
.checkbox-row:last-child { border-bottom: none; }
.checkbox-row input[type='checkbox'] { accent-color: var(--accent, #e53e3e); width: 15px; height: 15px; cursor: pointer; flex-shrink: 0; }
.checkbox-row:hover { color: #111; }

.divider { height: 1px; background: #f0f0f0; margin: 18px 0; }

.hint-text { font-size: 0.78rem; color: #aaa; margin-top: 6px; line-height: 1.5; }

/* ─── PROGRESS ─── */
.progress-wrap { display: none; margin: 14px 0 4px; }
.progress-wrap.show { display: block; }
.progress-bar { height: 4px; background: #f0f0f0; border-radius: 99px; overflow: hidden; margin-bottom: 8px; }
.progress-fill { height: 100%; background: var(--accent, #e53e3e); border-radius: 99px; width: 0%; transition: width 0.3s ease; }
.progress-label { font-size: 0.8rem; color: #999; text-align: center; }

/* ─── PAGE GRID ─── */
.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
  max-height: 340px;
  overflow-y: auto;
  margin-bottom: 8px;
}
.page-card {
  background: #fafafa;
  border: 2px solid #e5e5e5;
  border-radius: 10px;
  padding: 8px;
  text-align: center;
  cursor: grab;
  user-select: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  position: relative;
}
.page-card:hover { border-color: #aaa; box-shadow: 0 4px 12px rgba(0,0,0,0.07); }
.page-card.dragging { opacity: 0.3; border-style: dashed; }
.page-card.over { border-color: var(--accent, #e53e3e); background: #fff5f5; }
.page-preview {
  width: 100%;
  aspect-ratio: 3/4;
  background: #fff;
  border-radius: 5px;
  margin-bottom: 6px;
  overflow: hidden;
  border: 1px solid #efefef;
}
.page-preview canvas { width: 100% !important; height: 100% !important; display: block; }
.page-num-label { font-size: 0.67rem; color: #999; font-variant-numeric: tabular-nums; }
.page-del-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  background: #e53e3e;
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 0.58rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.page-card:hover .page-del-btn { display: flex; }

/* ─── HIDDEN ─── */
.hidden { display: none !important; }

/* ─── TOAST ─── */
#toast-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast-item {
  padding: 11px 18px;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #111;
  box-shadow: 0 4px 24px rgba(0,0,0,0.10);
  animation: toast-in 0.25s cubic-bezier(0.34,1.56,0.64,1) both;
  pointer-events: auto;
}
.toast-item.success { border-color: #bbf7d0; color: #16a34a; }
.toast-item.error { border-color: #fecaca; color: #e53e3e; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px) scale(0.95); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 600px) {
  .tool-main { padding: 24px 16px 60px; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .tool-hero { flex-direction: column; text-align: center; }
}
