@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --ink: #1a2233;
  --muted: #5b6675;
  --line: #e1e5eb;
  --accent: #1f8a5f;
  --accent-dark: #146645;
  --accent-light: #e8f6ef;
  --bg: #f4f6f8;
  --card: #ffffff;
  --danger: #b3261e;
  --danger-bg: #fbeceb;
  --shadow-sm: 0 1px 2px rgba(20, 30, 45, 0.05), 0 1px 1px rgba(20, 30, 45, 0.04);
  --shadow-md: 0 6px 20px rgba(20, 40, 35, 0.07), 0 2px 6px rgba(20, 40, 35, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background:
    radial-gradient(720px 360px at 12% -8%, #e9f6ef 0%, rgba(233,246,239,0) 60%),
    var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

header.top {
  margin-bottom: 32px;
}

header.top h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
}

header.top p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
  max-width: 56ch;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px;
  box-shadow: var(--shadow-md);
}

.dropzone {
  display: block;
  border: 2px dashed var(--line);
  border-radius: 10px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: #f2f8f4;
}

.dropzone .icon {
  font-size: 32px;
  margin-bottom: 10px;
}

.dropzone .primary {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.dropzone .secondary {
  font-size: 13px;
  color: var(--muted);
}

.or-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--muted);
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.or-divider::before,
.or-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.folder-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 20px;
  background: var(--card);
  border: 2px dashed var(--line);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.folder-btn:hover,
.folder-btn:focus-visible {
  border-color: var(--accent);
  background: #f2f8f4;
}

.folder-btn-icon {
  font-size: 28px;
  line-height: 1;
  flex-shrink: 0;
}

.folder-btn-title {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 2px;
}

.folder-btn-sub {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
}

.filename {
  margin-top: 16px;
  font-size: 14px;
  padding: 10px 14px;
  background: #f2f8f4;
  border: 1px solid #cfe6d9;
  border-radius: 8px;
  display: none;
}

.filename.visible { display: block; }

input[type="file"] { display: none; }

button.primary {
  margin-top: 20px;
  width: 100%;
  padding: 14px 20px;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: white;
  border: none;
  border-radius: 9px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(20, 102, 69, 0.28);
  transition: transform 0.1s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

button.primary:hover { filter: brightness(1.06); box-shadow: 0 4px 12px rgba(20, 102, 69, 0.34); }
button.primary:active { transform: translateY(1px); }

button.primary:disabled {
  background: #a9b3ab;
  box-shadow: none;
  cursor: not-allowed;
}

.error {
  margin-bottom: 20px;
  padding: 12px 16px;
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 8px;
  font-size: 14px;
}

.section-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 10px;
}

.type-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.type-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13.5px;
  cursor: pointer;
  background: var(--card);
}

.type-option:has(input:checked) {
  border-color: var(--accent);
  background: #f2f8f4;
  color: var(--accent-dark);
  font-weight: 600;
}

.type-option input { accent-color: var(--accent); }

.extras-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-bottom: 24px;
}

.extra-option {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  cursor: pointer;
}

.extra-option input { accent-color: var(--accent); }

.speed-hint {
  margin: -8px 0 24px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

.keywords {
  margin-top: 28px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

.keywords code {
  background: #eef0f3;
  padding: 1px 5px;
  border-radius: 4px;
}

.progress-count {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
}

.progress-track {
  width: 100%;
  height: 14px;
  background: #eef0f3;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.progress-sub {
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
}

.progress-eta {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-dark);
  min-height: 1.2em;
}

.summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: #f2f8f4;
  border: 1px solid #cfe6d9;
  border-radius: 10px;
  margin-bottom: 24px;
  font-size: 14px;
}

.summary .badge {
  font-size: 20px;
}

.download-btn {
  display: block;
  text-align: center;
  width: 100%;
  padding: 14px 20px;
  background: var(--accent);
  color: white;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  margin-bottom: 28px;
}

.download-btn:hover { background: var(--accent-dark); }

.retention-notice {
  margin: -14px 0 24px;
  padding: 12px 16px;
  background: #fff8ec;
  border: 1px solid #f0dfb8;
  border-radius: 8px;
  color: #7a5c1e;
  font-size: 13px;
  line-height: 1.5;
}

.previews {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.previews img {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
}

.page-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.back-link {
  display: inline-block;
  margin-top: 28px;
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
}

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

.disclaimer {
  margin-top: 28px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

.page.wide {
  max-width: 1080px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}

.grid-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--card);
  display: flex;
  flex-direction: column;
}

.grid-thumb {
  display: block;
  height: 180px;
  background: #f2f3f5;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.grid-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  display: block;
}

.grid-info {
  padding: 12px 14px 4px;
}

.grid-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.grid-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}

.grid-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px 14px;
  margin-top: auto;
  font-size: 13px;
}

.grid-view {
  color: var(--accent);
  text-decoration: none;
}

.grid-view:hover { text-decoration: underline; }

.grid-download {
  color: white;
  background: var(--accent);
  padding: 5px 12px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  font-size: 12.5px;
}

.grid-download:hover { background: var(--accent-dark); }

/* ---- nav ---- */

.topnav {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 24px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  font-size: 13.5px;
  overflow-x: auto;
}

.topnav .brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  color: var(--ink);
  text-decoration: none;
  font-size: 15.5px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  flex-shrink: 0;
}

