/* Global Design Tokens & Setup */
:root {
  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-code: 'JetBrains Mono', monospace;

  /* Colors */
  --bg-dark: #070913;
  --bg-card: rgba(16, 22, 42, 0.65);
  --bg-card-hover: rgba(22, 31, 58, 0.8);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-hover: rgba(0, 242, 254, 0.35);
  
  --primary-glow: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
  --secondary-glow: linear-gradient(135deg, #b155ff 0%, #ff5e97 100%);
  --danger-glow: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
  
  --text-primary: #f1f5f9;
  --text-muted: #94a3b8;
  --text-highlight: #00f2fe;
  
  --shadow-neon: 0 8px 32px 0 rgba(0, 242, 254, 0.12);
  --shadow-neon-hover: 0 12px 40px 0 rgba(0, 242, 254, 0.25);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-primary);
  font-family: var(--font-main);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Background Glowing Orbs */
.glass-bg-glow {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.glass-bg-glow::before,
.glass-bg-glow::after {
  content: '';
  position: absolute;
  width: 40vw;
  height: 40vw;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.15;
}

.glass-bg-glow::before {
  top: -10%;
  left: -10%;
  background: radial-gradient(circle, #00f2fe 0%, transparent 70%);
}

.glass-bg-glow::after {
  bottom: -10%;
  right: -10%;
  background: radial-gradient(circle, #b155ff 0%, transparent 70%);
}

/* Application Container */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-neon);
  position: relative;
  z-index: 1000;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.icon-logo {
  color: #00f2fe;
  filter: drop-shadow(0 0 8px rgba(0, 242, 254, 0.8));
  animation: pulse-glow 2s infinite ease-in-out;
}

.logo-area h1 {
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(to right, #ffffff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  background: rgba(0, 242, 254, 0.1);
  color: var(--text-highlight);
  border: 1px solid rgba(0, 242, 254, 0.2);
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  background: rgba(255, 255, 255, 0.03);
  padding: 0.4rem 0.8rem;
  border-radius: 30px;
  border: 1px solid var(--border-color);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #94a3b8;
}

.status-indicator.online {
  background-color: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.status-indicator.p2p {
  background-color: #00f2fe;
  box-shadow: 0 0 8px #00f2fe;
}

.status-indicator.offline {
  background-color: #ef4444;
  box-shadow: 0 0 8px #ef4444;
}

.peer-count-badge {
  background: rgba(255, 255, 255, 0.1);
  padding: 0.1rem 0.5rem;
  border-radius: 10px;
  font-size: 0.75rem;
  color: #fff;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.6rem 1.2rem;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary {
  background: var(--primary-glow);
  color: #070913;
  box-shadow: 0 4px 15px rgba(0, 242, 254, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 242, 254, 0.5);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
  background: var(--danger-glow);
  color: white;
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

/* Grid Layout */
.app-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  flex: 1;
}

/* Cards / Panels */
.panel-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  transition: border-color 0.3s, box-shadow 0.3s;
  box-shadow: var(--shadow-neon);
}

.panel-card:hover {
  border-color: var(--border-color-hover);
  box-shadow: var(--shadow-neon-hover);
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.panel-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

.panel-header i {
  color: #00f2fe;
}

.channel-type {
  margin-left: auto;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(177, 85, 255, 0.15);
  color: #ff5e97;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  border: 1px solid rgba(177, 85, 255, 0.3);
}

.panel-body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  flex: 1;
}

/* Text Share Section */
.share-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

textarea {
  width: 100%;
  background: rgba(7, 9, 19, 0.5);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.95rem;
  padding: 1rem;
  resize: vertical;
  outline: none;
  transition: all 0.3s;
}

textarea:focus {
  border-color: #00f2fe;
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.15);
  background: rgba(7, 9, 19, 0.8);
}

.input-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.char-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* History & File Lists */
.history-section, .file-list-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
  min-height: 200px;
}

.history-section h3, .file-list-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.history-list, .file-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow-y: auto;
  max-height: 350px;
  padding-right: 0.25rem;
}

/* Scrollbar styling */
.history-list::-webkit-scrollbar,
.file-list::-webkit-scrollbar {
  width: 4px;
}

.history-list::-webkit-scrollbar-thumb,
.file-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

/* Cards inside Lists */
.history-card, .file-card {
  background: rgba(7, 9, 19, 0.4);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  transition: all 0.2s;
  animation: slide-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.history-card:hover, .file-card:hover {
  background: rgba(7, 9, 19, 0.6);
  border-color: rgba(255, 255, 255, 0.15);
}

.card-content {
  flex: 1;
  min-width: 0; /* Enable text truncation */
}

.card-text {
  font-size: 0.9rem;
  word-break: break-all;
  white-space: pre-wrap;
  line-height: 1.4;
}

.card-text.url {
  color: var(--text-highlight);
  text-decoration: underline;
  cursor: pointer;
}

.card-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: rgba(0, 242, 254, 0.1);
  border-color: var(--text-highlight);
  color: var(--text-highlight);
}

.btn-icon-danger:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
  color: #ef4444;
}

