:root {
  --webview-header-height: 48px;
  --webview-tabbar-height: 56px;
  --webview-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --safe-area-inset-top: env(safe-area-inset-top, 0px);
  --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-inset-left: env(safe-area-inset-left, 0px);
  --safe-area-inset-right: env(safe-area-inset-right, 0px);
  --tabbar-bg: #ffffff;
  --tabbar-text: #666666;
  --tabbar-active: var(--primary-color, #007bff);
  --tabbar-border: rgba(0, 0, 0, 0.06);
}

html.dark-mode {
  --tabbar-bg: #1A1A1A;
  --tabbar-text: #AAAAAA;
  --tabbar-border: rgba(255, 255, 255, 0.08);
}

html.webview-mode {
  overscroll-behavior-y: none;
  -webkit-overflow-scrolling: touch;
}

/* 웹뷰 모드 - 모바일 네이티브 터치 경험 (탭 하이라이트/포커스 아웃라인 제거) */
html.webview-mode *,
body[data-webview] * {
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
html.webview-mode a:focus,
html.webview-mode button:focus,
html.webview-mode [role="button"]:focus,
body[data-webview] a:focus,
body[data-webview] button:focus,
body[data-webview] [role="button"]:focus {
  outline: none;
  box-shadow: none;
}

.webview-body {
  margin: 0;
  padding: 0;
  min-height: calc(var(--vh, 1vh) * 100);
  background: var(--bg-color-secondary, #f5f5f5);
  padding-top: 0;
  padding-bottom: var(--webview-tabbar-height);
}
.webview-body.keyboard-open {
  padding-bottom: 0;
}

.webview-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--webview-header-height);
  background: var(--header-bg, #ffffff);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  padding-top: var(--safe-area-inset-top);
  z-index: 1000;
  box-shadow: 0 1px 0 var(--border-color, rgba(0, 0, 0, 0.08));
}
.webview-header__back {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--header-text, #333);
  font-size: 18px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.webview-header__back:active {
  opacity: 0.6;
}
.webview-header__title {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--header-text, #333);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 8px;
}
.webview-header__actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.webview-header__action {
  position: relative;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--header-text, #333);
  font-size: 18px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.webview-header__action:active {
  opacity: 0.6;
}
.webview-header__badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: #ff4444;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.webview-header--full {
  height: auto;
  min-height: var(--webview-header-height);
  padding: 0;
  flex-direction: column;
}

.webview-main {
  min-height: calc(var(--vh, 1vh) * 100);
  padding-top: calc(var(--webview-header-height) + var(--safe-area-inset-top));
  padding-bottom: calc(var(--webview-tabbar-height) + var(--safe-area-inset-bottom) + 16px);
  transition: padding-bottom var(--webview-transition);
}
.webview-main.tabbar-hidden {
  padding-bottom: var(--safe-area-inset-bottom);
}

.webview-tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--webview-tabbar-height);
  background: var(--tabbar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  padding-bottom: 0;
  z-index: 1000;
  border-top: 1px solid var(--tabbar-border, rgba(0, 0, 0, 0.06));
  transform: translateY(0);
  transition: transform var(--webview-transition), background 0.3s ease, border-color 0.3s ease;
}
.webview-tabbar.hidden {
  transform: translateY(100%);
}
.webview-tabbar__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--tabbar-text);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.2s ease;
  position: relative;
  padding: 10px 0 6px;
}
.webview-tabbar__item:active {
  transform: scale(0.92);
}
.webview-tabbar__item.active {
  color: var(--tabbar-active);
}
.webview-tabbar__item.active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  background: var(--tabbar-active);
  border-radius: 0 0 3px 3px;
}
.webview-tabbar__item.active .webview-tabbar__icon {
  transform: translateY(-2px);
}
.webview-tabbar__item.active .webview-tabbar__icon i {
  font-weight: 900;
}
.webview-tabbar__item.active .webview-tabbar__label {
  font-weight: 600;
  opacity: 1;
}
.webview-tabbar__icon {
  position: relative;
  font-size: 22px;
  line-height: 1;
  margin-bottom: 3px;
  transition: transform 0.2s ease;
}
.webview-tabbar__icon i {
  display: block;
}
.webview-tabbar__badge {
  position: absolute;
  top: -4px;
  right: -12px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: linear-gradient(135deg, #ff5f6d, #ff4444);
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(255, 68, 68, 0.4);
}
.webview-tabbar__badge--dot {
  min-width: 8px;
  width: 8px;
  height: 8px;
  padding: 0;
  top: -2px;
  right: -4px;
  box-shadow: 0 1px 3px rgba(255, 68, 68, 0.5);
}
.webview-tabbar__label {
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
  opacity: 0.85;
  letter-spacing: -0.2px;
}

.ptr-indicator {
  position: fixed;
  top: var(--safe-area-inset-top);
  left: 50%;
  transform: translateX(-50%) translateY(-50px);
  width: 36px;
  height: 36px;
  background: var(--bg-color, #fff);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  transition: transform 0.2s ease;
}
.ptr-indicator i {
  font-size: 16px;
  color: var(--primary-color, #007bff);
  transition: transform 0.1s ease;
}
.ptr-indicator.ready i {
  color: #4caf50;
}
.ptr-indicator.refreshing {
  transform: translateX(-50%) translateY(20px) !important;
}
.ptr-indicator.refreshing i {
  animation: ptr-spin 0.8s linear infinite;
}

@keyframes ptr-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
.keyboard-open .webview-tabbar {
  display: none !important;
}
.keyboard-open .webview-main {
  padding-bottom: 0 !important;
}

.webview-body .site-popup--top {
  top: var(--safe-area-inset-top, 0);
}
.webview-body .site-popup--bottom {
  bottom: calc(var(--webview-tabbar-height, 56px) + var(--safe-area-inset-bottom, 0px));
}
.webview-body .site-popup--slide_in {
  bottom: calc(var(--webview-tabbar-height, 56px) + var(--safe-area-inset-bottom, 0px));
}

.webview-only {
  display: none !important;
}
.webview-body .webview-only {
  display: block !important;
}

.webview-body .webview-hide {
  display: none !important;
}

.webview-body .site-footer,
.webview-body .footer-wrapper,
.webview-body .footer-section,
.webview-body [data-widget-area=FOOTER],
.webview-body .widget-footer,
.webview-body .slecs-footer {
  display: none !important;
}
.webview-body .sb-bottom-nav,
.webview-body .tn-bottom-nav {
  display: none !important;
}
.webview-body.hide-header .site-header,
.webview-body.hide-header .header-wrapper,
.webview-body.hide-header [data-widget-area=HEADER] {
  display: none !important;
}
.webview-body .main-content,
.webview-body .content-wrapper,
.webview-body .page-content {
  padding-bottom: calc(var(--webview-tabbar-height) + var(--safe-area-inset-bottom) + 16px) !important;
}

@media (min-width: 768px) {
  .webview-tabbar {
    display: none;
  }
  .webview-main {
    padding-bottom: 16px;
  }
  .webview-body {
    padding-bottom: 0;
  }
}
.tabbar-preview {
  display: flex;
  justify-content: center;
  padding: 20px 0;
}
.tabbar-preview__phone {
  width: 280px;
  height: 500px;
  background: #1a1a1a;
  border-radius: 36px;
  padding: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
.tabbar-preview__screen {
  width: 100%;
  height: 100%;
  background: #f5f5f5;
  border-radius: 24px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.tabbar-preview__content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  font-size: 14px;
}
.tabbar-preview__bar {
  height: 56px;
  background: var(--tabbar-bg, #fff);
  display: flex;
  align-items: center;
  justify-content: space-around;
  border-top: 1px solid #eee;
}
.tabbar-preview__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--tabbar-text, #666);
  font-size: 10px;
  cursor: default;
}
.tabbar-preview__item i {
  font-size: 18px;
  margin-bottom: 2px;
}
.tabbar-preview__item.active {
  color: var(--tabbar-active, var(--primary-color, #007bff));
}

.tabbar-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.tabbar-list__item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid var(--border-color, #e0e0e0);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: grab;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.tabbar-list__item:hover {
  border-color: var(--primary-color, #007bff);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.tabbar-list__item.sortable-ghost {
  opacity: 0.4;
}
.tabbar-list__item.sortable-chosen {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.tabbar-list__handle {
  color: #999;
  margin-right: 12px;
  cursor: grab;
}
.tabbar-list__handle:active {
  cursor: grabbing;
}
.tabbar-list__icon {
  width: 36px;
  height: 36px;
  background: var(--bg-color-secondary, #f5f5f5);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  font-size: 16px;
  color: var(--text-color-muted, #666);
}
.tabbar-list__name {
  font-weight: 600;
  margin-right: 8px;
  color: var(--text-color, #333);
}
.tabbar-list__code {
  color: #999;
  font-size: 12px;
  background: var(--bg-color-secondary, #f0f0f0);
  padding: 2px 8px;
  border-radius: 4px;
  margin-right: 12px;
  font-family: monospace;
}
.tabbar-list__url {
  color: #666;
  font-size: 12px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tabbar-list__actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
}
.tabbar-list__empty {
  text-align: center;
  padding: 48px 24px;
  color: #999;
  background: var(--bg-color-secondary, #f9f9f9);
  border-radius: 8px;
  border: 2px dashed var(--border-color, #ddd);
}
.tabbar-list__empty p {
  margin-bottom: 16px;
}

@media (max-width: 768px) {
  .tabbar-preview__phone {
    width: 240px;
    height: 420px;
    border-radius: 28px;
    padding: 10px;
  }
  .tabbar-preview__screen {
    border-radius: 20px;
  }
  .tabbar-preview__bar {
    height: 48px;
  }
  .tabbar-preview__item {
    font-size: 9px;
  }
  .tabbar-preview__item i {
    font-size: 16px;
  }
  .tabbar-list__item {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
  }
  .tabbar-list__url {
    flex-basis: 100%;
    order: 10;
    margin-top: 4px;
    padding-left: 48px;
  }
  .tabbar-list__actions {
    margin-left: 0;
  }
}
