:root {
  color-scheme: light;
  --bg: #0c1117;
  --bg-soft: #0b131f;
  --card: #101828;
  --google-ink: #1f2937;
  --muted: #a3b5c8;
  --radius: 18px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  --ink: #f8fafc;
  --ink-contrast: rgba(255, 255, 255, 0.08);
  --scrollbar-thumb: rgba(255, 255, 255, 0.25);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.6);
  --border: rgba(148, 163, 184, 0.12);
  --border-dashed: rgba(148, 163, 184, 0.4);
  --overlay-backdrop: rgba(0, 0, 0, 0.7);
  --overlay-backdrop-soft: rgba(0, 0, 0, 0.5);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  --text-shadow: 0 0 6px rgba(0, 0, 0, 0.8), 0 1px 3px rgba(0, 0, 0, 0.6);

  --ring: rgba(249, 115, 22, 0.4);
  --accent: #f97316;
  --accent-hover: #ea580c;
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-soft-bg: rgba(239, 68, 68, 0.2);
  --danger-text-soft: #fca5a5;
  --success: #22c55e;
  --success-alt: #10b981;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  position: relative;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
*::-webkit-scrollbar {
  width: 3px !important;
  height: 3px !important;
}

html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track,
*::-webkit-scrollbar-track {
  background: transparent !important;
}

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb,
*::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb) !important;
  border-radius: 2px !important;
}

html::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover,
*::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover) !important;
}

/* 隱藏滾動條箭頭按鈕 */
html::-webkit-scrollbar-button,
body::-webkit-scrollbar-button,
*::-webkit-scrollbar-button {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
}

.shell {
  width: min(1120px, 92vw);
  margin: 32px auto;
}

header.shell {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 40px;
  color: var(--bg);
}

h1 {
  font-family: "DM Serif Display", serif;
  margin: 0;
  font-size: clamp(28px, 3vw, 40px);
}

h2, h3 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.auth {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.resources {
  position: relative;
}

.resources summary {
  list-style: none;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.resources summary::-webkit-details-marker {
  display: none;
}

.resources[open] summary {
  border-color: var(--accent);
}

.resources-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 180px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  display: grid;
  gap: 4px;
  z-index: 20;
}

.resources-menu a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
  font-size: 13px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--border);
  animation: rise 0.7s ease both;
}

.card + .card {
  margin-top: 24px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
}

.shell > .grid {
  margin-top: 0;
}

.shell > .grid .card {
  margin-top: 0;
}

.grid + .card {
  margin-top: 24px;
}

.row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  align-items: center;
}

.input {
  height: 200px;
}

.field {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--bg-soft);
  color: var(--ink);
  font-size: 14px;
  outline: none;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.field.mono {
  font-family: var(--mono);
  font-size: 13px;
}

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

.btn {
  padding: 12px 18px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border);
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--danger-text-soft));
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--border);
  font-size: 12px;
  color: var(--muted);
}

.hidden {
  display: none;
}

.dropzone {
  display: grid;
  place-items: center;
  gap: 12px;
  padding: 28px;
  border-radius: 16px;
  border: 2px dashed var(--border-dashed);
  background: var(--bg-soft);
  cursor: pointer;
  min-height: 140px;
  text-align: center;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.dropzone input {
  display: none;
}

.dropzone:hover {
  border-color: var(--accent);
  transform: scale(1.02);
  box-shadow: var(--shadow);
}

.albums {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  min-height: 200px;
}

.album-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
  min-height: 280px;
  border-radius: 12px;
}

.album-card-create {
  border: 2px dashed var(--border-dashed);
  align-items: center;
  justify-content: center;
  padding: 0;
}

.album-card-create:hover {
  border-color: var(--accent);
}

.album-card-create-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.album-card-create-plus {
  color: var(--ink);
  font-size: 64px;
  line-height: 1;
}

