/* ===========================================================================
   Drop v2 — design tokens
   =========================================================================== */

:root {
  --bg: #FAFAF8;
  --ink: #0E1014;
  --ink-2: #3C4049;
  --muted: #6B6F78;
  --accent: #2F4BF2;
  --accent-hover: #1B32C4;
  --success: #0E9F6E;
  --success-ink: #0A7F58;
  --hairline: #0E10140F;
  --line-soft: #0E101414;
  --line: #0E101418;
  --sans: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
}

body {
  font-family: var(--sans);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

input { font-family: inherit; }
input:focus { outline: none; }

button { font-family: inherit; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* フォーカスリング（アクセント色・3px の薄いリング） */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 8px;
}
.dropzone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  box-shadow: 0 0 0 3px rgba(47, 75, 242, .18);
}

@keyframes v2Rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
/* toast は translateX(-50%) で中央寄せしているので、専用の keyframes を使う */
@keyframes v2RiseCentered {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%); }
}

/* ===========================================================================
   レイアウト
   =========================================================================== */

.page {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
  transition: background .2s ease;
}

.page.is-dragging { background: rgba(47, 75, 242, .045); }

/* 背景装飾 */
.deco { position: absolute; pointer-events: none; }

.deco-grid {
  inset: 0;
  background-image:
    linear-gradient(#0E101408 1px, transparent 1px),
    linear-gradient(90deg, #0E101408 1px, transparent 1px);
  background-size: 96px 96px;
  background-position: center;
}
.deco-circle {
  top: 96px; left: 60px;
  width: 148px; height: 148px;
  border: 1px solid #0E101412;
  border-radius: 50%;
}
.deco-square {
  bottom: 84px; right: 72px;
  width: 96px; height: 96px;
  border-radius: 26px;
  background: #2F4BF20D;
}
.deco-triangle {
  bottom: 140px; left: 118px;
  width: 0; height: 0;
  border-left: 30px solid transparent;
  border-right: 30px solid transparent;
  border-bottom: 50px solid #2F4BF20F;
}

/* ヘッダー */
.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--hairline);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent);
  box-shadow: 0 2px 6px -1px rgba(47, 75, 242, .45);
}
.brand-dot { width: 8px; height: 8px; border-radius: 50%; background: #fff; }
.brand-name { font-size: 15.5px; font-weight: 600; letter-spacing: -.03em; }
.brand-host {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .02em;
  padding-left: 2px;
}

/* main */
#app {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.view { flex: 1; display: flex; flex-direction: column; align-items: center; }
.view[hidden] { display: none; }

.view-idle {
  justify-content: center;
  padding: 20px 24px 28px;
  animation: v2Rise .32s cubic-bezier(.2, .8, .3, 1) both;
}

.view-center {
  justify-content: center;
  padding: 28px 24px 40px;
  animation: v2Rise .32s cubic-bezier(.2, .8, .3, 1) both;
}

/* フッター */
.footer {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px 22px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .06em;
  color: var(--muted);
}

/* ===========================================================================
   idle
   =========================================================================== */

.hero {
  margin: 0 0 10px;
  font-size: clamp(30px, 8vw, 46px);
  line-height: 1.02;
  font-weight: 600;
  letter-spacing: -.042em;
  text-align: center;
  text-wrap: balance;
}
.hero-accent { color: var(--accent); }

/* ドロップ領域のアフォーダンス */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 26px 24px;
  border: 1px dashed #0E101426;
  border-radius: 26px;
  background: transparent;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease;
  -webkit-tap-highlight-color: transparent;
}
.dropzone:hover { border-color: #0E101440; }
.page.is-dragging .dropzone {
  border-color: var(--accent);
  background: rgba(47, 75, 242, .03);
}

.ripple-canvas {
  width: min(420px, 76vw);
  height: min(260px, 30vh);
  display: block;
}
.ripple-canvas-compact {
  width: min(320px, 70vw);
  height: 118px;
  /* 波紋はキャンバス下端まで届くので、負マージンで badge を引き上げると
     外周が "YOUR LINK IS LIVE" の裏を通ってしまう。わずかに離して重なりを 0 にする */
  margin-bottom: 2px;
}

.zone-title { font-size: 19px; font-weight: 600; letter-spacing: -.025em; }
.zone-or {
  margin-top: 7px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .05em;
  color: var(--ink-2);
}
.zone-or-link { color: var(--accent); border-bottom: 1px solid var(--accent); }

/* 事前パスワード */
.pre-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 22px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .08em;
}