/* File Dropzone */
.file-dropzone {
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  background: rgba(7, 9, 19, 0.2);
  position: relative;
}

.file-dropzone:hover, .file-dropzone.dragover {
  border-color: #00f2fe;
  background: rgba(0, 242, 254, 0.03);
  box-shadow: 0 0 15px rgba(0, 242, 254, 0.1) inset;
}

.hidden-file-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  pointer-events: none;
}

.dropzone-icon {
  color: var(--text-muted);
  width: 40px;
  height: 40px;
  transition: all 0.3s;
}

.file-dropzone:hover .dropzone-icon, .file-dropzone.dragover .dropzone-icon {
  color: #00f2fe;
  transform: translateY(-4px);
  filter: drop-shadow(0 0 5px rgba(0, 242, 254, 0.5));
}

.dropzone-main-text {
  font-size: 0.95rem;
  font-weight: 600;
}

.dropzone-main-text span {
  color: #00f2fe;
  text-decoration: underline;
}

.dropzone-sub-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Progress bar */
.upload-progress-container {
  background: rgba(7, 9, 19, 0.5);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1rem;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
}

.progress-bar-bg {
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--primary-glow);
  border-radius: 10px;
  transition: width 0.1s ease;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: var(--text-muted);
  padding: 3rem 1rem;
  border: 1px dashed rgba(255, 255, 255, 0.05);
  border-radius: 12px;
}

.empty-state i {
  width: 32px;
  height: 32px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 0.85rem;
}

/* Footer */
.app-footer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
  padding: 1rem 0.5rem 0 0.5rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Animations */
@keyframes pulse-glow {
  0%, 100% {
    filter: drop-shadow(0 0 4px rgba(0, 242, 254, 0.6));
    opacity: 0.8;
  }
  50% {
    filter: drop-shadow(0 0 12px rgba(0, 242, 254, 1));
    opacity: 1;
  }
}

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

.hidden {
  display: none !important;
}

/* ==========================================================================
   Widget / Mobile Mode (當寬度較小時自動化為桌面小工具樣式)
   ========================================================================== */

@media (max-width: 800px) {
  .app-grid {
    grid-template-columns: 1fr;
  }
}

/* 強制 Widget 模式 (可用於 URL 帶有 ?mode=widget) */
body.widget-mode {
  padding: 0;
  min-height: 100vh;
  background-color: #05070d;
}

body.widget-mode .app-container {
  padding: 0.75rem;
  min-height: 100vh;
  gap: 0.5rem;
}

body.widget-mode .app-header {
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.5rem;
  border-radius: 12px;
}

body.widget-mode .app-header h1 {
  font-size: 1.1rem;
}