.album-card-create-text {
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.album-card:hover {
  transform: scale(1.02);
  box-shadow: var(--shadow);
}

.album-card.selected {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.album-card-preview {
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  gap: 2px;
  overflow: hidden;
  flex-shrink: 0;
}

.album-card-preview.count-1 {
  grid-template-columns: 1fr;
}

.album-card-preview.count-2 {
  grid-template-columns: 1fr 1fr;
}

.album-card-preview.count-3 {
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.album-card-preview.count-4 {
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.album-card-preview.count-5 {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: minmax(0, 3fr) minmax(0, 2fr);
}

.album-card-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  min-width: 0;
  min-height: 0;
}

.album-card-preview.count-3 img:first-child {
  grid-row: 1 / 3;
}

.album-card-preview.count-5 img:first-child {
  grid-column: span 2;
}

.album-card input {
  padding: 8px 12px;
  border: none;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  resize: none;
  min-height: 48px;
  flex-shrink: 0;
}

.album-card input::placeholder {
  color: var(--muted);
}

.album-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px 8px;
}

.album-count-badge {
  font-size: 11px;
}

.album-card .album-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
}

.album-card .btn {
  background: var(--overlay-backdrop-soft);
  border: none;
  border-radius: 4px;
}

.album-card .btn:hover {
  background: var(--overlay-backdrop);
  transform: none;
  box-shadow: none;
}

/* 手機版相簿／圖片排序控制 */
.mobile-sort-controls {
  position: absolute;
  top: 8px;
  left: 8px;
  display: none;
  gap: 4px;
  z-index: 11;
}

.mobile-sort-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

/* 僅在手機尺寸且卡片被啟用時顯示排序控制 */
@media (max-width: 720px) {
  .album-card.show-mobile-sort .mobile-sort-controls,
  .image-card.show-mobile-sort .mobile-sort-controls {
    display: flex;
  }

  /* 手機不強調拖曳游標 */
  .image-card {
    cursor: default;
  }
}

.list {
  display: grid;
  gap: 12px;
}

.album-item {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.album-item > div {
  flex-shrink: 0;
}

.album-btn {
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg-soft);
  border: 1px solid transparent;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.album-btn.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--ring);
}

.album-delete-btn {
  padding: 10px 14px !important;
  font-size: 20px;
  line-height: 1;
}

.album-delete-btn:hover {
  background: var(--danger-soft-bg);
  border-color: var(--danger);
  color: var(--danger);
}

.list button {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg-soft);
  border: 1px solid transparent;
  color: var(--ink);
  cursor: pointer;
}

.list button.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--ring);
}

.status {
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
}

.log {
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
  max-height: 120px;
  overflow: auto;
}

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

.image-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  background: var(--bg-soft);
  cursor: move;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
  border-radius: 12px;
}

.image-card:hover {
  transform: scale(1.02);
  box-shadow: var(--shadow);
}

.image-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: transparent;
}

.image-card input {
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  resize: none;
  min-height: 48px;
}

.image-card .image-link-input {
  font-size: 12px;
  color: var(--muted);
  min-height: auto;
  margin-bottom: 2px;
}

.image-card input::placeholder {
  color: var(--muted);
}

.image-card .image-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px 10px;
}

.image-card .image-card-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
}

.image-card .btn {
  background: var(--overlay-backdrop-soft);
  border: none;
  border-radius: 4px;
}

.image-card .btn:hover {
  background: var(--overlay-backdrop);
  transform: none;
  box-shadow: none;
}

.image-card .image-replace-btn {
  border: none;
  background: var(--border);
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  min-height: 28px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 999px;
}

.image-card .image-replace-btn:hover:not(:disabled) {
  background: var(--overlay-backdrop-soft);
  color: var(--ink);
}

.image-card .image-replace-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

.embed {
  background: transparent;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

/* Notion 主題背景層（底層，根據 Notion 主題顯示深色或淺色） */
.notion-theme-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background: transparent; /* 預設透明 */
}

.embed-shell {
  width: 100%;
  height: 100vh;
  margin: 0;
  padding: 0;
}

