:root {
  --bg: #f5f6f8;
  --panel-bg: #ffffff;
  --border: #e2e4e9;
  --text: #1a1c23;
  --text-muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.app-header h1 {
  margin: 0 0 4px;
  font-size: 26px;
}

.app-header p {
  margin: 0 0 24px;
  color: var(--text-muted);
}

.header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

.user-bar a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.user-bar a:hover {
  text-decoration: underline;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

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

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.field input[type="text"],
.field input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}

.field input[type="text"]:focus,
.field input[type="password"]:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.error-msg {
  display: block;
  color: var(--danger);
  font-size: 12px;
  min-height: 16px;
  margin-top: 4px;
}

.density-hint {
  display: block;
  font-size: 12px;
  margin-top: -2px;
}

.density-hint[data-level="low"] {
  color: #16a34a;
}

.density-hint[data-level="medium"] {
  color: #b45309;
}

.density-hint[data-level="high"] {
  color: var(--danger);
}

.field-row {
  display: flex;
  gap: 16px;
}

.field-row .field {
  flex: 1;
}

.customize {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.customize summary {
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}

.customize .field {
  margin-top: 14px;
}

.checkbox-field {
  margin-bottom: 12px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.shorten-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f0fdf4;
}

.shorten-result span {
  flex: 1;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item .stats-btn {
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 0 2px;
}

.history-item .stats-btn:hover {
  color: var(--primary);
}

.history-item .stats-info {
  font-size: 11px;
  color: var(--text-muted);
  width: 100%;
  margin-top: 4px;
}

.frame-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px;
}

.frame-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-family: inherit;
}

.frame-option canvas {
  width: 48px;
  height: 48px;
}

.frame-option span {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.2;
}

.frame-option.selected {
  border-color: var(--primary);
  background: #eff4ff;
}

.frame-option.selected span {
  color: var(--primary);
}

input[type="color"] {
  width: 100%;
  height: 38px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

input[type="range"] {
  width: 100%;
}

input[type="file"] {
  width: 100%;
  font-size: 13px;
}

.actions {
  margin-top: 20px;
}

.btn-primary,
.btn-secondary,
.btn-text {
  font-family: inherit;
  cursor: pointer;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-size: 15px;
  font-weight: 600;
}

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

.btn-secondary {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-text {
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 12px;
  text-decoration: underline;
  padding: 4px 0;
}

.btn-text:hover {
  color: var(--danger);
}

.preview-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 300px;
}

.qr-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
}

.qr-preview:empty::before {
  content: "Preview QR akan muncul di sini";
  color: var(--text-muted);
  font-size: 13px;
}

.qr-preview canvas,
.qr-preview img,
.qr-preview svg {
  max-width: 100%;
  height: auto;
}

.download-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.history-panel {
  margin-top: 20px;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history-header h2 {
  margin: 0;
  font-size: 16px;
}

.history-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.history-item .thumb {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.history-item .url-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  cursor: pointer;
}

.history-item .url-text:hover {
  color: var(--primary);
}

.history-item .remove-btn {
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.history-item .remove-btn:hover {
  color: var(--danger);
}

.history-empty {
  color: var(--text-muted);
  font-size: 13px;
  margin: 12px 0 0;
}