body.widget-mode .header-actions,
body.widget-mode .app-footer-bar,
body.widget-mode .dropzone-sub-text,
body.widget-mode .logo-area span.badge {
  display: none !important;
}

body.widget-mode .app-grid {
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

body.widget-mode .panel-card {
  padding: 0.85rem;
  border-radius: 12px;
  gap: 0.75rem;
}

body.widget-mode .panel-header {
  padding-bottom: 0.5rem;
}

body.widget-mode .panel-header h2 {
  font-size: 0.95rem;
}

body.widget-mode textarea {
  font-size: 0.85rem;
  padding: 0.6rem;
  rows: 2 !important; /* Will adjust with JS */
}

body.widget-mode .file-dropzone {
  padding: 1.25rem 1rem;
  border-radius: 12px;
}

body.widget-mode .dropzone-icon {
  width: 28px;
  height: 28px;
}

body.widget-mode .dropzone-main-text {
  font-size: 0.85rem;
}

body.widget-mode .history-section,
body.widget-mode .file-list-section {
  min-height: 120px;
}

body.widget-mode .history-list,
body.widget-mode .file-list {
  max-height: 150px;
}

body.widget-mode .history-card,
body.widget-mode .file-card {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
}

body.widget-mode .card-text {
  font-size: 0.8rem;
}

body.widget-mode .btn {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
}

/* 裝置命名與定向傳輸美化 */
.device-naming {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  padding: 0.4rem 0.8rem;
  border-radius: 30px;
  border: 1px solid var(--border-color);
}

.input-nickname {
  background: transparent;
  border: none;
  border-bottom: 1px dashed rgba(0, 242, 254, 0.4);
  color: var(--text-highlight);
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 0.85rem;
  width: 90px;
  outline: none;
  padding: 0 2px;
  transition: all 0.2s;
}

.input-nickname:focus {
  border-bottom: 1px solid #00f2fe;
  color: #fff;
  width: 120px;
  text-shadow: 0 0 5px rgba(0, 242, 254, 0.5);
}

.target-select-container {
  display: flex;
  align-items: center;
}

.file-target-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
  background: rgba(7, 9, 19, 0.3);
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

.target-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.select-target {
  background: rgba(7, 9, 19, 0.7);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.825rem;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  outline: none;
  cursor: pointer;
  transition: all 0.25s;
  min-width: 140px;
}

.select-target:hover, .select-target:focus {
  border-color: #00f2fe;
  box-shadow: 0 0 8px rgba(0, 242, 254, 0.15);
}

/* 定向傳播私密卡片 */
.history-card.private {
  border-left: 3px solid #ff5e97;
  background: rgba(255, 94, 151, 0.02);
}

.private-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: rgba(255, 94, 151, 0.15);
  color: #ff5e97;
  border: 1px solid rgba(255, 94, 151, 0.2);
  margin-left: 0.5rem;
}

/* Widget Mode 佈局覆蓋 */
/* 全域目標選擇欄 (完整模式隱藏) */
.global-target-bar {
  display: none;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.4rem 0.75rem;
  border-radius: 12px;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  box-shadow: var(--shadow-neon);
}

.global-target-bar span {
  font-weight: 600;
  color: var(--text-muted);
}

/* Widget 專用最新卡片 (完整模式隱藏) */
.widget-active-card {
  display: none;
  flex-direction: column;
  background: rgba(7, 9, 19, 0.4);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.5rem 0.75rem;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
  transition: all 0.3s;
}

.widget-active-card:hover {
  border-color: var(--border-color-hover);
}

.widget-card-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 0.25rem;
}

.widget-meta {
  color: var(--text-highlight);
}

