/* =========================================================
   Base & Variables
   ========================================================= */
:root {
  --color-bg: #f5f5f5;
  --color-surface: #ffffff;
  --color-border: #e0e0e0;
  --color-text: #1a1a1a;
  --color-subtext: #666666;
  --color-primary: #1a6ee6;
  --color-primary-h: #1558b8;
  --color-danger: #d32f2f;
  --color-danger-h: #b71c1c;
  --color-success: #2e7d32;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .10);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .14);
  --transition: 0.18s ease;
  --max-width: 1100px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  text-decoration: none;
  color: inherit;
}

/* =========================================================
   Layout
   ========================================================= */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
}

/* =========================================================
   Header
   ========================================================= */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 14px 0;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-inner {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.site-logo {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.site-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--color-primary);
}

.site-subtitle {
  font-size: 0.85rem;
  color: var(--color-subtext);
}

/* =========================================================
   Buttons
   ========================================================= */
.btn {
  display: inline-block;
  padding: 9px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background var(--transition), opacity var(--transition);
  line-height: 1.4;
}

.btn-lg {
  padding: 12px 28px;
  font-size: 1rem;
  border-radius: var(--radius-md);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.82rem;
}

.btn-ghost {
  background: transparent;
  color: var(--color-primary);
}

.btn-ghost:hover {
  background: rgba(26, 110, 230, .08);
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--color-primary-h);
}

.btn-secondary {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-border);
}

.btn-danger {
  background: var(--color-danger);
  color: #fff;
}

.btn-danger:hover {
  background: var(--color-danger-h);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Download format */
.download-format-group {
  display: flex;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--color-primary);
}

.btn-format-jpg,
.btn-format-png {
  padding: 8px 16px;
  border: none;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  letter-spacing: 0.05em;
}

.btn-format-jpg {
  background: #fff;
  color: var(--color-primary);
}

.btn-format-jpg:hover {
  background: var(--color-primary);
  color: #fff;
}

.btn-format-png {
  background: var(--color-primary);
  color: #fff;
}

.btn-format-png:hover {
  background: var(--color-primary-h);
}

.btn-format-jpg:disabled,
.btn-format-png:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* =========================================================
   View switch
   ========================================================= */
.view {
  display: block;
}

/* =========================================================
   Home
   ========================================================= */
.home-hero {
  margin-top: 48px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.home-desc {
  color: var(--color-subtext);
  font-size: 0.95rem;
}

/* Recent albums */
.recent-section {
  margin-top: 48px;
  padding-bottom: 48px;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--color-text);
}

/* Album grid (home) */
.album-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  list-style: none;
  padding: 0;
}

@media (min-width: 480px) {
  .album-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 700px) {
  .album-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 900px) {
  .album-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.album-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
  display: flex;
  flex-direction: column;
}

.album-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.album-card-cover {
  aspect-ratio: 4/3;
  background: var(--color-bg);
  overflow: hidden;
}

.album-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.25s ease;
}

.album-card:hover .album-card-cover img {
  transform: scale(1.05);
}

.album-card-cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--color-border);
}

.album-card-body {
  padding: 12px 14px;
}

.album-card-name {
  font-size: 0.92rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.album-card-date {
  font-size: 0.75rem;
  color: var(--color-subtext);
  margin-top: 2px;
}

/* =========================================================
   Album topbar
   ========================================================= */
.album-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 12px;
  padding-bottom: 12px;
  flex-wrap: wrap;
}

.album-topbar-title {
  flex: 1;
  font-size: 1.1rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =========================================================
   Sections (upload / gallery)
   ========================================================= */
.upload-section,
.gallery-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-top: 16px;
  box-shadow: var(--shadow-sm);
}

/* =========================================================
   Dropzone
   ========================================================= */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: 36px 24px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  text-align: center;
}

.dropzone:hover,
.dropzone.drag-over {
  border-color: var(--color-primary);
  background: #edf3fd;
}

.dropzone-icon {
  width: 44px;
  height: 44px;
  color: var(--color-subtext);
  flex-shrink: 0;
}

