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

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-tertiary: #0f3460;
  --text-primary: #ffffff;
  --text-secondary: #b0b0b0;
  --accent: #4361ee;
  --accent-hover: #3a56d4;
  --border: #2a2a4a;
  --success: #2a9d8f;
  --warning: #f4a261;
  --danger: #e63946;
  --phone-height: 80vh;
  --phone-width: calc(var(--phone-height) * 9 / 19.5);
  --phone-frame-padding: 3px;
  --phone-inner-padding: 6px;
  --phone-frame-radius: calc(var(--phone-width) * 0.111);
  --phone-inner-radius: calc(var(--phone-frame-radius) - 2px);
  --phone-screen-radius: calc(var(--phone-frame-radius) - 6px);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
}

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 280px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.import-btn {
  margin: 12px 16px;
  padding: 12px 16px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s;
}

.import-btn:hover {
  background: var(--accent-hover);
}

.file-tree {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.file-tree::-webkit-scrollbar {
  display: none;
}

.empty-state {
  text-align: center;
  padding: 10px 10px;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 14px;
  color: #858585;
}

.tree-node {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
  justify-content: space-between;
}

.tree-node:hover {
  background: var(--bg-tertiary);
}

.tree-node.selected {
  background: var(--accent);
}

.tree-node-content {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.tree-toggle {
  font-size: 10px;
  width: 16px;
  text-align: center;
  cursor: pointer;
  color: var(--text-secondary);
  order: 3;
}

.tree-delete {
  width: 0;
  height: 0;
  overflow: hidden;
  background-image: url('resources/ic_delete.png');
  background-size: cover;
  background-position: center;
  cursor: pointer;
  transition: width 0.2s, height 0.2s;
  order: 4;
}

.tree-node:hover>.tree-delete {
  width: 28px;
  height: 28px;
}

.tree-toggle-placeholder {
  width: 16px;
  display: inline-block;
}

.tree-icon {
  font-size: 14px;
  order: 1;
}

.tree-name {
  flex: 1;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  order: 2;
}

.tree-preview {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  overflow: hidden;
  order: 4;
}

.tree-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tree-children {
  padding-left: 8px;
  max-height: 222px;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.tree-children::-webkit-scrollbar {
  display: none;
}

.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  padding: 24px;
  overflow: auto;
}

.workspace-header {
  margin-bottom: 16px;
}

.workspace-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
}

.workspace-hint {
  margin-top: 16px;
  padding: 12px 24px;
  background: rgba(67, 97, 238, 0.2);
  border-radius: 8px;
  font-size: 12px;
  color: #a0a0ff;
}

.phone-simulator {
  display: flex;
  align-items: center;
  justify-content: center;
}

.phone-frame {
  position: relative;
  background: #2d2d2d;
  border-radius: var(--phone-frame-radius);
  padding: var(--phone-frame-padding);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  width: var(--phone-width);
  height: var(--phone-height);
}

.phone-inner {
  background: #1a1a1a;
  border-radius: var(--phone-inner-radius);
  padding: var(--phone-inner-padding);
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.phone-screen {
  background: #1f1f1f;
  border-radius: var(--phone-screen-radius);
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.phone-content {
  background: #2d2d2d;
  border-top-left-radius: 0px;
  border-top-right-radius: 0px;
  border-bottom-left-radius: var(--phone-screen-radius);
  border-bottom-right-radius: var(--phone-screen-radius);
  width: calc(100% - 2 * var(--phone-inner-padding) - 2 * var(--phone-frame-padding));
  height: 94.4%;
  overflow: hidden;
  position: absolute;
  bottom: calc(var(--phone-inner-padding) + var(--phone-frame-padding));
  left: 50%;
  transform: translateX(-50%);
}

.wallpaper {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% - 2 * var(--phone-inner-padding) - 2 * var(--phone-frame-padding));
  height: calc(100% - 2 * var(--phone-inner-padding) - 2 * var(--phone-frame-padding));
  object-fit: cover;
  border-radius: var(--phone-screen-radius);
  z-index: 0;
}

.status-bar {
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  padding: calc(var(--phone-width) * 0.014) calc(var(--phone-width) * 0.06);
  font-size: calc(var(--phone-width) * 0.036);
  font-weight: 600;
  color: white;
}

.grid-container {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  min-height: calc(var(--phone-height) * 0.9);
  justify-content: space-between;
  gap: calc(var(--phone-width) * 0.067);
}

.grid-item-container {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--phone-width) * 0.011);
  transform: translate(-50%, -50%);
}