.widget-card-body {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.widget-card-text {
  font-size: 0.825rem;
  color: var(--text-primary);
  word-break: break-all;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  font-family: var(--font-main);
  line-height: 1.4;
}

.widget-card-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.widget-card-actions .btn-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

/* ==========================================================================
   超濃縮 Widget Mode 佈局覆蓋 (320x240 px 專用)
   ========================================================================= */
body.widget-mode {
  padding: 0;
  min-height: 100vh;
  background-color: #05070d;
}

body.widget-mode .app-container {
  padding: 0.4rem;
  min-height: 100vh;
  gap: 0;
  display: flex;
  flex-direction: column;
}

body.widget-mode .app-header {
  padding: 0.25rem 0.4rem;
  margin-bottom: 0.25rem;
  border-radius: 8px;
  box-shadow: none;
}

body.widget-mode .logo-area h1 {
  font-size: 1rem;
}

body.widget-mode .logo-area .icon-logo {
  width: 16px;
  height: 16px;
}

/* 保留 Widget 下暱稱修改，但要精簡 */
body.widget-mode .device-naming {
  display: flex !important;
  background: transparent;
  border: none;
  padding: 0;
  gap: 0.25rem;
  font-size: 0.75rem;
}

body.widget-mode .device-naming span {
  display: none; /* 隱藏「裝置名稱:」標籤以省空間 */
}

body.widget-mode .input-nickname {
  width: 60px !important;
  font-size: 0.75rem;
  border-bottom: 1px dashed rgba(0, 242, 254, 0.4);
}

body.widget-mode .input-nickname:focus {
  width: 60px !important;
}

/* 隱藏 Widget 不需要的多餘 Header 控制與 Status 文字，以及整個 Logo 區 */
body.widget-mode .header-actions,
body.widget-mode #status-text,
body.widget-mode .app-footer-bar,
body.widget-mode .logo-area {
  display: none !important;
}

body.widget-mode .connection-status {
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
  gap: 0.35rem;
  background: transparent;
  border: none;
}

body.widget-mode .peer-count-badge {
  font-size: 0.7rem;
  padding: 0 0.3rem;
}

/* 顯示全域選擇欄與最新剪貼簿卡片 */
body.widget-mode .global-target-bar {
  display: flex;
  margin-bottom: 0.4rem;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
  align-items: center;
  justify-content: space-between;
}

body.widget-mode .global-target-bar span {
  font-size: 0.75rem;
}

body.widget-mode .global-target-bar .select-target {
  min-width: 130px;
  font-size: 0.75rem;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
}

body.widget-mode .widget-active-card {
  display: flex;
  margin-bottom: 0.25rem;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
}
body.widget-mode .widget-card-text {
  font-size: 0.725rem;
  padding: 0.15rem 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.widget-mode .widget-card-header {
  font-size: 0.65rem;
  margin-bottom: 0.1rem;
}
body.widget-mode .widget-card-actions .btn-icon {
  width: 24px;
  height: 24px;
  padding: 0;
}
body.widget-mode .widget-card-actions .btn-icon i {
  width: 12px;
  height: 12px;
}

/* Grid Layout 扁平化 */
body.widget-mode .app-grid {
  grid-template-columns: 1fr;
  gap: 0.4rem;
  flex: 1;
}

body.widget-mode .panel-card {
  padding: 0.5rem;
  border-radius: 10px;
  box-shadow: none;
  border: 1px solid var(--border-color);
  background: transparent;
  gap: 0.4rem;
}

/* 隱藏各個面板自帶的獨立 header 還有獨立 target selector */
body.widget-mode .panel-header,
body.widget-mode .target-select-container,
body.widget-mode .file-target-container {
  display: none !important;
}

/* 隱藏歷史清單與檔案清單 */
body.widget-mode .history-section,
body.widget-mode .file-list-section {
  display: none !important;
}

/* 緊湊的文字共享輸入區 */
body.widget-mode .share-input-group {
  gap: 0.35rem;
}

body.widget-mode textarea {
  font-size: 0.75rem;
  padding: 0.3rem 0.5rem;
  border-radius: 8px;
  background: rgba(7, 9, 19, 0.4);
  min-height: 32px;
  height: auto;
  max-height: 60px;
  line-height: 1.4 !important;
  resize: none !important;
  overflow-y: auto;
}

body.widget-mode .input-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

body.widget-mode .char-count {
  display: none !important;
}

body.widget-mode .btn {
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  border-radius: 6px;
}

/* 緊湊的拖放直傳區 */
/* 萬能輸入框包裝與拖曳覆蓋層 */
.universal-input-wrapper {
  position: relative;
  width: 100%;
}

.drag-overlay {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(7, 242, 254, 0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px dashed #00f2fe;
  border-radius: 12px;
  align-items: center;
  justify-content: center;
  color: #00f2fe;
  font-weight: 800;
  font-size: 1rem;
  text-shadow: 0 0 8px rgba(0, 242, 254, 0.6);
  pointer-events: none; /* 防止滑鼠移入子元素重複觸發 drag */
  z-index: 10;
  animation: pulse-border 1.5s infinite alternate ease-in-out;
}

.universal-input-wrapper.dragover .drag-overlay {
  display: flex;
}

@keyframes pulse-border {
  from { border-color: rgba(0, 242, 254, 0.4); }
  to { border-color: rgba(0, 242, 254, 1); }
}

/* Toast 提示通知 */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: rgba(16, 22, 42, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-left: 4px solid #00f2fe;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: auto;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success {
  border-left-color: #10b981;
}

.toast.error {
  border-left-color: #ef4444;
}

/* Widget Mode 佈局壓縮優化 */
body.widget-mode #panel-files {
  display: none !important; /* 隱藏整個檔案面板，因為小工具為單一萬能輸入框 */
}

body.widget-mode .app-container {
  padding: 0.3rem;
  min-height: 100vh;
  justify-content: flex-start;
}

body.widget-mode .app-grid {
  grid-template-columns: 1fr;
  flex: none;
}

body.widget-mode .panel-card {
  border: none;
  background: transparent;
  padding: 0.25rem;
}

/* 小工具內進度條直接顯示在萬能輸入框下方 */
body.widget-mode .upload-progress-container {
  margin-top: 0.35rem;
  padding: 0.35rem 0.5rem;
  background: rgba(7, 9, 19, 0.6);
  border: 1px solid var(--border-color);
}

/* 小工具模式下，Toast 位置調整至頂部中央，避免蓋住輸入 */
body.widget-mode .toast-container {
  top: 1rem;
  bottom: auto;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
}

body.widget-mode .toast {
  transform: translateY(-20px);
}

body.widget-mode .toast.show {
  transform: translateY(0) translateX(0);
}

/* 阻斷小工具垂直滾動條，確保視窗尺寸牢固 */
body.widget-mode {
  overflow: hidden !important;
}

/* 懸浮歷史紀錄下拉選單 (不改變視窗尺寸，採絕對定位浮動覆蓋) */
.widget-active-card {
  position: relative;
}

.widget-history-dropdown {
  background: rgba(7, 9, 19, 0.4);
  border: 1px dashed rgba(0, 242, 254, 0.25);
  border-radius: 10px;
  max-height: 115px;
  overflow-y: auto;
  padding: 0.35rem;
  margin-top: 0.35rem;
  box-shadow: none;
}

.widget-history-dropdown::-webkit-scrollbar {
  width: 3px;
}

.widget-history-dropdown::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.widget-history-dropdown.hidden {
  display: none !important;
}

.widget-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.widget-hist-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  padding: 0.25rem 0.4rem;
  gap: 0.4rem;
  font-size: 0.725rem;
  transition: all 0.2s;
}

.widget-hist-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.widget-hist-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
  font-family: var(--font-main);
  color: var(--text-primary);
}

