/* SK Share（/view/）と作るページ（/view/editor/）— Google のマテリアルデザイン（Material 3）
   色は SK's Blue から作った M3 の配色（/toolbox/shared/settings.js の blue と同じ）
   共通の部品（アイコン・状態レイヤー・波紋・ボタン・スナックバー）は /toolbox/shared/m3.css */
:root {
  --md-primary: #004ac6; --md-on-primary: #ffffff; --md-primary-container: #2563eb; --md-on-primary-container: #eeefff;
  --md-secondary-container: #dce2ff; --md-on-secondary-container: #394c84;
  --md-tertiary: #943700; --md-error: #ba1a1a; --md-error-container: #ffdad6; --md-on-error-container: #93000a;
  --md-surface: #faf8ff; --md-on-surface: #191b23; --md-on-surface-variant: #434655;
  --md-surface-container-lowest: #ffffff; --md-surface-container-low: #f3f3fe; --md-surface-container: #ededf9;
  --md-surface-container-high: #e7e7f3; --md-surface-container-highest: #e1e2ed;
  --md-outline: #737686; --md-outline-variant: #c3c6d7;
  --md-inverse-surface: #2e3039; --md-inverse-on-surface: #f0f0fb; --md-inverse-primary: #b4c5ff;
  --md-font: "M PLUS 1", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  --md-emphasized: cubic-bezier(.2, 0, 0, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --md-primary: #b4c5ff; --md-on-primary: #002a78; --md-primary-container: #2563eb; --md-on-primary-container: #eeefff;
    --md-secondary-container: #33467e; --md-on-secondary-container: #dce2ff;
    --md-tertiary: #ffb596; --md-error: #ffb4ab; --md-error-container: #93000a; --md-on-error-container: #ffdad6;
    --md-surface: #11131b; --md-on-surface: #e1e2ed; --md-on-surface-variant: #c3c6d7;
    --md-surface-container-lowest: #0c0e16; --md-surface-container-low: #191b23; --md-surface-container: #1d1f27;
    --md-surface-container-high: #282a32; --md-surface-container-highest: #32343d;
    --md-outline: #8d90a0; --md-outline-variant: #434655;
    --md-inverse-surface: #e1e2ed; --md-inverse-on-surface: #2e3039; --md-inverse-primary: #0053db;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --md-primary: #b4c5ff; --md-on-primary: #002a78; --md-primary-container: #2563eb; --md-on-primary-container: #eeefff;
  --md-secondary-container: #33467e; --md-on-secondary-container: #dce2ff;
  --md-tertiary: #ffb596; --md-error: #ffb4ab; --md-error-container: #93000a; --md-on-error-container: #ffdad6;
  --md-surface: #11131b; --md-on-surface: #e1e2ed; --md-on-surface-variant: #c3c6d7;
  --md-surface-container-lowest: #0c0e16; --md-surface-container-low: #191b23; --md-surface-container: #1d1f27;
  --md-surface-container-high: #282a32; --md-surface-container-highest: #32343d;
  --md-outline: #8d90a0; --md-outline-variant: #434655;
  --md-inverse-surface: #e1e2ed; --md-inverse-on-surface: #2e3039; --md-inverse-primary: #0053db;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  background: var(--md-surface); color: var(--md-on-surface);
  font-family: var(--md-font); line-height: 1.6;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--md-primary); }
:focus-visible { outline: 3px solid var(--md-primary); outline-offset: 2px; }