.embed-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.embed-grid {
  width: 100%;
  height: 100%;
}

.embed-grid.grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.embed-grid.stack {
  grid-template-columns: 1fr;
}

/* Embed images are styled per-theme below */

/* Slideshow Theme */
.embed-grid.slideshow {
  display: flex;
  align-items: center;
  justify-content: center;
}

.slideshow-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.slideshow-image-wrapper,
.thumbnail-image-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.slideshow-image-wrapper,
.thumbnail-main-container {
  flex: 1;
}

.slideshow-images-scroll,
.thumbnail-images-scroll {
  display: flex;
  width: 100%;
  height: 100%;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.slideshow-image-slide,
.thumbnail-image-slide {
  width: 100%;
  height: 100%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.slideshow-image-slide img,
.thumbnail-image-slide img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.slideshow-overlay,
.thumbnail-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 16px;
  background: transparent;
  pointer-events: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  text-shadow: var(--text-shadow);
  z-index: 30;
}

.slideshow-overlay-left {
  pointer-events: none;
}

.slideshow-overlay-right {
  position: relative;
  pointer-events: auto;
}

.slideshow-menu-btn,
.thumbnail-menu-btn {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  text-shadow: var(--text-shadow);
}

.slideshow-btn:hover,
.slideshow-menu-btn:hover,
.thumbnail-menu-btn:hover {
  opacity: 0.8;
}

.slideshow-menu,
.thumbnail-menu {
  position: absolute;
  right: 0;
  top: 28px;
  display: grid;
  min-width: 120px;
  background: var(--overlay-backdrop);
  padding: 6px;
  z-index: 5;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.3s ease;
  backdrop-filter: blur(3px);
}

.slideshow-menu.open,
.thumbnail-menu.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.slideshow-menu-item,
.thumbnail-menu-item {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--ink);
  text-align: left;
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
}

.slideshow-menu-item:hover,
.thumbnail-menu-item:hover {
  background: var(--ink-contrast);
}

.slideshow-title,
.thumbnail-title {
  font-family: "Space Grotesk", "Noto Sans TC", sans-serif;
  margin: 0;
  font-size: clamp(20px, 2.4vw, 28px);
  font-weight: 900;
  color: var(--ink);
}

.slideshow-title.has-text,
.thumbnail-title.has-text {
  margin: 0 0 8px 0;
}

.slideshow-caption,
.thumbnail-caption {
  font-family: "Space Grotesk", "Noto Sans TC", sans-serif;
  margin: 0;
  font-size: clamp(14px, 1.6vw, 16px);
  font-weight: 700;
  color: var(--ink);
}

.slideshow-caption.has-text,
.thumbnail-caption.has-text {
  margin: 0 0 8px 0;
}

body.embed.embed-sans .slideshow-title,
body.embed.embed-sans .slideshow-caption,
body.embed.embed-sans .thumbnail-title,
body.embed.embed-sans .thumbnail-caption {
  font-family: "Space Grotesk", "Noto Sans TC", sans-serif;
}

body.embed.embed-serif .slideshow-title,
body.embed.embed-serif .slideshow-caption,
body.embed.embed-serif .thumbnail-title,
body.embed.embed-serif .thumbnail-caption {
  font-family: "Noto Serif TC", "Noto Sans TC", serif;
}

.image-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-top: 0;
  border-radius: 999px;
  background: var(--overlay-backdrop-soft);
  border: 1px solid var(--ink-contrast);
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  pointer-events: auto;
  backdrop-filter: blur(3px);
}

.image-link-btn:hover {
  background: var(--overlay-backdrop);
  transform: translateY(-1px);
}

.image-link-btn.hidden {
  display: none;
}
.image-link-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.slideshow-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  color: var(--ink);
  border: none;
  font-size: 32px;
  padding: 0 8px;
  line-height: 1;
  cursor: pointer;
  transition: opacity 0.2s ease;
  z-index: 20;
  text-shadow: var(--text-shadow);
}