.widget-hist-text.url {
  color: var(--text-highlight);
  text-decoration: underline;
  cursor: pointer;
}

.widget-hist-meta {
  font-size: 0.6rem;
  color: var(--text-muted);
}

.widget-hist-actions {
  display: flex;
  gap: 0.2rem;
  flex-shrink: 0;
}

.widget-hist-actions .btn-icon {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.widget-hist-actions .btn-icon i {
  width: 12px;
  height: 12px;
}

/* 微調按鈕樣式 */
.widget-card-actions .btn-icon {
  position: relative;
}

/* Widget Mode Tabs 佈局 */
.widget-tabs {
  display: none;
}

body.widget-mode .widget-tabs {
  display: flex;
  gap: 0.35rem;
  align-self: center;
}

body.widget-mode .tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 0.25rem !important;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s;
  position: relative;
}

body.widget-mode .tab-btn span {
  display: none !important; /* 隱藏「傳送」、「接收」文字以節省空間 */
}

body.widget-mode .tab-btn:hover {
  color: #00f2fe;
  background: rgba(0, 242, 254, 0.05);
}

body.widget-mode .tab-btn.active {
  color: #00f2fe;
  background: rgba(0, 242, 254, 0.1);
  border: 1px solid rgba(0, 242, 254, 0.2);
  box-shadow: 0 0 8px rgba(0, 242, 254, 0.15);
}

