/* twfile - file manager UI (original design) */

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

:root {
  --bg-page: #111827;
  --bg-panel: #1F2937;
  --bg-card: #374151;
  --bg-card-hover: #45526a;
  --bg-elev: #4b5563;
  --border: #374151;
  --border-soft: #2c3a4d;
  --text-0: #eef3fb;
  --text-1: #9aa7bd;
  --text-2: #6b7a91;
  --accent: #3b82f6;
  --accent-h: #2563eb;
  --green: #16a34a;
  --green-h: #15803d;
  --red: #e0344b;
  --red-h: #c81e36;
  --sidebar-w: 264px;
  --gap: 14px;
  --radius: 10px;
}

html, body {
  background: var(--bg-page);
  color: var(--text-0);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* ============ App shell ============ */
.app {
  display: flex;
  gap: var(--gap);
  padding: var(--gap);
  min-height: 100vh;
}

/* ============ Sidebar panel ============ */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  position: sticky;
  top: var(--gap);
  height: calc(100vh - var(--gap) * 2);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 18px;
}
.sidebar-brand img {
  width: 44px;
  height: auto;
  display: block;
  flex-shrink: 0;
}
.brand-text {
  color: var(--text-0);
  font-size: 31px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
}

.account-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.account-box .avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--bg-elev);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.account-box .acc-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 11px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  margin-bottom: 18px;
}
.btn-add:hover { background: var(--accent-h); }

.nav-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.nav-list a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-1);
  font-size: 14px;
  font-weight: 500;
}
.nav-list a:hover { background: var(--bg-card); color: var(--text-0); }
.nav-list a svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-sep { height: 1px; background: var(--border); margin: 16px 4px; }
.sidebar-social {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  color: var(--text-2);
  font-size: 13px;
}
.sidebar-social svg { width: 16px; height: 16px; }
.sidebar-foot {
  margin-top: auto;
  padding: 10px 12px 0;
  color: var(--text-2);
  font-size: 11px;
}

/* ============ Main panel ============ */
.main {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.topbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  position: sticky; top: 0; z-index: 30;
}
.hamburger {
  width: 42px; height: 42px;
  background: var(--accent);
  border: 0; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.hamburger svg { width: 22px; height: 22px; color: #fff; }
.topbar-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.topbar-logo img {
  width: 34px;
  height: auto;
  display: block;
  flex-shrink: 0;
}
.topbar-logo .brand-text {
  font-size: 24px;
}

.content {
  flex: 1 1 auto;
  padding: 22px 26px 40px;
  width: 100%;
}

/* Ad banner */
.ad-note {
  text-align: center;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 8px;
}
.ad-banner {
  display: block;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
  width: min(100%, 760px);
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 22px;
}
.ad-banner img { width: 100%; display: block; }

/* Folder header */
.folder-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.folder-icon {
  width: 44px; height: 44px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.folder-icon svg { width: 40px; height: 40px; }
.folder-meta .live {
  display: inline-block;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 4px;
  margin-bottom: 5px;
}
.folder-meta .folder-name {
  font-size: 21px;
  font-weight: 700;
  line-height: 1.2;
}
.folder-meta .folder-sub {
  font-size: 13px;
  color: var(--text-1);
  margin-top: 3px;
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 0;
  flex-wrap: wrap;
}
.tool-check {
  width: 20px; height: 20px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg-card);
  flex-shrink: 0;
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  height: 40px;
  min-width: 40px;
  padding: 0 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-0);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.icon-btn:hover { background: var(--bg-card-hover); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.icon-btn.green:hover { background: var(--green-h); }
.import-label { display: inline; }
.sort-label { display: inline; }
.toolbar-spacer { flex: 1 1 auto; }
.btn-app {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--red);
  color: #fff;
  border: 0;
  height: 44px;
  padding: 0 22px;
  border-radius: 9px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}
.btn-app:hover { background: var(--red-h); }
.btn-app svg { width: 17px; height: 17px; }

/* File list */
.file-list { display: flex; flex-direction: column; }
.file-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
}
.file-row .row-check {
  width: 20px; height: 20px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg-card);
  flex-shrink: 0;
}
.file-row .row-fileicon {
  width: 30px; height: 30px;
  flex-shrink: 0;
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.file-row .row-fileicon svg { width: 30px; height: 30px; }
.file-thumb {
  flex-shrink: 0;
  width: auto;
  height: auto;
  min-width: 72px;
  max-width: 128px;
  max-height: 128px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-elev);
  display: flex;
  align-items: center;
  justify-content: center;
}
.file-thumb img {
  width: auto;
  height: auto;
  max-width: 128px;
  max-height: 128px;
  object-fit: contain;
  display: block;
}
.file-thumb.file-thumb-ahoo {
  width: 92px;
  height: 128px;
  min-width: 92px;
  max-width: 92px;
  max-height: 128px;
}
.file-thumb.file-thumb-gay {
  width: 92px;
  height: 128px;
  min-width: 92px;
  max-width: 92px;
  max-height: 128px;
}
.file-thumb.file-thumb-ahoo img {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: cover;
  object-position: center center;
}
.file-thumb.file-thumb-gay img {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: cover;
  object-position: center center;
}
.file-body { flex: 1 1 auto; min-width: 0; }
.file-name { font-size: 15px; font-weight: 600; word-break: break-all; }
.file-sub { font-size: 12px; color: var(--text-2); margin-top: 3px; }
.file-buttons { display: flex; gap: 8px; flex-shrink: 0; }
.fbtn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-0);
  height: 38px;
  padding: 0 16px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.fbtn:hover { background: var(--bg-card-hover); }
