/* === Reset & Base === */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0a0a0b;
  --bg-secondary: #141416;
  --bg-elevated: #1c1c1f;
  --bg-glass: rgba(255, 255, 255, 0.03);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  --text-primary: #f5f5f7;
  --text-secondary: #8e8e93;
  --text-tertiary: #636366;
  --accent: #f97316;
  --accent-hover: #fb923c;
  --accent-glow: rgba(249, 115, 22, 0.15);
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #eab308;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* === Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  color: var(--accent);
}

.modal-card h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.modal-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 32px;
}

#nickname-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#nickname-input {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  color: var(--text-primary);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
  text-align: center;
}

#nickname-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#nickname-input::placeholder {
  color: var(--text-tertiary);
}

/* === Buttons === */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #ea580c);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--accent-hover), var(--accent));
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-ghost:hover {
  background: var(--bg-glass);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-icon:hover {
  background: var(--bg-glass);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

/* === App Layout === */
.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px 40px;
}

/* === Header === */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  z-index: 10;
}

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

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-text {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent), #ef4444);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.status-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-tertiary);
  padding: 4px 10px;
  background: var(--bg-glass);
  border-radius: 100px;
  border: 1px solid var(--border);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* === App Intro === */
.app-intro {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 24px;
  padding: 0 4px;
}

/* === Upload Section === */
.upload-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 32px;
}

.mode-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 20px;
}

.tab {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 10px 16px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.tab:hover {
  color: var(--text-primary);
}

.tab.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.upload-mode {
  display: none;
}

.upload-mode.active {
  display: block;
}

/* Drop Zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
}

.drop-zone.dragover .drop-zone-content {
  color: var(--accent);
}

.drop-text {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
}

.drop-hint {
  font-size: 13px;
  color: var(--text-tertiary);
}

/* File Preview */
.file-preview {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-preview-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.file-preview-item .file-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--accent-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}

.file-preview-item .file-info {
  flex: 1;
  min-width: 0;
}

.file-preview-item .file-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-preview-item .file-size {
  color: var(--text-tertiary);
  font-size: 12px;
}

.file-preview-item .file-remove {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all var(--transition);
}

.file-preview-item .file-remove:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

/* Text Input */
.text-input {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: 'Inter', monospace;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color var(--transition);
  min-height: 120px;
}

.text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.text-input::placeholder {
  color: var(--text-tertiary);
}

/* Controls Grid */
.upload-controls-grid {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.control-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 140px;
}

.control-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}

#ttl-select {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
  flex: 1;
}

#ttl-select:focus {
  border-color: var(--accent);
}

#password-input,
#max-access-input {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
  width: 80px;
}

#password-input:focus,
#max-access-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

#password-input::placeholder,
#max-access-input::placeholder {
  color: var(--text-tertiary);
}

.btn-upload {
  padding: 12px 28px;
  width: 100%;
}

/* Password Modal */
.modal-card-sm {
  max-width: 360px;
  padding: 36px 32px;
}

.modal-icon-lock {
  background: rgba(168, 85, 247, 0.15);
  color: #a855f7;
}

.pin-input-group {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}

.pin-digit {
  width: 52px;
  height: 60px;
  background: var(--bg-primary);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 24px;
  font-weight: 700;
  font-family: inherit;
  text-align: center;
  outline: none;
  transition: all var(--transition);
  caret-color: transparent;
}

.pin-digit:focus {
  border-color: #a855f7;
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.2);
}

.pin-digit.error {
  border-color: var(--danger);
  animation: pinShake 0.4s ease;
}

@keyframes pinShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.modal-actions .btn-ghost,
.modal-actions .btn-primary {
  flex: 1;
}

.pw-hint {
  font-size: 13px;
  color: var(--danger);
  margin-bottom: 12px;
  animation: fadeIn 0.2s;
}

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

/* Item badges */
.item-badges {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.item-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 500;
}

.item-badge.locked {
  background: rgba(168, 85, 247, 0.12);
  color: #a855f7;
}

.item-badge.access-limit {
  background: rgba(59, 130, 246, 0.12);
  color: #3b82f6;
}

/* === Items Section === */
.items-section {
  min-height: 200px;
}

.items-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.items-header h3 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.badge {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.items-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 20px;
  color: var(--text-tertiary);
  text-align: center;
  gap: 12px;
}

.empty-state p {
  font-size: 15px;
  color: var(--text-secondary);
}

.empty-hint {
  font-size: 13px !important;
  color: var(--text-tertiary) !important;
}

/* Item Card */
.item-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  animation: cardIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transition: all var(--transition);
}

.item-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-elevated);
}

.item-card.removing {
  animation: cardOut 0.4s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes cardOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to { opacity: 0; transform: translateX(20px) scale(0.95); }
}

.item-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.item-icon.file-type {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
}

.item-icon.text-type {
  background: rgba(168, 85, 247, 0.1);
  color: #a855f7;
}

.item-body {
  flex: 1;
  min-width: 0;
}

.item-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.item-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-tertiary);
}

.item-meta .nickname {
  color: var(--text-secondary);
}

.item-timer {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
  min-width: 80px;
}

.countdown {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.countdown.urgent {
  color: var(--danger);
}

.countdown.warning {
  color: var(--warning);
}

.progress-bar {
  width: 80px;
  height: 3px;
  background: var(--bg-primary);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--success);
  transition: width 1s linear, background-color 0.5s;
}

.progress-fill.warning {
  background: var(--warning);
}

.progress-fill.urgent {
  background: var(--danger);
}

.item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Text preview in card */
.text-preview {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
  font-family: 'Inter', monospace;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }

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

/* Upload progress */
.upload-progress {
  margin-top: 12px;
  display: none;
}

.upload-progress.active {
  display: block;
}

.upload-progress-bar {
  width: 100%;
  height: 4px;
  background: var(--bg-primary);
  border-radius: 2px;
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #ea580c);
  border-radius: 2px;
  transition: width 0.3s;
  animation: progressPulse 1.5s infinite;
}

@keyframes progressPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* === Responsive === */
@media (max-width: 640px) {
  .app {
    padding: 0 12px 24px;
  }

  .upload-section {
    padding: 16px;
  }

  .header {
    padding: 16px 0;
    margin-bottom: 20px;
  }

  .control-row {
    flex-direction: column;
  }

  .control-group {
    justify-content: space-between;
  }

  .item-card {
    padding: 12px 14px;
    gap: 12px;
  }

  .item-timer {
    min-width: 60px;
  }

  .progress-bar {
    width: 60px;
  }

  .status-bar {
    display: none;
  }
}