body.widget-mode .tab-btn i {
  width: 14px;
  height: 14px;
}

/* 未讀紅點通知 (使用醒目紅點霓虹發光，防與青色主題融為一體) */
.badge-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 7px;
  height: 7px;
  background-color: #ef4444;
  border-radius: 50%;
  box-shadow: 0 0 6px #ef4444, 0 0 12px #ef4444;
  z-index: 10;
  animation: badge-pulse 1.2s infinite alternate ease-in-out;
}

@keyframes badge-pulse {
  from { transform: scale(0.85); opacity: 0.7; }
  to { transform: scale(1.25); opacity: 1; }
}

.badge-dot.hidden {
  display: none !important;
}

/* 雙分頁之 CSS 互斥切換 (預設為傳送分頁) */
body.widget-mode.tab-send #widget-active-card {
  display: none !important;
}

body.widget-mode.tab-send .global-target-bar,
body.widget-mode.tab-send #share-input-group {
  display: flex !important;
}

/* 切換為接收分頁 */
body.widget-mode.tab-receive #widget-active-card {
  display: flex !important;
}

body.widget-mode.tab-receive .global-target-bar,
body.widget-mode.tab-receive #share-input-group {
  display: none !important;
}

/* ==========================================
   👤 使用者認證樣式
   ========================================== */
.auth-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-color);
  background: rgba(255, 255, 255, 0.03);
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  margin-right: 0.25rem;
}

.auth-username {
  font-weight: 600;
  color: #00f2fe;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-auth-logout {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.75rem;
  transition: color 0.2s;
}

.btn-auth-logout:hover {
  color: #ef4444;
}

/* 小工具下徹底隱藏整個認證狀態，以節省寶貴的 Header 空間且避免無功能人形裝飾 */
body.widget-mode .auth-status {
  display: none !important;
}

/* ==========================================
   📱 裝置列表下拉抽屜樣式
   ========================================== */
.app-header {
  position: relative; /* 確保下拉抽屜可以絕對定位在 Header 底端 */
}

.device-dropdown {
  position: absolute;
  top: 100%;
  right: 0.5rem;
  width: 280px;
  background: rgba(10, 15, 30, 0.95) !important;
  backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 242, 254, 0.2) !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 15px rgba(0, 242, 254, 0.1) !important;
  border-radius: 12px;
  padding: 0.6rem;
  z-index: 2000;
  display: none; /* 預設隱藏，由 JS 控制 active class 切換 */
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.device-dropdown.active {
  display: flex;
}

.dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 0.4rem;
}

.dropdown-header h4 {
  margin: 0;
  font-size: 0.85rem;
  color: #00f2fe;
}

.dropdown-tip {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.device-list {
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.device-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  gap: 0.4rem;
}

.device-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.device-info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  overflow: hidden;
  flex: 1;
}