.pill {
  display: flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  padding: 5px 11px;
  cursor: pointer;
  transition: all .16s ease;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .08em;
}
.pill.is-open { border-color: #0E101433; color: var(--ink); }
.pill.is-set {
  border-color: #2F4BF240;
  background: #2F4BF20F;
  color: var(--accent);
}

.pre-password {
  display: flex;
  align-items: center;
  gap: 8px;
  animation: v2Rise .2s ease both;
}
.pre-password[hidden] { display: none; }
.pre-password input {
  width: 190px; height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 0 13px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .04em;
  color: var(--ink);
}
.pre-password input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 75, 242, .14);
}

.linkish {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .08em;
  color: var(--muted);
  cursor: pointer;
  padding: 5px 4px;
  background: none;
  border: 0;
}
.linkish:hover { color: var(--ink); }

.constraints {
  margin: 18px 0 0;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .08em;
  color: var(--muted);
}

/* ===========================================================================
   uploading
   =========================================================================== */

.up-name {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -.025em;
  max-width: min(420px, 86vw);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}
.up-status {
  margin-top: 7px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .08em;
  color: var(--ink-2);
}
.progress-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(340px, 80vw);
  margin-top: 22px;
}
.progress-track {
  flex: 1;
  height: 4px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--line-soft);
}
.progress-fill {
  height: 100%;
  width: 100%;
  background: var(--accent);
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform .18s ease-out;
}
.progress-pct {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}
.cancel { margin-top: 18px; }

/* ===========================================================================
   done
   =========================================================================== */

.live-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .14em;
  color: var(--success-ink);
  margin-bottom: 10px;
}
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); }

.share-url {
  margin: 0 0 10px;
  font-size: clamp(22px, 6.4vw, 32px);
  font-weight: 600;
  letter-spacing: -.038em;
  line-height: 1.05;
  text-align: center;
  word-break: break-all;
}

.file-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .05em;
  color: var(--ink-2);
  max-width: min(440px, 100%);
  margin-bottom: 24px;
}
.kind-badge {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 5px;
  padding: 2px 6px;
  flex: none;
}
.file-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { white-space: nowrap; flex: none; }

.done-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  width: min(440px, 100%);
}

.btn-primary {
  height: 48px;
  border-radius: 13px;
  border: 1px solid transparent;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -.015em;
  cursor: pointer;
  transition: background .16s ease, box-shadow .16s ease;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px -2px rgba(47, 75, 242, .5), inset 0 1px 0 rgba(255, 255, 255, .18);
}
.btn-primary.is-copied {
  background: var(--success);
  box-shadow: 0 2px 8px -2px rgba(14, 159, 110, .5);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 48px;
  padding: 0 20px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 500;
  letter-spacing: -.015em;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
  cursor: pointer;
}
.btn-ghost:hover { background: #F5F5F3; color: var(--ink); }

.btn-wide {
  width: min(440px, 100%);
  margin-top: 16px;
  height: 46px;
  font-size: 14px;
}

/* Link settings */
.settings {
  width: min(440px, 100%);
  margin-top: 18px;
  border-top: 1px solid var(--line-soft);
}
.settings-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 2px;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
}
.settings-label { font-size: 13.5px; font-weight: 600; letter-spacing: -.015em; flex: none; }
.settings-summary {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .05em;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.chevron {
  display: flex;
  margin-left: auto;
  flex: none;
  transition: transform .2s ease;
  transform: rotate(0deg);
  color: var(--ink);
}
.chevron.is-open { transform: rotate(180deg); }

.settings-panel {
  padding: 6px 2px 18px;
  border-top: 1px solid var(--line-soft);
}
.settings-panel[hidden] { display: none; }

.field-label {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .1em;
  color: var(--muted);
  margin: 16px 0 8px;
}
.field-label-gap { margin-top: 18px; }

#password-input {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 0 14px;
  font-size: 14px;
  color: var(--ink);
}
#password-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 75, 242, .14);
}