.dropzone-text {
  font-size: 0.95rem;
  color: var(--color-text);
  font-weight: 500;
}

.dropzone-sub {
  font-size: 0.8rem;
  color: var(--color-subtext);
}

/* =========================================================
   Upload status
   ========================================================= */
.upload-status {
  margin-top: 16px;
}

.progress-wrap {
  height: 6px;
  background: var(--color-border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-bar {
  height: 100%;
  background: var(--color-primary);
  border-radius: 99px;
  transition: width 0.3s ease;
}

.upload-message {
  font-size: 0.9rem;
  color: var(--color-subtext);
}

.data-usage {
  margin-top: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-success);
  border: 1px solid #a5d6a7;
  background: #f1f8e9;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  display: inline-block;
}

/* =========================================================
   Gallery
   ========================================================= */
.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.gallery-header-actions {
  display: flex;
  gap: 8px;
}

.gallery-header .section-title {
  margin-bottom: 0;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 600px) {
  .gallery {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 900px) {
  .gallery {
    grid-template-columns: repeat(4, 1fr);
  }
}

.gallery-item {
  position: relative;
  aspect-ratio: 1/1;
  overflow: hidden;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  cursor: pointer;
  background: var(--color-bg);
  list-style: none;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
}

.gallery-item:hover img {
  transform: scale(1.04);
}

.gallery-empty,
.gallery-error {
  font-size: 0.9rem;
  color: var(--color-subtext);
  padding: 16px 0;
}

.gallery-error {
  color: var(--color-danger);
}

/* =========================================================
   Select mode
   ========================================================= */
.gallery-item.selectable {
  cursor: default;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.gallery-item.selectable:hover img {
  transform: none;
}

.gallery-item.selected {
  outline: 3px solid var(--color-primary);
  outline-offset: -3px;
}

.gallery-item.selected::after {
  content: "✓";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  background: var(--color-primary);
  border-radius: 50%;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .32);
  pointer-events: none;
}

.gallery-item.selectable:active {
  opacity: 0.8;
}

#select-btn.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

/* Select action bar */
.select-action-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 10px 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  z-index: 50;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, .12);
}

.select-count {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}

.select-action-btns {
  display: flex;
  gap: 8px;
}

.select-action-bar .btn-format-jpg,
.select-action-bar .btn-format-png {
  font-size: 0.82rem;
  padding: 7px 14px;
}

html.select-mode-on main.container {
  padding-bottom: 90px;
}

/* =========================================================
   Modal: image viewer
   ========================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 100;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 101;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-close {
  position: fixed;
  top: 12px;
  right: 16px;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  z-index: 102;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Modal nav buttons (◀ ▶) */
.modal-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.45);
  border: none;
  color: #fff;
  font-size: 2.5rem;
  line-height: 1;
  cursor: pointer;
  z-index: 102;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  transition: background var(--transition);
  user-select: none;
}

.modal-nav:hover {
  background: rgba(0, 0, 0, 0.72);
}

.modal-prev {
  left: 10px;
}

.modal-next {
  right: 10px;
}

@media (max-width: 500px) {
  .modal-prev {
    left: 4px;
  }

  .modal-next {
    right: 4px;
  }

  .modal-nav {
    font-size: 2rem;
    padding: 6px 10px;
  }
}

.modal-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 90vw;
  max-height: 90vh;
}

.modal-img {
  max-width: 100%;
  max-height: calc(90vh - 80px);
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.modal-toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* =========================================================
   Modal: album create
   ========================================================= */
.album-modal {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.album-modal-box {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.album-modal-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.album-modal-label {
  font-size: 0.85rem;
  color: var(--color-subtext);
}

.album-modal-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  outline: none;
  transition: border-color var(--transition);
}

.album-modal-input:focus {
  border-color: var(--color-primary);
}

.album-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* =========================================================
   Copy toast
   ========================================================= */
.copy-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 8px 20px;
  border-radius: 99px;
  font-size: 0.85rem;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.copy-toast.show {
  opacity: 1;
}

/* =========================================================
   Utility
   ========================================================= */
[hidden] {
  display: none !important;
}

main.container {
  padding-bottom: 40px;
}