.device-meta-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.device-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4b5563; /* 預設灰色離線 */
}

.device-status-dot.online {
  background: #10b981; /* 綠色在線 */
  box-shadow: 0 0 6px #10b981;
}

.device-name-container {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-color);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-ip {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.device-item-self {
  font-size: 0.65rem;
  color: #00f2fe;
  background: rgba(0, 242, 254, 0.1);
  padding: 0.05rem 0.25rem;
  border-radius: 4px;
}

.device-actions {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.device-actions .btn-icon {
  width: 24px;
  height: 24px;
  padding: 0;
}

.device-actions .btn-icon i {
  width: 12px;
  height: 12px;
}

.device-actions .btn-icon:hover {
  color: #00f2fe;
}

.device-actions .btn-delete-device:hover {
  color: #ef4444 !important;
}

.loading-placeholder {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  padding: 1rem 0;
}

/* 小工具下的下拉抽屜定位微調 */
body.widget-mode .device-dropdown {
  width: 220px;
  right: 0.25rem;
}

body.widget-mode .device-name-container {
  max-width: 90px;
}

/* ==========================================
   👥 認證對話框 (Modal) 樣式
   ========================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(5, 7, 15, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  transition: opacity 0.3s;
}

.modal-overlay.hidden {
  display: none !important;
}

.modal-content {
  width: 320px;
  background: rgba(10, 15, 30, 0.85);
  border: 1px solid rgba(0, 242, 254, 0.25);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), 0 0 20px rgba(0, 242, 254, 0.15);
  border-radius: 16px;
  overflow: hidden;
  animation: modal-zoom 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modal-zoom {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 0.8rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.01);
}

.modal-header h3 {
  margin: 0;
  font-size: 1rem;
  color: #00f2fe;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.input-field-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.input-field-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.input-field-group input {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
  color: var(--text-color);
  transition: all 0.25s;
}

.input-field-group input:focus {
  border-color: #00f2fe;
  box-shadow: 0 0 8px rgba(0, 242, 254, 0.25);
  outline: none;
}

.auth-error-msg {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-size: 0.75rem;
  text-align: center;
  margin-bottom: 0.5rem;
}

.auth-error-msg.hidden {
  display: none !important;
}

#btn-auth-submit {
  width: 100%;
  padding: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 0.5rem;
}

.auth-toggle-tip {
  margin-top: 0.6rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.auth-toggle-tip a {
  color: #00f2fe;
  text-decoration: none;
  font-weight: 600;
}

.auth-toggle-tip a:hover {
  text-decoration: underline;
}

/* ==========================================
   🎭 小工具模式下登入 Modal 縮放 (防上下截斷)
   ========================================== */
body.widget-mode .modal-content {
  width: 250px;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 242, 254, 0.15);
}

body.widget-mode .modal-header {
  padding: 0.4rem 0.6rem;
}

body.widget-mode .modal-header h3 {
  font-size: 0.85rem;
}

body.widget-mode .modal-body {
  padding: 0.6rem;
  gap: 0.4rem;
}

body.widget-mode .input-field-group {
  margin-bottom: 0.3rem;
  gap: 0.2rem;
}

body.widget-mode .input-field-group label {
  font-size: 0.65rem;
}

body.widget-mode .input-field-group input {
  padding: 0.3rem 0.45rem;
  font-size: 0.75rem;
  border-radius: 5px;
}

body.widget-mode .auth-error-msg {
  padding: 0.3rem;
  font-size: 0.65rem;
  margin-bottom: 0.2rem;
  margin-top: 0.1rem;
}

body.widget-mode #btn-auth-submit {
  margin-top: 0.25rem !important;
  padding: 0.35rem;
  font-size: 0.75rem;
}

body.widget-mode .auth-toggle-tip {
  margin-top: 0.35rem;
  font-size: 0.65rem;
}