.segment {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
.seg {
  text-align: center;
  padding: 12px 4px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -.01em;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
  border: 0;
  background: #fff;
  color: var(--ink-2);
}
.seg + .seg { border-left: 1px solid var(--line-soft); }
.seg.is-active { background: var(--ink); color: #fff; }

.btn-save {
  width: 100%;
  margin-top: 20px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -.015em;
  cursor: pointer;
  transition: background .16s ease, color .16s ease, border-color .16s ease;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
}
.btn-save.is-saved {
  border-color: transparent;
  background: var(--success);
  color: #fff;
}
.btn-save:disabled { opacity: .6; cursor: default; }

/* ===========================================================================
   toast
   =========================================================================== */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  max-width: min(420px, calc(100vw - 32px));
  padding: 11px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 8px 24px -8px rgba(16, 24, 40, .25);
  font-size: 13px;
  letter-spacing: -.01em;
  color: var(--ink);
  z-index: 50;
  animation: v2RiseCentered .2s ease both;
}
.toast[hidden] { display: none; }
.toast.is-error { border-color: #D9273E33; color: #B4212F; }

/* ===========================================================================
   モバイル
   =========================================================================== */

/* 狭幅（〜640px）: 図形装飾はテキストと衝突するので隠し、縦リズムを詰める。
   .deco-grid は面全体の背景パターンでテキストと視覚的に衝突しないため残す。 */
@media (max-width: 640px) {
  .deco-circle,
  .deco-square,
  .deco-triangle { display: none; }

  .view-idle { padding: 16px 20px 24px; }
  .hero { margin-bottom: 8px; }

  .dropzone { padding: 8px 20px 18px; }

  /* キャンバス下端の空き（波紋の下の余白）を負マージンで回収し、
     "Drop your file here" をキャンバスに近づける */
  .ripple-canvas {
    width: min(420px, 80vw);
    height: min(196px, 42vh);
    margin-bottom: -12px;
  }
  /* 後続の 480px ブロックの .ripple-canvas に負けないよう二重クラスで指定 */
  .ripple-canvas.ripple-canvas-compact {
    width: min(320px, 74vw);
    height: min(104px, 15vh);
    margin-bottom: 2px;
  }

  .pre-row { margin-top: 18px; }
  .constraints { margin-top: 14px; }

  /* 本文の .constraints と同じ情報なので、狭幅では片方だけ見せる。
     残った 1 項目は中央に置いて、片側に寄った余白が目立たないようにする */
  .footer-formats { display: none; }
  .footer { justify-content: center; }
}

@media (max-width: 480px) {
  .topbar { padding: 16px 18px; }
  .footer { padding: 0 18px 18px; gap: 10px; font-size: 9.5px; }
  .view-idle, .view-center { padding-left: 16px; padding-right: 16px; }
  .dropzone { padding: 6px 16px 16px; border-radius: 22px; }
  .ripple-canvas { height: min(184px, 40vh); }
  .pre-password input { width: min(190px, 52vw); }
}

/* ===========================================================================
   prefers-reduced-motion
   =========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .view-idle, .view-center, .pre-password, .toast { animation: none !important; }
}