.grid-item-container.custom-container-4 {
  transform: none;
}

.grid-item-container.custom-container-4.hidden {
  visibility: hidden;
}

.grid-item-container.custom-container-4 .icon-label {
  visibility: hidden !important;
}

.grid-item.custom-size-4 {
  cursor: move;
}

.grid-item-container.overlapped {
  display: none;
}

.grid-item-container.initially-hidden {
  visibility: hidden;
}

.grid-item {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: calc(var(--phone-width) * 0.039);
  aspect-ratio: 1;
  width: 56px;
  height: 56px;
  position: relative;
}

.grid-item.custom-size-4 {
  aspect-ratio: auto;
  width: 284px;
  height: 142px;
}

.delete-icon {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  background: var(--danger);
  background-image: url('resources/ic_delete.png');
  background-size: cover;
  background-position: center;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 100;
}

.grid-item:hover .delete-icon {
  opacity: 1;
}

.icon-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--phone-width) * 0.067);
  background: linear-gradient(135deg, var(--accent), var(--success));
  border-radius: calc(var(--phone-width) * 0.039);
}

.icon-label {
  font-size: calc(var(--phone-width) * 0.031);
  text-align: center;
  max-width: calc(var(--phone-width) * 0.167);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: white;
}

.circles-container {
  position: absolute;
  top: calc(var(--phone-height) * 0.7915);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  justify-content: center;
  gap: calc(var(--phone-width) * 0.022);
}

.circle {
  width: calc(var(--phone-width) * 0.022);
  height: calc(var(--phone-width) * 0.022);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
}

.circle.active {
  background: white;
  border-color: white;
}

.settings-panel {
  width: 280px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
}

.settings-header {
  margin-bottom: 24px;
}

.settings-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.settings-section {
  margin-bottom: 20px;
}

.settings-label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.color-picker {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-radius: 8px;
}

.color-picker input[type="color"] {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  background: none;
}

.color-value {
  font-size: 14px;
  color: var(--text-secondary);
  font-family: monospace;
}

.slider-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slider-container input[type="range"] {
  flex: 1;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  appearance: none;
  cursor: pointer;
}

.slider-container input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
}

.slider-value {
  font-size: 14px;
  color: var(--accent);
  min-width: 50px;
  text-align: right;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: 8px;
}

.toggle-row span {
  font-size: 14px;
}

.toggle {
  position: relative;
  width: 44px;
  height: 24px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-primary);
  border-radius: 12px;
  transition: 0.3s;
}

.toggle-slider::before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}

.toggle input:checked+.toggle-slider {
  background: var(--accent);
}

.toggle input:checked+.toggle-slider::before {
  transform: translateX(20px);
}

.export-btn {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  margin-top: 24px;
  transition: background 0.2s;
}

.export-btn:hover {
  background: var(--accent-hover);
}

.export-info {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.export-info p {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.notification-success {
  background: var(--success);
}

.notification-error {
  background: var(--danger);
}

.notification-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  font-size: 14px;
  font-weight: bold;
}

.notification-content {
  flex: 1;
  font-size: 14px;
  color: white;
}

.notification-close {
  font-size: 20px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.7);
  transition: color 0.2s;
}

.notification-close:hover {
  color: white;
}