.slideshow-btn.prev {
  left: 16px;
}

.slideshow-btn.next {
  right: 16px;
}

.slideshow-dots {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  padding: 8px 4px;
  background: transparent;
  z-index: 20;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
  gap: clamp(3px, 0.5vw, 5px);
  overflow-x: auto;
  overflow-y: hidden;
}

/* 右至左：點點順序反轉，第一張在最右邊 */
.embed-grid.slideshow.embed-rtl .slideshow-dots {
  flex-direction: row-reverse;
}

.slideshow-dots::-webkit-scrollbar {
  height: 0;
}

.dot {
  display: inline-block;
  width: clamp(5px, 1vw, 8px);
  height: clamp(5px, 1vw, 8px);
  flex-shrink: 0;
  background: var(--scrollbar-thumb);
  border-radius: 0;
  cursor: pointer;
  transition: background 0.3s ease, transform 0.2s ease;
}

.dot:hover {
  transform: scale(1.2);
}

.dot.active {
  background: var(--ink);
}

/* Thumbnail Theme */
.embed-grid.thumbnail {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.thumbnail-main-container {
  position: relative;
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.thumbnail-overlay-left {
  pointer-events: none;
}

.thumbnail-overlay-right {
  position: relative;
  pointer-events: auto;
}

/* thumbnail title/caption now share styles with slideshow via .slideshow-title/.thumbnail-title and .slideshow-caption/.thumbnail-caption */

.thumbnail-bar-container {
  width: 100%;
  padding: 8px 0;
  background: transparent;
}

.thumbnail-bar {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 8px;
  justify-content: center;
  scroll-behavior: smooth;
}

/* 右至左：縮圖列順序反轉，第一張在最右邊 */
.embed-grid.thumbnail.embed-rtl .thumbnail-bar {
  flex-direction: row-reverse;
}

.thumbnail-bar::-webkit-scrollbar {
  height: 1px !important;
}

.thumbnail-bar::-webkit-scrollbar-track {
  background: transparent !important;
}

.thumbnail-bar::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb) !important;
  border-radius: 2px !important;
  opacity: 0 !important;
  transition: opacity 0.3s ease !important;
}

.thumbnail-bar:hover::-webkit-scrollbar-thumb {
  opacity: 1;
}

.thumbnail-bar .thumbnail {
  height: 60px;
  width: auto;
  object-fit: contain;
  cursor: pointer;
  opacity: 0.5;
  flex-shrink: 0;
  border-radius: 0;
  border: 2px solid transparent;
  transition: opacity 0.25s ease, border-color 0.25s ease;
  will-change: opacity, border-color;
}

.thumbnail-bar .thumbnail.active {
  opacity: 1;
  border-color: var(--ink);
  animation: thumbnailFadeIn 0.25s ease-out;
}

.thumbnail-bar .thumbnail.fading-out {
  animation: thumbnailFadeOut 0.25s ease-out forwards;
}