.fbtn svg { width: 15px; height: 15px; }
.fbtn.kebab { padding: 0; width: 38px; justify-content: center; }

.empty-note {
  padding: 40px 10px;
  text-align: center;
  color: var(--text-2);
  font-size: 14px;
}

/* Footer */
.main-footer {
  border-top: 1px solid var(--border);
  padding: 20px 26px 34px;
  color: var(--text-2);
  font-size: 12px;
  text-align: center;
}

/* Top page hero */
.hero { padding: 50px 0 20px; text-align: center; }
.hero h1 { font-size: 30px; margin-bottom: 6px; }
.hero p { color: var(--text-1); margin-bottom: 22px; }
.recent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 22px;
  text-align: left;
}
.recent-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.recent-card:hover { background: var(--bg-card-hover); }
.recent-card svg { width: 30px; height: 30px; flex-shrink: 0; }
.recent-id { font-size: 15px; font-weight: 700; }
.recent-items { font-size: 12px; color: var(--text-2); }

/* Gate modal */
body.gate-modal-open { overflow: hidden; }
.gate-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
}
.gate-modal.is-open { display: block; }
.gate-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 12, 24, 0.72);
  backdrop-filter: blur(7px);
}
.gate-modal__dialog {
  position: relative;
  width: min(100% - 28px, 430px);
  margin: min(10vh, 72px) auto 0;
  background: #f8fbff;
  color: #0f172a;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
}
.gate-modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  color: #475569;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}
.gate-modal__hero {
  height: 220px;
  background: linear-gradient(180deg, #1d4ed8 0%, #2563eb 45%, #60a5fa 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 20px 16px;
}
.gate-modal__phone {
  width: 144px;
  height: 188px;
  border-radius: 28px;
  background: #0f172a;
  padding: 11px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.34);
  position: relative;
}
.gate-modal__phone-notch {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 56px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}
.gate-modal__phone-screen {
  width: 100%;
  height: 100%;
  border-radius: 20px;
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,0.22), transparent 34%),
    linear-gradient(180deg, #dbeafe 0%, #bfdbfe 34%, #93c5fd 100%);
  overflow: hidden;
  position: relative;
}
.gate-modal__bubble {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 28px;
  height: 38px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.88);
}
.gate-modal__bubble--small {
  left: 34px;
  right: 54px;
  bottom: 78px;
  height: 18px;
  opacity: 0.72;
}
.gate-modal__phone-home {
  position: absolute;
  bottom: 7px;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.34);
}
.gate-modal__body {
  padding: 28px 28px 30px;
  text-align: center;
}
.gate-modal__title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.gate-modal__ios-icon {
  display: none;
}
.gate-modal__ios-icon img {
  display: block;
  width: 122px;
  height: 122px;
  object-fit: cover;
  border-radius: 28px;
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.16);
}
.gate-modal__text {
  margin-top: 10px;
  color: #475569;
  font-size: 14px;
}
.gate-modal__ios-points {
  display: none;
  margin-top: 16px;
  color: #475569;
  font-size: 15px;
  line-height: 1.8;
  text-align: left;
}
.gate-modal__cta {
  display: inline-flex;
  width: 100%;
  justify-content: center;
  align-items: center;
  margin-top: 22px;
  min-height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 55%, #38bdf8 100%);
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  box-shadow: 0 14px 32px rgba(37, 99, 235, 0.34);
}
.gate-modal--ios .gate-modal__hero {
  height: 166px;
  background: #fff;
  padding: 32px 20px 0;
}
.gate-modal--ios .gate-modal__cta {
  background: linear-gradient(135deg, #ec4899 0%, #d946ef 48%, #8b5cf6 100%);
  box-shadow: 0 14px 32px rgba(217, 70, 239, 0.24);
}
.gate-modal--ios .gate-modal__phone {
  display: none;
}
.gate-modal--ios .gate-modal__ios-icon {
  display: block;
}
.gate-modal--ios .gate-modal__title {
  font-size: 17px;
}
.gate-modal--ios .gate-modal__text:empty {
  display: none;
}
.gate-modal--ios .gate-modal__ios-points {
  display: block;
}
.gate-modal--android .gate-modal__hero {
  background: linear-gradient(180deg, #0f9d58 0%, #16a34a 42%, #4ade80 100%);
}
.gate-modal--android .gate-modal__cta {
  background: linear-gradient(135deg, #0f9d58 0%, #16a34a 55%, #22c55e 100%);
  box-shadow: 0 14px 32px rgba(22, 163, 74, 0.32);
}
@media (max-width: 520px) {
  .gate-modal__dialog {
    width: calc(100% - 24px);
    margin-top: max(72px, 18vh);
    border-radius: 22px;
  }
  .gate-modal__hero {
    height: 196px;
  }
  .gate-modal--ios .gate-modal__hero {
    height: 154px;
    padding-top: 28px;
  }
  .gate-modal__ios-icon img {
    width: 112px;
    height: 112px;
    border-radius: 24px;
  }
  .gate-modal__phone {
    width: 126px;
    height: 170px;
  }
  .gate-modal__body {
    padding: 24px 20px 24px;
  }
}

/* Drawer overlay */
.scrim {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 40;
}

/* ============ Responsive ============ */
@media (max-width: 860px) {
  .app { padding: 10px; gap: 10px; }
  .topbar { display: flex; }
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    height: 100vh;
    border-radius: 0;
    border-width: 0 1px 0 0;
  }
  body.drawer-open .sidebar { transform: translateX(0); }
  body.drawer-open .scrim { display: block; }
  .content { padding: 16px 14px 32px; }
  .ad-banner { width: 100%; }
  .file-thumb {
    min-width: 60px;
    max-width: 98px;
    max-height: 98px;
  }
  .file-thumb img {
    max-width: 98px;
    max-height: 98px;
  }
  .file-thumb.file-thumb-ahoo {
    width: 70px;
    height: 98px;
    min-width: 70px;
    max-width: 70px;
    max-height: 98px;
  }
  .file-thumb.file-thumb-gay {
    width: 70px;
    height: 98px;
    min-width: 70px;
    max-width: 70px;
    max-height: 98px;
  }
  .file-thumb.file-thumb-ahoo img {
    max-width: none;
    max-height: none;
  }
  .file-thumb.file-thumb-gay img {
    max-width: none;
    max-height: none;
  }
  .file-buttons { flex-wrap: wrap; justify-content: flex-end; }
  .folder-meta .folder-name { font-size: 19px; }
}
@media (max-width: 520px) {
  .toolbar {
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: hidden;
  }
  .tool-check {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    flex: 0 0 16px;
  }
  .toolbar-spacer { display: none; }
  .icon-btn {
    min-width: 38px;
    width: 38px;
    height: 38px;
    padding: 0;
    gap: 0;
    flex: 0 0 38px;
  }
  .btn-app {
    height: 38px;
    padding: 0 16px;
    gap: 6px;
    font-size: 13px;
    flex: 1 1 0;
    min-width: 0;
    justify-content: center;
  }
  .btn-app svg {
    width: 15px;
    height: 15px;
  }
  .file-row { flex-wrap: wrap; }
  .file-buttons { width: 100%; }
  .fbtn { flex: 1 1 auto; justify-content: center; }
  .fbtn.kebab { flex: 0 0 38px; }
  .icon-btn.green {
    min-width: 38px;
    width: 38px;
  }
  .import-label { display: none; }
  .sort-label { display: none; }
}