.topnav .brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(155deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: white;
  flex-shrink: 0;
}

.topnav .brand-mark svg { width: 15px; height: 15px; }

.topnav-links {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.topnav-links a {
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.topnav-links a:hover { color: var(--accent-dark); }

.topnav-active-batch {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: #f2f8f4;
  border: 1px solid #cfe6d9;
  border-radius: 999px;
  color: var(--accent-dark) !important;
  font-weight: 600;
  font-size: 12.5px;
}

.topnav-active-batch:hover {
  background: #e3f1e8;
}

.topnav-trial {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  background: #fdf6e8;
  border: 1px solid #ecdbab;
  border-radius: 999px;
  color: #8a6a1f !important;
  font-weight: 600;
  font-size: 12.5px;
}

.topnav-trial:hover { background: #faecc8; }

.topnav-user {
  color: var(--muted);
  padding-left: 6px;
  border-left: 1px solid var(--line);
}

/* ---- auth forms ---- */

.page.narrow { max-width: 420px; }

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

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}

.auth-form input {
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 400;
}

.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.auth-form .hint {
  margin-top: -10px;
  font-size: 12px;
  color: var(--muted);
}

.checkbox-line {
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  font-weight: 400 !important;
  color: var(--muted);
}

.checkbox-line input { margin-top: 2px; flex-shrink: 0; }
.checkbox-line a { color: var(--accent-dark); }

.policy-text h3 {
  font-size: 14.5px;
  margin: 20px 0 6px;
}

.policy-text h3:first-child { margin-top: 0; }

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

.policy-text a { color: var(--accent-dark); }

.button-link {
  display: block;
  text-align: center;
  margin-top: 4px;
  padding: 14px 20px;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: white !important;
  text-decoration: none;
  border-radius: 9px;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(20, 102, 69, 0.28);
}

.button-link:hover { filter: brightness(1.06); }

.auth-switch {
  margin-top: 18px;
  font-size: 13.5px;
  color: var(--muted);
  text-align: center;
}

.auth-switch a { color: var(--accent); }

/* ---- file list ---- */

.filelist {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.filelist-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  background: var(--card);
}

.filelist-name a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}

.filelist-name a:hover { color: var(--accent-dark); }

/* ---- manual masking (result page buttons + editor) ---- */

.result-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 10px;
  margin-bottom: 28px;
}
.result-actions .download-btn { flex: 1 1 260px; width: auto; margin-bottom: 0; }
.result-actions form { margin: 0; display: flex; }
.edit-btn {
  display: flex; align-items: center; justify-content: center;
  padding: 14px 20px;
  background: var(--card);
  color: var(--accent-dark);
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  font-size: 15px; font-weight: 600;
  text-decoration: none;
}
.edit-btn:hover { background: var(--accent-light); }
.link-btn {
  background: none; border: none; padding: 0 6px;
  color: var(--muted); font: inherit; font-size: 13px;
  text-decoration: underline; cursor: pointer;
}
.link-btn:hover { color: var(--danger); }

.editor-bar {
  position: sticky; top: 56px; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 10px 14px; margin-bottom: 16px;
  background: var(--card);
  border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-sm);
}
.editor-bar .count { font-size: 14px; color: var(--muted); flex: 1 1 160px; }
.editor-bar button {
  font: inherit; font-size: 14px; font-weight: 600;
  padding: 9px 16px; border-radius: 8px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
}
.editor-bar button:disabled { opacity: 0.45; cursor: not-allowed; }
.editor-bar button.apply {
  background: var(--accent); border-color: var(--accent-dark); color: #fff;
}
.editor-bar button.apply:hover:not(:disabled) { background: var(--accent-dark); }
.editor-help { font-size: 14px; color: var(--muted); margin: 0 0 14px; line-height: 1.5; }
.editor-msg { margin: 0 0 14px; }

.edit-page { margin-bottom: 22px; }
.edit-canvas {
  position: relative; display: block; width: 100%;
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  background: #fff; min-height: 120px;
  cursor: crosshair; user-select: none; -webkit-user-select: none;
}
.edit-canvas img { display: block; width: 100%; height: auto; pointer-events: none; -webkit-user-drag: none; }
.edit-canvas.touch-draw { touch-action: none; }
.edit-box {
  position: absolute; background: rgba(0, 0, 0, 0.82);
  outline: 2px solid var(--danger);
}
.edit-box.draft { background: rgba(179, 38, 30, 0.25); outline: 2px dashed var(--danger); }
.edit-box .del {
  position: absolute; top: -1px; right: -1px;
  width: 22px; height: 22px; line-height: 20px; padding: 0;
  background: var(--danger); color: #fff; border: none; border-radius: 0 0 0 6px;
  font-size: 15px; font-weight: 700; cursor: pointer; text-align: center;
}
.touch-toggle { display: none; }
@media (pointer: coarse) { .touch-toggle { display: inline-block; } }

.upload-box {
  margin: 16px 0;
  padding: 16px;
  border: 1px solid #dfe3e8;
  border-radius: 10px;
  background: #fafbfc;
}
.upload-box[hidden], .error[hidden] { display: none; }
.upload-cancel {
  margin-top: 14px;
  padding: 8px 16px;
  font-size: 14px;
  background: #fff;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 8px;
  cursor: pointer;
}
.uploading .dropzone, .uploading .folder-btn { opacity: 0.5; pointer-events: none; }