@keyframes rise {
  from {
    transform: translateY(12px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* 縮略圖淡入淡出過渡 */
@keyframes thumbnailFadeIn {
  from {
    opacity: 0.5;
    border-color: transparent;
  }
  to {
    opacity: 1;
    border-color: var(--ink);
  }
}

@keyframes thumbnailFadeOut {
  from {
    opacity: 1;
    border-color: var(--ink);
  }
  to {
    opacity: 0.5;
    border-color: transparent;
  }
}

/* Footer 樣式 */
.footer {
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 24px;
  margin-top: 48px;
  text-align: center;
  position: relative;
}

.footer-text {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

/* 預覽窗口調整尺寸支持 */
#previewContainer {
  user-select: none;
  max-width: 100%; /* 確保不會超過父容器 */
  width: 100%; /* 預設寬度 */
  height: 420px; /* 預設高度 */
}

#resizeHandle {
  user-select: none;
}

#resizeHandle:hover {
  opacity: 0.8 !important;
}

@media (max-width: 720px) {
  header.shell {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .resources-menu {
    left: 0;
    right: auto;
  }

  .image-card {
    grid-template-columns: 1fr;
  }

  .image-card img {
    width: 100%;
    height: 180px;
  }
}

/* Modal 樣式 */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease-out;
}

.modal.hidden {
  display: none;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: var(--overlay-backdrop);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: min(440px, 90vw);
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease-out;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
  line-height: 1;
  transition: color 0.2s;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.modal-close:hover {
  color: var(--ink);
  background: var(--ink-contrast);
}

.modal-title {
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 8px 0;
  color: var(--ink);
}

.modal-subtitle {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 24px 0;
}

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

.login-form .label {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: -8px;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0;
  color: var(--muted);
  font-size: 14px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.btn.primary {
  background: var(--accent);
  color: var(--ink);
  border: none;
}

.btn.primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn.google {
  background: var(--ink);
  color: var(--google-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-weight: 500;
  transition: all 0.2s;
}

.btn.google:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Toast 通知樣式 */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 420px;
  pointer-events: none;
}

.toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: toastSlideIn 0.3s ease-out;
  pointer-events: auto;
  min-width: 300px;
  backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
}

.toast::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
}

.toast.success::before {
  background: var(--success);
}

.toast.error::before {
  background: var(--danger);
}

.toast.info::before {
  background: var(--accent);
}

.toast.warning::before {
  background: var(--warning);
}

.toast-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
}

.toast.success .toast-icon {
  color: var(--success);
}

.toast.error .toast-icon {
  color: var(--danger);
}

.toast.info .toast-icon {
  color: var(--accent);
}

.toast.warning .toast-icon {
  color: var(--warning);
}

.toast-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.toast-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  line-height: 1.4;
}

.toast-message {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  word-break: break-word;
}

.toast-close {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-size: 16px;
  line-height: 1;
  transition: all 0.2s;
}

.toast-close:hover {
  background: var(--ink-contrast);
  color: var(--ink);
}

.toast.removing {
  animation: toastSlideOut 0.3s ease-out forwards;
}

@keyframes toastSlideIn {
  from {
    transform: translateX(calc(100% + 24px));
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toastSlideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(calc(100% + 24px));
    opacity: 0;
  }
}

@media (max-width: 720px) {
  .toast-container {
    top: 16px;
    right: 16px;
    left: 16px;
    max-width: none;
  }

  .toast {
    min-width: 0;
  }
}

/* ============================= */
/* Migration Panel Styles */
/* ============================= */

.migration-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.migration-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.migration-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.migration-status {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--ink-contrast);
  border-radius: 12px;
}

.migration-progress {
  width: 100%;
  height: 8px;
  background: var(--ink-contrast);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.migration-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--danger-text-soft));
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

.migration-log {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
  font-size: 14px;
}

.migration-log-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 8px;
  background: var(--ink-contrast);
  animation: migrationLogSlideIn 0.3s ease;
}

@keyframes migrationLogSlideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.migration-log-item.success {
  border-left: 3px solid var(--success-alt);
}

.migration-log-item.error {
  border-left: 3px solid var(--danger);
}

.migration-log-item.info {
  border-left: 3px solid var(--accent);
}

.migration-log-item.warning {
  border-left: 3px solid var(--warning);
}

.migration-log-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.migration-log-item.success .migration-log-icon {
  color: var(--success-alt);
}

.migration-log-item.error .migration-log-icon {
  color: var(--danger);
}

.migration-log-item.info .migration-log-icon {
  color: var(--accent);
}

.migration-log-item.warning .migration-log-icon {
  color: var(--warning);
}

.migration-log-text {
  flex: 1;
  color: var(--muted);
  line-height: 1.5;
}

.migration-log-item.error .migration-log-text {
  color: var(--danger-text-soft);
}

@media (max-width: 720px) {
  .migration-actions {
    flex-direction: column;
  }

  .migration-actions button {
    width: 100%;
  }
}