.vw-page {
  max-width: 880px; margin: 0 auto;
  padding: max(4px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(48px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

/* ---- 上のバー ---- */
.vw-bar { display: flex; align-items: center; gap: 4px; min-height: 64px; margin: 0 -4px; }
.vw-bar__space { flex: 1; }
.vw-brand {
  display: inline-flex; align-items: center; gap: 10px; height: 44px; padding: 0 14px 0 8px; border-radius: 22px;
  color: var(--md-on-surface); text-decoration: none; font-size: 16px; font-weight: 700;
}
.vw-brand img { width: 28px; height: 28px; border-radius: 8px; }

/* ---- パスワードの入力 ---- */
.vw-gate { display: flex; flex-direction: column; align-items: center; padding-top: clamp(8px, 6vh, 64px); }
.vw-gate__card {
  width: 100%; max-width: 440px; padding: 32px 28px 28px; border-radius: 28px;
  background: var(--md-surface-container-low); text-align: center;
  animation: vw-rise .5s var(--md-emphasized) both;
}
.vw-gate__icon {
  display: inline-grid; place-items: center; width: 72px; height: 72px; border-radius: 24px;
  background: var(--md-primary-container); color: var(--md-on-primary-container);
}
.vw-gate__icon .msr { font-size: 36px; }
.vw-gate__title { margin: 20px 0 0; font-size: 28px; font-weight: 700; line-height: 1.3; }
.vw-gate__lead { margin: 10px 0 24px; font-size: 14.5px; color: var(--md-on-surface-variant); }
.vw-gate__submit { width: 100%; height: 52px; margin-top: 20px; border-radius: 26px; font-size: 16px; }
.vw-gate.is-shake .vw-field { animation: vw-shake .4s cubic-bezier(.36, .07, .19, .97); }

/* M3 の outlined text field（文字を入れるとラベルが枠の上に上がる） */
.vw-field { position: relative; text-align: left; }
.vw-field__input {
  width: 100%; height: 56px; padding: 0 52px 0 16px; border: 1px solid var(--md-outline); border-radius: 4px;
  background: transparent; font-size: 17px; letter-spacing: .04em; outline: 0;
  transition: border-color .15s linear, box-shadow .15s linear;
}
.vw-field__input:hover { border-color: var(--md-on-surface); }
.vw-field__input:focus { border-color: var(--md-primary); box-shadow: inset 0 0 0 1px var(--md-primary); }
.vw-field__label {
  position: absolute; left: 12px; top: 50%; translate: 0 -50%; padding: 0 4px; pointer-events: none;
  background: var(--md-surface-container-low); color: var(--md-on-surface-variant); font-size: 16px; line-height: 1;
  transition: top .2s var(--md-emphasized), font-size .2s var(--md-emphasized), color .15s linear;
}
.vw-field__input:focus + .vw-field__label, .vw-field__input:not(:placeholder-shown) + .vw-field__label { top: 0; font-size: 12px; }
.vw-field__input:focus + .vw-field__label { color: var(--md-primary); }
.vw-field__toggle { position: absolute; right: 4px; top: 4px; }
.vw-field__support { margin: 6px 16px 0; font-size: 12px; line-height: 16px; color: var(--md-on-surface-variant); text-align: left; }
.vw-field.is-error .vw-field__input { border-color: var(--md-error); box-shadow: inset 0 0 0 1px var(--md-error); }
.vw-field.is-error .vw-field__label { color: var(--md-error); }
.vw-field.is-error + .vw-field__support { color: var(--md-error); }

/* 読み込み中のくるくる（ボタンの中） */
.vw-spinner { display: none; width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: vw-spin .8s linear infinite; }
.is-busy .vw-spinner { display: inline-block; }

.vw-foot { margin: 24px 0 0; font-size: 12.5px; line-height: 1.7; color: var(--md-on-surface-variant); text-align: center; }

.vw-foot--tight { margin-top: 4px; }

/* ---- 中身 ---- */
.vw-content { animation: vw-rise .5s var(--md-emphasized) both; }
.vw-head { margin: 8px 4px 20px; }
.vw-head__kicker {
  display: inline-flex; align-items: center; gap: 6px; margin: 0; height: 32px; padding: 0 12px 0 8px; border-radius: 8px;
  background: var(--md-secondary-container); color: var(--md-on-secondary-container); font-size: 13px; font-weight: 500;
}
.vw-head__kicker .msr { font-size: 18px; }
.vw-head__title { margin: 14px 0 0; font-size: clamp(26px, 5vw, 36px); font-weight: 800; line-height: 1.3; overflow-wrap: anywhere; }
.vw-head__note { margin: 10px 0 0; font-size: 15px; color: var(--md-on-surface-variant); white-space: pre-wrap; overflow-wrap: anywhere; }
.vw-head__note:empty { display: none; }
.vw-head__expires { display: flex; align-items: center; gap: 6px; margin: 12px 0 0; font-size: 13px; color: var(--md-on-surface-variant); }
.vw-head__expires .msr { font-size: 18px; }

/* 目次（M3 の assist chips） */
.vw-chips { display: flex; gap: 8px; margin: 0 -16px 16px; padding: 0 16px 4px; overflow-x: auto; scrollbar-width: none; }
.vw-chips::-webkit-scrollbar { display: none; }
.vw-chip {
  display: inline-flex; align-items: center; gap: 8px; flex: none; height: 32px; padding: 0 16px 0 8px;
  border: 1px solid var(--md-outline-variant); border-radius: 8px; background: none; cursor: pointer;
  color: var(--md-on-surface); font-size: 14px; font-weight: 500; white-space: nowrap;
}
.vw-chip .msr { font-size: 18px; color: var(--md-primary); }

.vw-items { display: flex; flex-direction: column; gap: 16px; }
.vw-item {
  border-radius: 28px; overflow: hidden; background: var(--md-surface-container-low);
  scroll-margin-top: 16px; animation: vw-rise .5s var(--md-emphasized) both;
}
.vw-item__head { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 8px 8px 8px 20px; }
.vw-item__icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px; background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.vw-item__icon .msr { font-size: 22px; }
.vw-item__title { flex: 1; min-width: 0; margin: 0; font-size: 17px; font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; }
.vw-item__kind { display: block; font-size: 12px; font-weight: 500; color: var(--md-on-surface-variant); }
.vw-video { position: relative; aspect-ratio: 16 / 9; background: #000; }
.vw-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.vw-drive { position: relative; margin: 0 12px 12px; border-radius: 16px; overflow: hidden; background: var(--md-surface-container-highest); }
.vw-drive iframe { display: block; width: 100%; height: 100%; border: 0; }
.vw-drive--file, .vw-drive--document { height: min(80vh, 900px); }
.vw-drive--spreadsheets, .vw-drive--folder { height: min(70vh, 640px); }
.vw-drive--presentation { aspect-ratio: 16 / 9.6; }
.vw-drive--folder { background: #fff; }
.vw-doc { margin: 0 12px 12px; border-radius: 16px; overflow: hidden; background: #fff; box-shadow: inset 0 0 0 1px var(--md-outline-variant); }
.vw-doc-frame { display: block; width: 100%; height: 240px; border: 0; background: #fff; }
.vw-item__error { margin: 0 20px 20px; font-size: 14px; color: var(--md-error); }
.vw-loading { display: grid; place-items: center; height: 200px; color: var(--md-on-surface-variant); }
.vw-loading .vw-spinner { display: inline-block; width: 32px; height: 32px; border-width: 3.5px; color: var(--md-primary); }

/* 文書の全画面表示 */
.vw-full {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: var(--md-surface); color: var(--md-on-surface);
}
.vw-full[open] { display: flex; flex-direction: column; animation: vw-rise .35s var(--md-emphasized); }
.vw-full::backdrop { background: rgba(0, 0, 0, .32); }
.vw-full__bar { display: flex; align-items: center; gap: 8px; min-height: 64px; padding: max(4px, env(safe-area-inset-top)) 16px 0 4px; flex: none; }
.vw-full__title { font-size: 20px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vw-full__body { flex: 1; overflow-y: auto; padding: 0 max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.vw-full__body .vw-doc { margin: 0 auto; max-width: 960px; }

@keyframes vw-rise { from { opacity: 0; transform: translateY(16px); } }
@keyframes vw-spin { to { transform: rotate(360deg); } }
@keyframes vw-shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media (max-width: 480px) {
  .vw-gate__card { padding: 28px 20px 24px; }
  .vw-item { border-radius: 24px; }
  .vw-item__head { padding-left: 16px; }
  .vw-doc { margin: 0 8px 8px; }
}
