:root {
  /* Modern, vibrant color palette */
  --color-primary: #6366f1;
  --color-primary-hover: #4f46e5;
  --color-bg: #f8fafc;
  --color-card-bg: #ffffff;
  --color-text-main: #0f172a;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;
  --color-border-focus: #94a3b8;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.4);

  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
}

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

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Subtle texture for premium feel */
  background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23e2e8f0' fill-opacity='0.4' fill-rule='evenodd'%3E%3Ccircle cx='3' cy='3' r='1'/%3E%3Ccircle cx='13' cy='13' r='1'/%3E%3C/g%3E%3C/svg%3E");
}

/* Navigation Bar */
.top-nav {
  width: 100%;
  background-color: var(--color-card-bg);
  box-shadow: var(--shadow-sm);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-logo {
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--color-primary);
  letter-spacing: -0.05em;
}

.btn-login-google {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: white;
  border: 1px solid var(--color-border);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  color: #3c4043;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.btn-login-google:hover {
  background-color: #f8f9fa;
  box-shadow: var(--shadow-md);
}

.btn-login-google img {
  width: 18px;
  height: 18px;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--color-primary);
}

.user-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.btn-logout {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
}

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

.app-container {
  width: 100%;
  max-width: 600px;
  padding: 2rem;
  margin-top: 2rem;
}

.app-header {
  text-align: center;
  margin-bottom: 2rem;
}

.app-header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-text-main);
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.app-header p {
  color: var(--color-text-muted);
  font-size: 1.1rem;
}

.usage-limit-info {
  margin-top: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: rgba(99, 102, 241, 0.1);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.9rem;
}

.badge {
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-guest { background-color: #94a3b8; color: white; }
.badge-user { background-color: var(--color-primary); color: white; }

.limit-text { color: var(--color-text-main); font-weight: 500; }

.card {
  background-color: var(--color-card-bg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
}

.analysis-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text-main);
}

.form-input, .form-select {
  width: 100%;
  padding: 0.75rem 1rem;
  font-family: inherit;
  font-size: 1rem;
  color: var(--color-text-main);
  background-color: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-input::placeholder {
  color: #94a3b8;
}

/* Upload Zone Styles */
.upload-zone {
  position: relative;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background-color: #fcfcfd;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  overflow: hidden; /* For preview image containment */
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--color-primary);
  background-color: rgba(99, 102, 241, 0.05);
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.upload-icon {
  color: var(--color-primary);
  margin-bottom: 0.5rem;
}

.upload-placeholder p {
  font-weight: 500;
  color: var(--color-text-main);
}

.upload-hint {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.thumbnail-preview {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background-color: #000;
  border-radius: calc(var(--radius-lg) - 2px);
  z-index: 10;
}

.hidden {
  display: none !important;
}

/* Custom Select Dropdown Styling Wrapper */
.select-wrapper {
  position: relative;
}

.select-wrapper::after {
  content: "▼";
  font-size: 0.8rem;
  color: var(--color-text-muted);
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.form-select {
  appearance: none; /* Hide default arrow */
  padding-right: 2.5rem;
}

/* Button */
.btn-primary {
  display: inline-block;
  width: 100%;
  padding: 1rem;
  margin-top: 1rem;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  color: #ffffff;
  background-color: var(--color-primary);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  background-color: var(--color-primary-hover);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

.btn-primary:active {
  transform: translateY(0);
}

/* Responsive */
@media (max-width: 640px) {
  .card {
    padding: 1.5rem;
  }
  .app-container {
    padding: 1rem;
    margin-top: 1rem;
  }
}

/* Loading & Result Sections */
.text-center {
  text-align: center;
  padding: 4rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 2rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--color-text-main);
}

.loading-subtitle {
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.result-container {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.result-header-wrapper {
  text-align: center;
  border-bottom: 2px solid var(--color-border);
  padding-bottom: 1.5rem;
}

.result-header {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--color-text-main);
  margin-bottom: 0.5rem;
}

.score-highlight {
  color: var(--color-primary);
  font-size: 2.2rem;
}

.result-summary {
  color: var(--color-text-muted);
  font-size: 1.1rem;
  font-weight: 500;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.metric-card {
  background-color: var(--color-bg);
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

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

.metric-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text-main);
  text-align: right;
}

.progress-bar-bg {
  width: 100%;
  height: 8px;
  background-color: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background-color: var(--color-primary);
  width: 0%;
  transition: width 1s ease-out;
}

.analysis-feedback {
  background-color: rgba(99, 102, 241, 0.05);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  border-left: 4px solid var(--color-primary);
}

.analysis-feedback h3 {
  font-size: 1.2rem;
  color: var(--color-text-main);
  margin-bottom: 1rem;
}

.analysis-item {
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.analysis-item:last-child {
  margin-bottom: 0;
}

.analysis-item p {
  margin-top: 0.25rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.status-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  background-color: #e2e8f0;
  color: #475569;
}

.status-badge.Good, .status-badge.Pass { background-color: #dcfce7; color: #0f5132; }
.status-badge.Warning { background-color: #fef08a; color: #854d0e; }
.status-badge.Bad, .status-badge.Fail { background-color: #fee2e2; color: #991b1b; }

.action-plan {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.plan-card {
  padding: 1.25rem;
  border-radius: var(--radius-md);
}

.plan-card h3 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}

.plan-card ul {
  padding-left: 1.5rem;
  color: var(--color-text-main);
  font-size: 0.95rem;
  line-height: 1.6;
}

.plan-card.pros {
  background-color: #f0fdf4;
  border: 1px solid #bbf7d0;
}
.plan-card.pros h3 { color: #166534; }

.plan-card.cons {
  background-color: #fef2f2;
  border: 1px solid #fecaca;
}
.plan-card.cons h3 { color: #991b1b; }

.prescriptions {
  background-color: #fffbeb;
  border: 1px solid #fde047;
  padding: 1.5rem;
  border-radius: var(--radius-lg);
}

.prescriptions h3 {
  color: #854d0e;
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

.prescription-list {
  list-style: none;
  padding: 0;
  counter-reset: custom-counter;
}

.prescription-list li {
  counter-increment: custom-counter;
  margin-bottom: 0.75rem;
  padding-left: 2rem;
  position: relative;
  font-weight: 500;
  color: var(--color-text-main);
  line-height: 1.5;
}

.prescription-list li::before {
  content: counter(custom-counter);
  position: absolute;
  left: 0;
  top: 0;
  background-color: #eab308;
  color: white;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: bold;
}

.monetization-hook {
  text-align: center;
  font-size: 0.95rem;
  color: var(--color-primary);
  font-weight: 600;
  background-color: #e0e7ff;
  padding: 1rem;
  border-radius: var(--radius-md);
  margin-top: 1rem;
}

@media (min-width: 640px) {
  .action-plan {
    flex-direction: row;
  }
  .plan-card {
    flex: 1;
  }
}

.btn-secondary {
  display: inline-block;
  width: 100%;
  padding: 1rem;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  color: var(--color-text-main);
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-secondary:hover {
  background-color: #e2e8f0;
}